@superdispatch/ui 0.26.0 → 0.27.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.
@@ -1,7 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["value", "inputRef", "onChange", "valueIsNumericString", "thousandSeparator", "disableValueParsing"],
4
- _excluded2 = ["id", "InputProps"];
4
+ _excluded2 = ["value", "inputRef", "onChange", "valueIsNumericString", "thousandSeparator", "disableValueParsing"],
5
+ _excluded3 = ["id", "InputProps", "isText"];
5
6
  import { TextField } from '@material-ui/core';
6
7
  import { forwardRef } from 'react';
7
8
  import { NumericFormat } from 'react-number-format';
@@ -25,31 +26,61 @@ function NumberInputComponent(_ref) {
25
26
  thousandSeparator: thousandSeparator,
26
27
  allowedDecimalSeparators: ['.', ','],
27
28
  onValueChange: (values, sourceInfo) => {
28
- var inputValue = values.value;
29
29
  var {
30
30
  event
31
31
  } = sourceInfo;
32
32
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
33
33
  onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread(_objectSpread({}, event), {}, {
34
34
  target: _objectSpread(_objectSpread({}, event === null || event === void 0 ? void 0 : event.target), {}, {
35
- value: inputValue
35
+ value: disableValueParsing ? values.value : values.floatValue
36
36
  })
37
37
  }));
38
38
  }
39
39
  }));
40
40
  }
