@superdispatch/ui 0.26.1 → 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';
@@ -37,18 +38,49 @@ function NumberInputComponent(_ref) {
37
38
  }
38
39
  }));
39
40
  }
40
- export var NumberField = /*#__PURE__*/forwardRef((_ref2, ref) => {
41
+ function TextInputComponent(_ref2) {
41
42
  var {
42
- id,
43
- InputProps
43
+ value,
44
+ inputRef,
45
+ onChange,
46
+ valueIsNumericString = true,
47
+ thousandSeparator = true,
48
+ disableValueParsing
44
49
  } = _ref2,
45
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);
46
78
  var uid = useUID(id);
47
79
  return /*#__PURE__*/_jsx(TextField, _objectSpread(_objectSpread({}, props), {}, {
48
80
  ref: ref,
49
81
  id: uid,
50
82
  InputProps: _objectSpread(_objectSpread({}, InputProps), {}, {
51
- inputComponent: NumberInputComponent
83
+ inputComponent: isText ? TextInputComponent : NumberInputComponent
52
84
  })
53
85
  }));
54
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,
@@ -1735,18 +1736,49 @@ function NumberInputComponent(_ref) {
1735
1736
  }
1736
1737
  }));
1737
1738
  }
1738
- var NumberField = /*#__PURE__*/forwardRef((_ref2, ref) => {
1739
+ function TextInputComponent(_ref2) {
1739
1740
  var {
1740
- id,
1741
- InputProps
1741
+ value,
1742
+ inputRef,
1743
+ onChange,
1744
+ valueIsNumericString = true,
1745
+ thousandSeparator = true,
1746
+ disableValueParsing
1742
1747
  } = _ref2,
1743
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);
1744
1776
  var uid = useUID(id);
1745
1777
  return /*#__PURE__*/jsx(TextField, _objectSpread(_objectSpread({}, props), {}, {
1746
1778
  ref: ref,
1747
1779
  id: uid,
1748
1780
  InputProps: _objectSpread(_objectSpread({}, InputProps), {}, {
1749
- inputComponent: NumberInputComponent
1781
+ inputComponent: isText ? TextInputComponent : NumberInputComponent
1750
1782
  })
1751
1783
  }));
1752
1784
  });