@bigbinary/neetoui 5.1.6 → 5.1.7

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/index.d.ts CHANGED
@@ -287,6 +287,7 @@ export interface InputProps
287
287
  labelProps?: LabelProps;
288
288
  maxLength?: number;
289
289
  unlimitedChars: boolean;
290
+ rejectCharsRegex?: RegExp;
290
291
  }
291
292
 
292
293
  export type LabelProps = {
package/index.js CHANGED
@@ -2085,6 +2085,37 @@ _curry2(function omit(names, obj) {
2085
2085
  return result;
2086
2086
  });
2087
2087
 
2088
+ /**
2089
+ * Replace a substring or regex match in a string with a replacement.
2090
+ *
2091
+ * The first two parameters correspond to the parameters of the
2092
+ * `String.prototype.replace()` function, so the second parameter can also be a
2093
+ * function.
2094
+ *
2095
+ * @func
2096
+ * @memberOf R
2097
+ * @since v0.7.0
2098
+ * @category String
2099
+ * @sig RegExp|String -> String -> String -> String
2100
+ * @param {RegExp|String} pattern A regular expression or a substring to match.
2101
+ * @param {String} replacement The string to replace the matches with.
2102
+ * @param {String} str The String to do the search and replacement in.
2103
+ * @return {String} The result.
2104
+ * @example
2105
+ *
2106
+ * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
2107
+ * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
2108
+ *
2109
+ * // Use the "g" (global) flag to replace all occurrences:
2110
+ * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
2111
+ */
2112
+
2113
+ var replace$2 =
2114
+ /*#__PURE__*/
2115
+ _curry3(function replace(regex, replacement, str) {
2116
+ return str.replace(regex, replacement);
2117
+ });
2118
+
2088
2119
  /**
2089
2120
  * Converts an object into an array of key, value arrays. Only the object's
2090
2121
  * own properties are used.
@@ -20298,7 +20329,7 @@ var DatePicker = /*#__PURE__*/forwardRef$1(function (_ref2, ref) {
20298
20329
  });
20299
20330
  DatePicker.displayName = "DatePicker";
20300
20331
 
20301
- var _excluded$p = ["size", "type", "label", "error", "suffix", "prefix", "disabled", "helpText", "className", "nakedInput", "contentSize", "required", "maxLength", "unlimitedChars", "labelProps"];
20332
+ var _excluded$p = ["size", "type", "label", "error", "suffix", "prefix", "disabled", "helpText", "className", "nakedInput", "contentSize", "required", "maxLength", "unlimitedChars", "labelProps", "rejectCharsRegex"];
20302
20333
  var SIZES$5 = {
20303
20334
  small: "small",
20304
20335
  medium: "medium",
@@ -20334,6 +20365,7 @@ var Input$1 = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
20334
20365
  _ref$unlimitedChars = _ref.unlimitedChars,
20335
20366
  unlimitedChars = _ref$unlimitedChars === void 0 ? false : _ref$unlimitedChars,
20336
20367
  labelProps = _ref.labelProps,
20368
+ rejectCharsRegex = _ref.rejectCharsRegex,
20337
20369
  otherProps = _objectWithoutProperties$1(_ref, _excluded$p);
20338
20370
  var _useState = useState(otherProps.value),
20339
20371
  _useState2 = _slicedToArray$2(_useState, 2),
@@ -20351,6 +20383,12 @@ var Input$1 = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
20351
20383
  };
20352
20384
  var onChange = otherProps.onChange || onChangeInternal;
20353
20385
  var isMaxLengthPresent = !!maxLength || maxLength === 0;
20386
+ var handleRegexChange = function handleRegexChange(e) {
20387
+ var globalRegex = new RegExp(rejectCharsRegex, "g");
20388
+ e.target.value = replace$2(globalRegex, "", e.target.value);
20389
+ onChange(e);
20390
+ };
20391
+ var handleChange = rejectCharsRegex ? handleRegexChange : onChange;
20354
20392
  return /*#__PURE__*/React__default.createElement("div", {
20355
20393
  className: classnames$1(["neeto-ui-input__wrapper", className])
20356
20394
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -20389,7 +20427,7 @@ var Input$1 = /*#__PURE__*/forwardRef$1(function (_ref, ref) {
20389
20427
  maxLength: maxLength
20390
20428
  }, otherProps, {
20391
20429
  value: value,
20392
- onChange: onChange
20430
+ onChange: handleChange
20393
20431
  })), suffix && /*#__PURE__*/React__default.createElement("div", {
20394
20432
  className: "neeto-ui-input__suffix"
20395
20433
  }, suffix)), !!error && /*#__PURE__*/React__default.createElement(Typography, {