flipper-ui 0.40.0 → 0.40.1
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,6 +13,7 @@ export interface MaskFieldProps extends Omit<ITextFieldProps, 'size'> {
|
|
|
13
13
|
fixedDecimalScale?: boolean;
|
|
14
14
|
customInput?: ComponentType<ITextFieldProps>;
|
|
15
15
|
hasFormat?: boolean;
|
|
16
|
+
allowAlphanumeric?: boolean;
|
|
16
17
|
onValueChange?: (values: NumberFormatValues, sourceInfo: SourceInfo) => void;
|
|
17
18
|
}
|
|
18
19
|
export interface IValues {
|
|
@@ -11,18 +11,50 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _reactNumberFormat = require("react-number-format");
|
|
13
13
|
var _textField = _interopRequireDefault(require("../text-field"));
|
|
14
|
-
var _excluded = ["customInput", "hasFormat", "format", "style"];
|
|
14
|
+
var _excluded = ["customInput", "hasFormat", "allowAlphanumeric", "format", "style"];
|
|
15
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
17
|
var MaskField = function MaskField(props) {
|
|
18
18
|
var customInput = props.customInput,
|
|
19
19
|
hasFormat = props.hasFormat,
|
|
20
|
+
allowAlphanumeric = props.allowAlphanumeric,
|
|
20
21
|
_props$format = props.format,
|
|
21
|
-
|
|
22
|
+
_format = _props$format === void 0 ? '######' : _props$format,
|
|
22
23
|
style = props.style,
|
|
23
24
|
otherProps = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
25
|
+
if (hasFormat && allowAlphanumeric) {
|
|
26
|
+
return /*#__PURE__*/_react["default"].createElement(_reactNumberFormat.NumberFormatBase, (0, _extends2["default"])({}, otherProps, {
|
|
27
|
+
style: _objectSpread({}, style),
|
|
28
|
+
customInput: customInput || _textField["default"],
|
|
29
|
+
isValidInputCharacter: function isValidInputCharacter(_char) {
|
|
30
|
+
return /[0-9A-Za-z]/.test(_char);
|
|
31
|
+
},
|
|
32
|
+
isCharacterSame: function isCharacterSame(_ref) {
|
|
33
|
+
var currentValue = _ref.currentValue,
|
|
34
|
+
formattedValue = _ref.formattedValue,
|
|
35
|
+
currentValueIndex = _ref.currentValueIndex,
|
|
36
|
+
formattedValueIndex = _ref.formattedValueIndex;
|
|
37
|
+
return currentValue[currentValueIndex].toUpperCase() === formattedValue[formattedValueIndex].toUpperCase();
|
|
38
|
+
},
|
|
39
|
+
format: function format(value) {
|
|
40
|
+
return (0, _reactNumberFormat.patternFormatter)(value.toUpperCase(), {
|
|
41
|
+
format: _format,
|
|
42
|
+
patternChar: '#'
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
removeFormatting: function removeFormatting(value) {
|
|
46
|
+
return value.replace(/[^0-9A-Za-z]/g, '').toUpperCase();
|
|
47
|
+
},
|
|
48
|
+
getCaretBoundary: function getCaretBoundary(value) {
|
|
49
|
+
return (0, _reactNumberFormat.getPatternCaretBoundary)(value, {
|
|
50
|
+
format: _format,
|
|
51
|
+
patternChar: '#'
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
24
56
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, hasFormat ? /*#__PURE__*/_react["default"].createElement(_reactNumberFormat.PatternFormat, (0, _extends2["default"])({}, otherProps, {
|
|
25
|
-
format:
|
|
57
|
+
format: _format,
|
|
26
58
|
style: _objectSpread({}, style),
|
|
27
59
|
customInput: customInput || _textField["default"]
|
|
28
60
|
})) : /*#__PURE__*/_react["default"].createElement(_reactNumberFormat.NumericFormat, (0, _extends2["default"])({}, otherProps, {
|