@etsoo/materialui 1.3.19 → 1.3.21

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.
@@ -1,9 +1,22 @@
1
1
  import React from "react";
2
2
  import { InputFieldProps } from "./InputField";
3
+ import { Currency } from "@etsoo/appscript";
3
4
  /**
4
5
  * Number input field properties
5
6
  */
6
7
  export type NumberInputFieldProps = Omit<InputFieldProps, "type" | "inputProps"> & {
8
+ /**
9
+ * Currency
10
+ */
11
+ currency?: string | Currency;
12
+ /**
13
+ * End symbol
14
+ */
15
+ endSymbol?: string;
16
+ /**
17
+ * Start (Currency) symbol
18
+ */
19
+ symbol?: string;
7
20
  /**
8
21
  * Input field style
9
22
  */
@@ -1,17 +1,26 @@
1
1
  import React from "react";
2
2
  import { InputField } from "./InputField";
3
+ import { InputAdornment } from "@mui/material";
4
+ import { NumberUtils } from "@etsoo/shared";
3
5
  /**
4
6
  * Number input field, for controlled only components, please see IntInputField and MoneyInputField
5
7
  * @param props Props
6
8
  * @returns Component
7
9
  */
8
10
  export function NumberInputField(props) {
9
- const { inputStyle, min = 0, step = 1, max = 9999999, ...rest } = props;
10
- return (React.createElement(InputField, { inputProps: {
11
+ const { currency, inputStyle, min = 0, step = 1, symbol = currency
12
+ ? `${currency} ${NumberUtils.getCurrencySymbol(currency)}`
13
+ : undefined, endSymbol, max = 9999999, InputProps, ...rest } = props;
14
+ return (React.createElement(InputField, { type: "number", inputProps: {
11
15
  min,
12
16
  step,
13
17
  max,
14
18
  style: inputStyle,
15
19
  inputMode: "numeric"
20
+ }, InputProps: {
21
+ startAdornment: symbol ? (React.createElement(React.Fragment, null,
22
+ React.createElement(InputAdornment, { position: "start" }, symbol))) : undefined,
23
+ endAdornment: endSymbol ? (React.createElement(InputAdornment, { position: "end" }, endSymbol)) : undefined,
24
+ ...InputProps
16
25
  }, ...rest }));
17
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.19",
3
+ "version": "1.3.21",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@emotion/css": "^11.11.2",
51
51
  "@emotion/react": "^11.11.1",
52
52
  "@emotion/styled": "^11.11.0",
53
- "@etsoo/appscript": "^1.4.53",
53
+ "@etsoo/appscript": "^1.4.54",
54
54
  "@etsoo/notificationbase": "^1.1.28",
55
55
  "@etsoo/react": "^1.7.11",
56
56
  "@etsoo/shared": "^1.2.12",
@@ -1,5 +1,8 @@
1
1
  import React from "react";
2
2
  import { InputField, InputFieldProps } from "./InputField";
3
+ import { Currency } from "@etsoo/appscript";
4
+ import { InputAdornment } from "@mui/material";
5
+ import { NumberUtils } from "@etsoo/shared";
3
6
 
4
7
  /**
5
8
  * Number input field properties
@@ -8,6 +11,21 @@ export type NumberInputFieldProps = Omit<
8
11
  InputFieldProps,
9
12
  "type" | "inputProps"
10
13
  > & {
14
+ /**
15
+ * Currency
16
+ */
17
+ currency?: string | Currency;
18
+
19
+ /**
20
+ * End symbol
21
+ */
22
+ endSymbol?: string;
23
+
24
+ /**
25
+ * Start (Currency) symbol
26
+ */
27
+ symbol?: string;
28
+
11
29
  /**
12
30
  * Input field style
13
31
  */
@@ -35,10 +53,23 @@ export type NumberInputFieldProps = Omit<
35
53
  * @returns Component
36
54
  */
37
55
  export function NumberInputField(props: NumberInputFieldProps) {
38
- const { inputStyle, min = 0, step = 1, max = 9999999, ...rest } = props;
56
+ const {
57
+ currency,
58
+ inputStyle,
59
+ min = 0,
60
+ step = 1,
61
+ symbol = currency
62
+ ? `${currency} ${NumberUtils.getCurrencySymbol(currency)}`
63
+ : undefined,
64
+ endSymbol,
65
+ max = 9999999,
66
+ InputProps,
67
+ ...rest
68
+ } = props;
39
69
 
40
70
  return (
41
71
  <InputField
72
+ type="number"
42
73
  inputProps={{
43
74
  min,
44
75
  step,
@@ -46,6 +77,17 @@ export function NumberInputField(props: NumberInputFieldProps) {
46
77
  style: inputStyle,
47
78
  inputMode: "numeric"
48
79
  }}
80
+ InputProps={{
81
+ startAdornment: symbol ? (
82
+ <React.Fragment>
83
+ <InputAdornment position="start">{symbol}</InputAdornment>
84
+ </React.Fragment>
85
+ ) : undefined,
86
+ endAdornment: endSymbol ? (
87
+ <InputAdornment position="end">{endSymbol}</InputAdornment>
88
+ ) : undefined,
89
+ ...InputProps
90
+ }}
49
91
  {...rest}
50
92
  />
51
93
  );