@vertigis/react-ui 13.3.0 → 14.0.0
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/NumberInput/NumberInput.js +4 -0
- package/package.json +1 -1
- package/styles/createTheme.js +90 -16
|
@@ -105,6 +105,10 @@ const NumberInput = forwardRef(function NumberInput({ onChange, onBlur, value, d
|
|
|
105
105
|
}
|
|
106
106
|
setNumericValue(correctValue(value));
|
|
107
107
|
}
|
|
108
|
+
else {
|
|
109
|
+
setTextValue("");
|
|
110
|
+
setNumericValue(NaN);
|
|
111
|
+
}
|
|
108
112
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- It's intentional to omit numericValue. We only want this to run when the incoming value changes, not when numericValue changes in handleChange().
|
|
109
113
|
}, [value, formatNumber, correctValue]);
|
|
110
114
|
const handleChange = useCallback(event => {
|
package/package.json
CHANGED
package/styles/createTheme.js
CHANGED
|
@@ -9,6 +9,10 @@ const primaryTextColor = "#333333";
|
|
|
9
9
|
const primaryErrorColor = "#B22222";
|
|
10
10
|
const primaryWarningColor = "#BF5300";
|
|
11
11
|
const primarySuccessColor = "#008040";
|
|
12
|
+
const fontWeightLight = 300;
|
|
13
|
+
const fontWeightRegular = 400;
|
|
14
|
+
const fontWeightMedium = 600;
|
|
15
|
+
const fontWeightBold = 700;
|
|
12
16
|
const lightThemeOverrides = {
|
|
13
17
|
palette: {
|
|
14
18
|
background: {
|
|
@@ -20,7 +24,7 @@ const lightThemeOverrides = {
|
|
|
20
24
|
secondary: secondaryTextColor,
|
|
21
25
|
},
|
|
22
26
|
};
|
|
23
|
-
const
|
|
27
|
+
const getDefaultOptions = (pxToRem) => ({
|
|
24
28
|
palette: {
|
|
25
29
|
primary: blue,
|
|
26
30
|
secondary: green,
|
|
@@ -29,10 +33,80 @@ const defaultOptions = {
|
|
|
29
33
|
warning: { main: primaryWarningColor },
|
|
30
34
|
success: { main: primarySuccessColor },
|
|
31
35
|
},
|
|
36
|
+
// Defaults should match https://meridian.vertigis.com/docs/design-language/#typography
|
|
37
|
+
// Use `pxToRem` so clients with different root font sizes still work properly.
|
|
32
38
|
typography: {
|
|
33
|
-
fontFamily: `"Segoe UI", "Helvetica Neue", "
|
|
39
|
+
fontFamily: `"Segoe UI", "Helvetica Neue", "Roboto", Helvetica, Arial, sans-serif`,
|
|
40
|
+
fontWeightLight,
|
|
41
|
+
fontWeightRegular,
|
|
42
|
+
fontWeightMedium,
|
|
43
|
+
fontWeightBold,
|
|
44
|
+
h1: {
|
|
45
|
+
fontSize: pxToRem(32),
|
|
46
|
+
fontWeight: fontWeightLight,
|
|
47
|
+
lineHeight: 1.25,
|
|
48
|
+
},
|
|
49
|
+
h2: {
|
|
50
|
+
fontSize: pxToRem(28),
|
|
51
|
+
fontWeight: fontWeightLight,
|
|
52
|
+
lineHeight: 1.25,
|
|
53
|
+
},
|
|
54
|
+
h3: {
|
|
55
|
+
fontSize: pxToRem(26),
|
|
56
|
+
fontWeight: fontWeightRegular,
|
|
57
|
+
lineHeight: 1.25,
|
|
58
|
+
},
|
|
59
|
+
h4: {
|
|
60
|
+
fontSize: pxToRem(22),
|
|
61
|
+
fontWeight: fontWeightRegular,
|
|
62
|
+
lineHeight: 1.25,
|
|
63
|
+
},
|
|
64
|
+
h5: {
|
|
65
|
+
fontSize: pxToRem(20),
|
|
66
|
+
fontWeight: fontWeightMedium,
|
|
67
|
+
lineHeight: 1.25,
|
|
68
|
+
},
|
|
69
|
+
h6: {
|
|
70
|
+
fontSize: pxToRem(16),
|
|
71
|
+
fontWeight: fontWeightMedium,
|
|
72
|
+
lineHeight: 1.125,
|
|
73
|
+
},
|
|
74
|
+
subtitle1: {
|
|
75
|
+
fontSize: pxToRem(16),
|
|
76
|
+
fontWeight: fontWeightRegular,
|
|
77
|
+
lineHeight: 1.125,
|
|
78
|
+
letterSpacing: pxToRem(0.15),
|
|
79
|
+
},
|
|
80
|
+
subtitle2: {
|
|
81
|
+
fontSize: pxToRem(14),
|
|
82
|
+
fontWeight: fontWeightMedium,
|
|
83
|
+
lineHeight: 1.5,
|
|
84
|
+
letterSpacing: pxToRem(0.17),
|
|
85
|
+
},
|
|
86
|
+
body1: {
|
|
87
|
+
fontSize: pxToRem(14),
|
|
88
|
+
fontWeight: fontWeightRegular,
|
|
89
|
+
lineHeight: 1.5,
|
|
90
|
+
},
|
|
91
|
+
body2: {
|
|
92
|
+
fontSize: pxToRem(12),
|
|
93
|
+
fontWeight: fontWeightRegular,
|
|
94
|
+
lineHeight: 1.375,
|
|
95
|
+
},
|
|
96
|
+
caption: {
|
|
97
|
+
fontSize: pxToRem(14),
|
|
98
|
+
fontWeight: fontWeightRegular,
|
|
99
|
+
fontStyle: "italic",
|
|
100
|
+
lineHeight: 1.625,
|
|
101
|
+
},
|
|
102
|
+
button: {
|
|
103
|
+
fontSize: pxToRem(14),
|
|
104
|
+
fontWeight: fontWeightRegular,
|
|
105
|
+
lineHeight: 1.75,
|
|
106
|
+
textTransform: "none",
|
|
107
|
+
},
|
|
34
108
|
},
|
|
35
|
-
};
|
|
109
|
+
});
|
|
36
110
|
const defaultDenseOptions = {
|
|
37
111
|
spacing: 6,
|
|
38
112
|
components: {
|
|
@@ -140,7 +214,7 @@ const getMenuItemStyles = ({ palette, transitions }) => ({
|
|
|
140
214
|
* separately after the fact.
|
|
141
215
|
*/
|
|
142
216
|
function getOverrides(theme) {
|
|
143
|
-
const { palette, shape, spacing, transitions, typography } = theme;
|
|
217
|
+
const { palette, shape, spacing, transitions, typography: { pxToRem, fontWeightMedium, fontWeightBold, body1, subtitle2 }, } = theme;
|
|
144
218
|
const isDarkMode = palette.mode === "dark";
|
|
145
219
|
return {
|
|
146
220
|
components: {
|
|
@@ -181,7 +255,6 @@ function getOverrides(theme) {
|
|
|
181
255
|
root: {
|
|
182
256
|
borderStyle: "solid",
|
|
183
257
|
borderWidth: 1,
|
|
184
|
-
textTransform: "none",
|
|
185
258
|
"&.Mui-focusVisible:active": {
|
|
186
259
|
backgroundColor: alpha(palette.grey.A200, 0.5),
|
|
187
260
|
},
|
|
@@ -327,13 +400,13 @@ function getOverrides(theme) {
|
|
|
327
400
|
boxSizing: "inherit",
|
|
328
401
|
},
|
|
329
402
|
"strong, b": {
|
|
330
|
-
fontWeight:
|
|
403
|
+
fontWeight: fontWeightBold,
|
|
331
404
|
},
|
|
332
405
|
body: {
|
|
333
406
|
margin: 0,
|
|
334
407
|
padding: 0,
|
|
335
408
|
color: palette.text.primary,
|
|
336
|
-
...
|
|
409
|
+
...body1,
|
|
337
410
|
backgroundColor: palette.background.default,
|
|
338
411
|
overflow: "hidden",
|
|
339
412
|
"@media print": {
|
|
@@ -386,7 +459,7 @@ function getOverrides(theme) {
|
|
|
386
459
|
},
|
|
387
460
|
styleOverrides: {
|
|
388
461
|
root: {
|
|
389
|
-
...
|
|
462
|
+
...subtitle2,
|
|
390
463
|
marginTop: 0,
|
|
391
464
|
marginBottom: spacing(0.5),
|
|
392
465
|
"&.Mui-error": {
|
|
@@ -406,9 +479,9 @@ function getOverrides(theme) {
|
|
|
406
479
|
margin: spacing(0.5, 0),
|
|
407
480
|
color: "currentColor",
|
|
408
481
|
// Clear InlineHelp button
|
|
409
|
-
paddingRight:
|
|
482
|
+
paddingRight: pxToRem(32),
|
|
410
483
|
lineHeight: 1.4,
|
|
411
|
-
fontWeight:
|
|
484
|
+
fontWeight: fontWeightMedium,
|
|
412
485
|
"&.Mui-error, &.Mui-error.Mui-focused": {
|
|
413
486
|
borderRadius: shape.borderRadius,
|
|
414
487
|
color: palette.text.primary,
|
|
@@ -416,8 +489,8 @@ function getOverrides(theme) {
|
|
|
416
489
|
// Error icon background circle
|
|
417
490
|
"& .GcxFormLabel-errorIconBackground": {
|
|
418
491
|
display: "inline-flex",
|
|
419
|
-
width:
|
|
420
|
-
height:
|
|
492
|
+
width: pxToRem(22),
|
|
493
|
+
height: pxToRem(22),
|
|
421
494
|
justifyContent: "center",
|
|
422
495
|
marginRight: "4px",
|
|
423
496
|
alignItems: "center",
|
|
@@ -618,7 +691,7 @@ function getOverrides(theme) {
|
|
|
618
691
|
// theme's `htmlFontSize` setting. Override with
|
|
619
692
|
// pxToRem to get the correct height regardless of
|
|
620
693
|
// HTML font size.
|
|
621
|
-
fontSize:
|
|
694
|
+
fontSize: pxToRem(20),
|
|
622
695
|
},
|
|
623
696
|
},
|
|
624
697
|
},
|
|
@@ -664,7 +737,7 @@ function getOverrides(theme) {
|
|
|
664
737
|
valueLabel: {
|
|
665
738
|
// Set the minimum height to avoid it jumping around
|
|
666
739
|
// when the label does not have a value.
|
|
667
|
-
minHeight:
|
|
740
|
+
minHeight: pxToRem(28),
|
|
668
741
|
},
|
|
669
742
|
},
|
|
670
743
|
},
|
|
@@ -790,7 +863,7 @@ function getOverrides(theme) {
|
|
|
790
863
|
// Chosen to match PanelGroup in react-ui-internal.
|
|
791
864
|
backgroundColor: isDarkMode ? palette.grey[900] : palette.grey[200],
|
|
792
865
|
fontWeight: "bold",
|
|
793
|
-
fontSize:
|
|
866
|
+
fontSize: pxToRem(14),
|
|
794
867
|
},
|
|
795
868
|
},
|
|
796
869
|
},
|
|
@@ -967,7 +1040,8 @@ function createTheme(options = {}) {
|
|
|
967
1040
|
// If we are using light mode, then we want to use our defined light theme palette
|
|
968
1041
|
const modeOptions = mode === "light" ? lightThemeOverrides : {};
|
|
969
1042
|
const { dense = false, ...overrides } = options;
|
|
970
|
-
const
|
|
1043
|
+
const defaultTheme = createMuiTheme();
|
|
1044
|
+
const mergedOptions = deepAssign({}, getDefaultOptions(defaultTheme.typography.pxToRem), modeOptions, dense ? defaultDenseOptions : {}, overrides);
|
|
971
1045
|
const createdTheme = createMuiTheme(mergedOptions);
|
|
972
1046
|
return overrideTheme(createdTheme, getOverrides(createdTheme));
|
|
973
1047
|
}
|