41
- export var NumberField = /*#__PURE__*/forwardRef((_ref2, ref) => {
41
+ function TextInputComponent(_ref2) {
42
42
  var {
43
- id,
44
- InputProps
43
+ value,
44
+ inputRef,
45
+ onChange,
46
+ valueIsNumericString = true,
47
+ thousandSeparator = true,
48
+ disableValueParsing
45
49
  } = _ref2,
46
50
  props = _objectWithoutProperties(_ref2, _excluded2);
51
+ return /*#__PURE__*/_jsx(NumericFormat, _objectSpread(_objectSpread({}, props), {}, {
52
+ value: value !== null && value !== void 0 ? value : '',
53
+ inputMode: "decimal",
54
+ getInputRef: inputRef,
55
+ valueIsNumericString: valueIsNumericString,
56
+ thousandSeparator: thousandSeparator,
57
+ allowedDecimalSeparators: ['.', ','],
58
+ onValueChange: (values, sourceInfo) => {
59
+ var {
60
+ event
61
+ } = sourceInfo;
62
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
63
+ onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread(_objectSpread({}, event), {}, {
64
+ target: _objectSpread(_objectSpread({}, event === null || event === void 0 ? void 0 : event.target), {}, {
65
+ value: values.value
66
+ })
67
+ }));
68
+ }
69
+ }));
70
+ }
71
+ export var NumberField = /*#__PURE__*/forwardRef((_ref3, ref) => {
72
+ var {
73
+ id,
74
+ InputProps,
75
+ isText = false
76
+ } = _ref3,
77
+ props = _objectWithoutProperties(_ref3, _excluded3);
47
78
  var uid = useUID(id);
48
79
  return /*#__PURE__*/_jsx(TextField, _objectSpread(_objectSpread({}, props), {}, {
49
80
  ref: ref,
50
81
  id: uid,
51
82
  InputProps: _objectSpread(_objectSpread({}, InputProps), {}, {
52
- inputComponent: NumberInputComponent
83
+ inputComponent: isText ? TextInputComponent : NumberInputComponent
53
84
  })
54
85
  }));
55
86
  });
@@ -253,6 +253,7 @@ interface NumberFormatCustomProps extends Omit<SafeNumberFormatProps, 'getInputR
253
253
  interface NumberFieldProps extends Omit<StandardTextFieldProps, 'InputProps' | 'inputProps'>, Omit<SafeNumberFormatProps, keyof StandardTextFieldProps> {
254
254
  InputProps?: Partial<Omit<InputProps, 'inputComponent'>>;
255
255
  inputProps?: NumberFormatCustomProps & StandardTextFieldProps['inputProps'];
256
+ isText?: boolean;
256
257
  }
257
258
  declare const NumberField: ForwardRefExoticComponent<NumberFieldProps>;
258
259
 
package/dist-web/index.js CHANGED
@@ -1704,7 +1704,8 @@ var Inline = /*#__PURE__*/forwardRef((_ref2, ref) => {
1704
1704
  if (process.env.NODE_ENV !== "production") Inline.displayName = "Inline";
1705
1705
 
1706
1706
  var _excluded$i = ["value", "inputRef", "onChange", "valueIsNumericString", "thousandSeparator", "disableValueParsing"],
1707
- _excluded2$3 = ["id", "InputProps"];
1707
+ _excluded2$3 = ["value", "inputRef", "onChange", "valueIsNumericString", "thousandSeparator", "disableValueParsing"],
1708
+ _excluded3 = ["id", "InputProps", "isText"];
1708
1709
  function NumberInputComponent(_ref) {
1709
1710
  var {
1710
1711
  value,
@@ -1723,31 +1724,61 @@ function NumberInputComponent(_ref) {
1723
1724
  thousandSeparator: thousandSeparator,
1724
1725
  allowedDecimalSeparators: ['.', ','],
1725
1726
  onValueChange: (values, sourceInfo) => {
1726
- var inputValue = values.value;
1727
1727
  var {
1728
1728
  event
1729
1729
  } = sourceInfo;
1730
1730
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1731
1731
  onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread(_objectSpread({}, event), {}, {
1732
1732
  target: _objectSpread(_objectSpread({}, event === null || event === void 0 ? void 0 : event.target), {}, {
1733
- value: inputValue
1733
+ value: disableValueParsing ? values.value : values.floatValue
1734
1734
  })
1735
1735
  }));
1736
1736
  }
1737
1737
  }));
1738
1738
  }
1739
- var NumberField = /*#__PURE__*/forwardRef((_ref2, ref) => {
1739
+ function TextInputComponent(_ref2) {
1740
1740
  var {
1741
- id,
1742
- InputProps
1741
+ value,
1742
+ inputRef,
1743
+ onChange,
1744
+ valueIsNumericString = true,
1745
+ thousandSeparator = true,
1746
+ disableValueParsing
1743
1747
  } = _ref2,
1744
1748
  props = _objectWithoutProperties(_ref2, _excluded2$3);
1749
+ return /*#__PURE__*/jsx(NumericFormat, _objectSpread(_objectSpread({}, props), {}, {
1750
+ value: value !== null && value !== void 0 ? value : '',
1751
+ inputMode: "decimal",
1752
+ getInputRef: inputRef,
1753
+ valueIsNumericString: valueIsNumericString,
1754
+ thousandSeparator: thousandSeparator,
1755
+ allowedDecimalSeparators: ['.', ','],
1756
+ onValueChange: (values, sourceInfo) => {
1757
+ var {
1758
+ event
1759
+ } = sourceInfo;
1760
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
1761
+ onChange === null || onChange === void 0 ? void 0 : onChange(_objectSpread(_objectSpread({}, event), {}, {
1762
+ target: _objectSpread(_objectSpread({}, event === null || event === void 0 ? void 0 : event.target), {}, {
1763
+ value: values.value
1764
+ })
1765
+ }));
1766
+ }
1767
+ }));
1768
+ }
1769
+ var NumberField = /*#__PURE__*/forwardRef((_ref3, ref) => {
1770
+ var {
1771
+ id,
1772
+ InputProps,
1773
+ isText = false
1774
+ } = _ref3,
1775
+ props = _objectWithoutProperties(_ref3, _excluded3);
1745
1776
  var uid = useUID(id);
1746
1777
  return /*#__PURE__*/jsx(TextField, _objectSpread(_objectSpread({}, props), {}, {
1747
1778
  ref: ref,
1748
1779
  id: uid,
1749
1780
  InputProps: _objectSpread(_objectSpread({}, InputProps), {}, {
1750
- inputComponent: NumberInputComponent
1781
+ inputComponent: isText ? TextInputComponent : NumberInputComponent
1751
1782
  })
1752
1783
  }));
1753
1784
  });