flipper-ui 0.31.4 → 0.31.5
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.
|
@@ -62,5 +62,5 @@ export declare const toLispCase: (name: string) => string;
|
|
|
62
62
|
export declare const HelperBox: (props: IHelperProps) => React.JSX.Element;
|
|
63
63
|
export declare const renderOptions: (options: TextFieldProps['options'], classes: Record<string, string>) => "" | React.JSX.Element[] | undefined;
|
|
64
64
|
export declare const EditBox: (props: IEditProps) => React.JSX.Element;
|
|
65
|
-
export declare const TextField: ({ options, margin, padding, style, error, variant, InputLabelProps, InputProps, SelectProps, autoComplete, onHelperClick, helperIcon, fullWidth, hasClear, onClear, characters, children, ...otherProps }: TextFieldProps) => React.JSX.Element;
|
|
65
|
+
export declare const TextField: ({ options, margin, padding, style, error, variant, InputLabelProps, InputProps, SelectProps, autoComplete, onHelperClick, helperIcon, fullWidth, hasClear, onClear, onChange, characters, children, ...otherProps }: TextFieldProps) => React.JSX.Element;
|
|
66
66
|
export default TextField;
|
|
@@ -26,7 +26,7 @@ var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
|
26
26
|
var _styles2 = require("./styles");
|
|
27
27
|
var _icons = require("../../../icons");
|
|
28
28
|
var _theme = require("../../../theme");
|
|
29
|
-
var _excluded = ["options", "margin", "padding", "style", "error", "variant", "InputLabelProps", "InputProps", "SelectProps", "autoComplete", "onHelperClick", "helperIcon", "fullWidth", "hasClear", "onClear", "characters", "children"];
|
|
29
|
+
var _excluded = ["options", "margin", "padding", "style", "error", "variant", "InputLabelProps", "InputProps", "SelectProps", "autoComplete", "onHelperClick", "helperIcon", "fullWidth", "hasClear", "onClear", "onChange", "characters", "children"];
|
|
30
30
|
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; }
|
|
31
31
|
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; }
|
|
32
32
|
var primary = _theme.theme.colors.primary;
|
|
@@ -143,6 +143,7 @@ var TextField = exports.TextField = function TextField(_ref) {
|
|
|
143
143
|
fullWidth = _ref.fullWidth,
|
|
144
144
|
hasClear = _ref.hasClear,
|
|
145
145
|
onClear = _ref.onClear,
|
|
146
|
+
onChange = _ref.onChange,
|
|
146
147
|
characters = _ref.characters,
|
|
147
148
|
children = _ref.children,
|
|
148
149
|
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
@@ -153,18 +154,30 @@ var TextField = exports.TextField = function TextField(_ref) {
|
|
|
153
154
|
marginLeft: '-20px'
|
|
154
155
|
}
|
|
155
156
|
});
|
|
157
|
+
var classes = useStyles();
|
|
158
|
+
var clearClass = clearStyle();
|
|
156
159
|
var hasValue = !!otherProps.value;
|
|
157
160
|
var endAdornment = hasValue && hasClear ? {
|
|
158
161
|
endAdornment: renderEndAdornment(onClear)
|
|
159
162
|
} : {};
|
|
160
|
-
var classes = useStyles();
|
|
161
|
-
var clearClass = clearStyle();
|
|
162
163
|
var handleClick = function handleClick() {
|
|
163
164
|
if (onHelperClick) {
|
|
164
165
|
onHelperClick();
|
|
165
166
|
}
|
|
166
167
|
};
|
|
167
168
|
var Wrapper = hasClear ? _styles2.StaticTextFieldWrapper : _styles2.TextFieldWrapper;
|
|
169
|
+
var emojiRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
170
|
+
var handleInputChange = function handleInputChange(event) {
|
|
171
|
+
if (onChange) {
|
|
172
|
+
var inputValue = event.target.value;
|
|
173
|
+
if (emojiRegex.test(inputValue)) {
|
|
174
|
+
var newValue = inputValue.replace(emojiRegex, '');
|
|
175
|
+
event.target.value = newValue;
|
|
176
|
+
return onChange(event);
|
|
177
|
+
}
|
|
178
|
+
return onChange(event);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
168
181
|
return /*#__PURE__*/_react["default"].createElement(Wrapper, null, /*#__PURE__*/_react["default"].createElement(_TextField["default"], (0, _extends2["default"])({
|
|
169
182
|
title: "",
|
|
170
183
|
select: !!(options !== null && options !== void 0 && options.length),
|
|
@@ -194,7 +207,8 @@ var TextField = exports.TextField = function TextField(_ref) {
|
|
|
194
207
|
iconOutlined: hasClear ? clearClass.iconOutlined : classes.iconOutlined
|
|
195
208
|
}
|
|
196
209
|
}, endAdornment), SelectProps),
|
|
197
|
-
characters: characters === null || characters === void 0 ? void 0 : characters.toString()
|
|
210
|
+
characters: characters === null || characters === void 0 ? void 0 : characters.toString(),
|
|
211
|
+
onChange: handleInputChange
|
|
198
212
|
}, otherProps), options ? renderOptions(options, classes) : children), characters && /*#__PURE__*/_react["default"].createElement(_styles2.CharactersCount, null, (_otherProps$value = otherProps.value) === null || _otherProps$value === void 0 ? void 0 : _otherProps$value.toString().length, "/", (_otherProps$inputProp = otherProps.inputProps) === null || _otherProps$inputProp === void 0 ? void 0 : _otherProps$inputProp.maxLength), onHelperClick && /*#__PURE__*/_react["default"].createElement(HelperBox, {
|
|
199
213
|
helperIcon: helperIcon,
|
|
200
214
|
onHelperClick: handleClick
|