@vertigis/react-ui 14.4.0 → 14.4.2

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.
@@ -13,7 +13,7 @@ import { useId } from "../utils/react.js";
13
13
  * NumberInput instead of a normal input.
14
14
  */
15
15
  const FormLabelNumberField = forwardRef((props, ref) => {
16
- const { autoComplete, autoFocus = false, children, className, defaultValue, FormHelperTextProps, fullWidth = false, helperText, id: idProp, InputLabelProps, inputProps, InputProps, inputRef, label, name, NumberInputComponent, onBlur, onChange, onFocus, placeholder, value, min, max, numberOutOfRangeErrorText, invalidNumberErrorText, maxDecimalPlacesErrorText, error, onError, onErrorEnd, allowUndefined, maxDecimalPlaces = DEFAULT_DECIMAL_PLACES, correctOnBlur = true, ...other } = props;
16
+ const { autoComplete, autoFocus = false, children, className, defaultValue, FormHelperTextProps, fullWidth = false, helperText, id: idProp, InputLabelProps, inputProps, InputProps, inputRef, label, name, NumberInputComponent, onBlur, onChange, onFocus, placeholder, value, min, max, numberOutOfRangeErrorText, invalidNumberErrorText, maxDecimalPlacesErrorText, error = false, onError, onErrorEnd, allowUndefined, maxDecimalPlaces = DEFAULT_DECIMAL_PLACES, correctOnBlur = true, ...other } = props;
17
17
  const id = useId(idProp);
18
18
  const helperTextId = helperText && id ? `${id}-helper-text` : undefined;
19
19
  const inputLabelId = label && id ? `${id}-label` : undefined;
@@ -47,7 +47,7 @@ const FormLabelNumberField = forwardRef((props, ref) => {
47
47
  setNumberError(undefined);
48
48
  onErrorEnd?.(numericValue, textValue);
49
49
  }, [onErrorEnd]);
50
- return (_jsxs(FormControl, { fullWidth: fullWidth, ref: ref, error: error ?? !!numberError, ...other, children: [label && (_jsx(FormLabel, { htmlFor: id, id: inputLabelId, children: label })), (helperText ?? numberError) && (_jsx(FormHelperText, { ...FormHelperTextProps, id: helperTextId, children: numberError ?? helperText })), _jsx(FormNumberInput
50
+ return (_jsxs(FormControl, { fullWidth: fullWidth, ref: ref, error: error || !!numberError, ...other, children: [label && (_jsx(FormLabel, { htmlFor: id, id: inputLabelId, children: label })), (helperText ?? numberError) && (_jsx(FormHelperText, { ...FormHelperTextProps, id: helperTextId, children: numberError ?? helperText })), _jsx(FormNumberInput
51
51
  // All of the properties fron here down to `InputProps` can be overridden by it.
52
52
  // Any after that must be controlled by this component itself.
53
53
  , {
@@ -9,7 +9,7 @@ export const DEFAULT_DECIMAL_PLACES = 16;
9
9
  * formatting and parsing. Default formatting and parsing can be overridden by
10
10
  * wrapping this component in a NumberFormatContext.Provider.
11
11
  */
12
- const NumberInput = forwardRef(({ onChange, onBlur, value, defaultValue, max, min, error, onError, onErrorEnd, allowUndefined, correctOnBlur = true, maxDecimalPlaces = DEFAULT_DECIMAL_PLACES, ...props }, ref) => {
12
+ const NumberInput = forwardRef(({ onChange, onBlur, value, defaultValue, max, min, error = false, onError, onErrorEnd, allowUndefined, correctOnBlur = true, maxDecimalPlaces = DEFAULT_DECIMAL_PLACES, ...props }, ref) => {
13
13
  const { formatNumber, parseNumber } = useContext(NumberFormatContext);
14
14
  const [textValue, setTextValue] = useState(value === undefined ? "" : formatNumber(value));
15
15
  const [numericValue, setNumericValue] = useState(value ?? NaN);
@@ -22,7 +22,7 @@ const NumberInput = forwardRef(({ onChange, onBlur, value, defaultValue, max, mi
22
22
  : // If the user begins to type a negative number, do not present an invalid
23
23
  // error.
24
24
  textValue?.trim() !== "-" && parseNumber(textValue) !== numericValue;
25
- const previousError = usePrevious(error ?? invalidError);
25
+ const previousError = usePrevious(error || invalidError);
26
26
  useEffect(() => {
27
27
  if (!isNaN(numericValue) &&
28
28
  !isOutOfRange(numericValue) &&
@@ -31,7 +31,7 @@ const NumberInput = forwardRef(({ onChange, onBlur, value, defaultValue, max, mi
31
31
  }
32
32
  }, [numericValue, isOutOfRange, isTooPrecise]);
33
33
  useEffect(() => {
34
- const e = error ?? invalidError;
34
+ const e = error || invalidError;
35
35
  if (e !== previousError) {
36
36
  if (invalidError) {
37
37
  const inputVal = parseNumber(textValue);
@@ -132,7 +132,7 @@ const NumberInput = forwardRef(({ onChange, onBlur, value, defaultValue, max, mi
132
132
  }
133
133
  onBlur?.(event);
134
134
  }, [correctOnBlur, reformat, onBlur]);
135
- return (_jsx(Input, { ref: ref, type: "text", value: textValue, onChange: handleChange, onBlur: handleBlur, defaultValue: typeof defaultValue === "number" ? formatNumber(defaultValue) : undefined, "data-test": "NumberInput-container", error: error ?? invalidError, ...props }));
135
+ return (_jsx(Input, { ref: ref, type: "text", value: textValue, onChange: handleChange, onBlur: handleBlur, defaultValue: typeof defaultValue === "number" ? formatNumber(defaultValue) : undefined, "data-test": "NumberInput-container", error: error || invalidError, ...props }));
136
136
  });
137
137
  export default NumberInput;
138
138
  function getDecimalPlaces(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertigis/react-ui",
3
- "version": "14.4.0",
3
+ "version": "14.4.2",
4
4
  "description": "Utilities and React components used in VertiGIS applications.",
5
5
  "keywords": [
6
6
  "vertigis",
@@ -9,6 +9,7 @@ const primaryTextColor = "#333333";
9
9
  const primaryErrorColor = "#B22222";
10
10
  const primaryWarningColor = "#BF5300";
11
11
  const primarySuccessColor = "#008040";
12
+ const fontWeightLightest = 200;
12
13
  const fontWeightLight = 300;
13
14
  const fontWeightRegular = 400;
14
15
  const fontWeightMedium = 600;
@@ -47,22 +48,22 @@ const getDefaultOptions = (pxToRem) => ({
47
48
  lineHeight: 1.25,
48
49
  },
49
50
  h2: {
50
- fontSize: pxToRem(28),
51
+ fontSize: pxToRem(26),
51
52
  fontWeight: fontWeightLight,
52
53
  lineHeight: 1.25,
53
54
  },
54
55
  h3: {
55
- fontSize: pxToRem(26),
56
- fontWeight: fontWeightRegular,
56
+ fontSize: pxToRem(22),
57
+ fontWeight: fontWeightLightest,
57
58
  lineHeight: 1.25,
58
59
  },
59
60
  h4: {
60
- fontSize: pxToRem(22),
61
+ fontSize: pxToRem(20),
61
62
  fontWeight: fontWeightRegular,
62
63
  lineHeight: 1.25,
63
64
  },
64
65
  h5: {
65
- fontSize: pxToRem(20),
66
+ fontSize: pxToRem(18),
66
67
  fontWeight: fontWeightMedium,
67
68
  lineHeight: 1.25,
68
69
  },