flipper-ui 0.31.0 → 0.31.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChangeEvent, ClipboardEvent, KeyboardEvent, FocusEvent, ReactNode, MouseEvent, Ref, HTMLAttributes } from 'react';
|
|
3
3
|
import type { DefaultProps } from '../../types';
|
|
4
|
-
import type { TextFieldProps as MuiTextFieldProps } from '@material-ui/core';
|
|
4
|
+
import type { InputBaseComponentProps, TextFieldProps as MuiTextFieldProps } from '@material-ui/core';
|
|
5
5
|
export interface IOption {
|
|
6
6
|
label: string;
|
|
7
7
|
name?: string;
|
|
@@ -27,7 +27,7 @@ export interface TextFieldProps extends DefaultProps, Omit<MuiTextFieldProps, 'm
|
|
|
27
27
|
value?: string | number;
|
|
28
28
|
variant?: 'standard' | 'outlined' | 'filled';
|
|
29
29
|
inputRef?: Ref<HTMLInputElement>;
|
|
30
|
-
inputProps?:
|
|
30
|
+
inputProps?: InputBaseComponentProps;
|
|
31
31
|
InputProps?: object;
|
|
32
32
|
InputLabelProps?: object;
|
|
33
33
|
SelectProps?: object;
|
|
@@ -37,6 +37,7 @@ export interface TextFieldProps extends DefaultProps, Omit<MuiTextFieldProps, 'm
|
|
|
37
37
|
helperIcon?: ReactNode;
|
|
38
38
|
showEdit?: boolean;
|
|
39
39
|
hasClear?: boolean;
|
|
40
|
+
characters?: boolean;
|
|
40
41
|
onClear?: () => void;
|
|
41
42
|
onHelperClick?: () => void;
|
|
42
43
|
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -63,5 +64,5 @@ export declare const toLispCase: (name: string) => string;
|
|
|
63
64
|
export declare const HelperBox: (props: IHelperProps) => React.JSX.Element;
|
|
64
65
|
export declare const renderOptions: (options: TextFieldProps['options'], classes: Record<string, string>) => "" | React.JSX.Element[] | undefined;
|
|
65
66
|
export declare const EditBox: (props: IEditProps) => React.JSX.Element;
|
|
66
|
-
export declare const TextField: ({ options, margin, padding, style, error, variant, InputLabelProps, InputProps, SelectProps, autoComplete, onHelperClick, helperIcon, fullWidth, hasClear, onClear, children, ...otherProps }: TextFieldProps) => React.JSX.Element;
|
|
67
|
+
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;
|
|
67
68
|
export default TextField;
|
|
@@ -27,15 +27,18 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
27
27
|
var _icons = require("../../../icons");
|
|
28
28
|
var _iconButton = require("../icon-button");
|
|
29
29
|
var _theme = require("../../../theme");
|
|
30
|
-
var _excluded = ["options", "margin", "padding", "style", "error", "variant", "InputLabelProps", "InputProps", "SelectProps", "autoComplete", "onHelperClick", "helperIcon", "fullWidth", "hasClear", "onClear", "children"];
|
|
31
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
30
|
+
var _excluded = ["options", "margin", "padding", "style", "error", "variant", "InputLabelProps", "InputProps", "SelectProps", "autoComplete", "onHelperClick", "helperIcon", "fullWidth", "hasClear", "onClear", "characters", "children"];
|
|
31
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
32
32
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
33
33
|
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; }
|
|
34
34
|
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; }
|
|
35
|
-
var
|
|
35
|
+
var _theme$colors = _theme.theme.colors,
|
|
36
|
+
grays = _theme$colors.grays,
|
|
37
|
+
primary = _theme$colors.primary;
|
|
36
38
|
var Helper = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: 42px;\n height: 38px;\n"])));
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
+
var CharactersCount = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: -35px;\n color: ", ";\n font-size: 14px;\n font-family:\n Roboto,\n Helvetica,\n Arial,\n sans- serif;\n"])), grays.g3);
|
|
40
|
+
var TextFieldWrapper = exports.TextFieldWrapper = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: rows;\n width: 100%;\n align-items: center;\n button {\n display: none;\n }\n :hover button {\n display: flex;\n }\n"])));
|
|
41
|
+
var StaticTextFieldWrapper = exports.StaticTextFieldWrapper = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: rows;\n width: 100%;\n align-items: center;\n"])));
|
|
39
42
|
var useStyles = exports.useStyles = (0, _styles.makeStyles)({
|
|
40
43
|
listOptions: {
|
|
41
44
|
outline: 'none',
|
|
@@ -129,6 +132,7 @@ var renderEndAdornment = function renderEndAdornment(onClear) {
|
|
|
129
132
|
})));
|
|
130
133
|
};
|
|
131
134
|
var TextField = exports.TextField = function TextField(_ref) {
|
|
135
|
+
var _otherProps$value, _otherProps$inputProp;
|
|
132
136
|
var options = _ref.options,
|
|
133
137
|
margin = _ref.margin,
|
|
134
138
|
padding = _ref.padding,
|
|
@@ -150,6 +154,7 @@ var TextField = exports.TextField = function TextField(_ref) {
|
|
|
150
154
|
fullWidth = _ref.fullWidth,
|
|
151
155
|
hasClear = _ref.hasClear,
|
|
152
156
|
onClear = _ref.onClear,
|
|
157
|
+
characters = _ref.characters,
|
|
153
158
|
children = _ref.children,
|
|
154
159
|
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
155
160
|
var clearStyle = (0, _styles.makeStyles)({
|
|
@@ -199,8 +204,9 @@ var TextField = exports.TextField = function TextField(_ref) {
|
|
|
199
204
|
classes: {
|
|
200
205
|
iconOutlined: hasClear ? clearClass.iconOutlined : classes.iconOutlined
|
|
201
206
|
}
|
|
202
|
-
}, endAdornment), SelectProps)
|
|
203
|
-
|
|
207
|
+
}, endAdornment), SelectProps),
|
|
208
|
+
characters: characters === null || characters === void 0 ? void 0 : characters.toString()
|
|
209
|
+
}, otherProps), options ? renderOptions(options, classes) : children), characters && /*#__PURE__*/_react["default"].createElement(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, {
|
|
204
210
|
helperIcon: helperIcon,
|
|
205
211
|
onHelperClick: handleClick
|
|
206
212
|
}));
|
|
@@ -7,3 +7,4 @@ export declare const withHelperButton: any;
|
|
|
7
7
|
export declare const withSelect: () => React.JSX.Element;
|
|
8
8
|
export declare const useWithSelectAndClear: () => React.JSX.Element;
|
|
9
9
|
export declare const combobox: () => React.JSX.Element;
|
|
10
|
+
export declare const withCharacterCount: () => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flipper-ui",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"homepage": "https://flipper-ui.ngi.com.br/",
|
|
7
|
-
"author": "NG
|
|
7
|
+
"author": "NG",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -3,6 +3,7 @@ import type { TextFieldProps } from '@/core/inputs/text-field';
|
|
|
3
3
|
interface IProps {
|
|
4
4
|
initialOption?: string;
|
|
5
5
|
inputProps?: TextFieldProps;
|
|
6
|
+
characters?: boolean;
|
|
6
7
|
}
|
|
7
|
-
declare const Default: ({ inputProps, initialOption }: IProps) => React.JSX.Element;
|
|
8
|
+
declare const Default: ({ inputProps, initialOption, characters }: IProps) => React.JSX.Element;
|
|
8
9
|
export default Default;
|
|
@@ -30,8 +30,10 @@ var LIST = [{
|
|
|
30
30
|
value: 'fable'
|
|
31
31
|
}];
|
|
32
32
|
var Default = function Default(_ref) {
|
|
33
|
+
var _inputProps$inputProp;
|
|
33
34
|
var inputProps = _ref.inputProps,
|
|
34
|
-
initialOption = _ref.initialOption
|
|
35
|
+
initialOption = _ref.initialOption,
|
|
36
|
+
characters = _ref.characters;
|
|
35
37
|
var _React$useState = React.useState(initialOption ? initialOption : ''),
|
|
36
38
|
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
37
39
|
value = _React$useState2[0],
|
|
@@ -42,8 +44,9 @@ var Default = function Default(_ref) {
|
|
|
42
44
|
var handleClear = function handleClear() {
|
|
43
45
|
setValue('');
|
|
44
46
|
};
|
|
45
|
-
return /*#__PURE__*/React.createElement(_textField.TextField, (0, _extends2["default"])({
|
|
47
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_textField.TextField, (0, _extends2["default"])({
|
|
46
48
|
value: value,
|
|
49
|
+
characters: characters,
|
|
47
50
|
onChange: handleChange,
|
|
48
51
|
onClear: handleClear
|
|
49
52
|
}, inputProps), inputProps !== null && inputProps !== void 0 && inputProps.select ? LIST.map(function (_ref2) {
|
|
@@ -53,6 +56,8 @@ var Default = function Default(_ref) {
|
|
|
53
56
|
key: value,
|
|
54
57
|
value: value
|
|
55
58
|
}, label);
|
|
56
|
-
}) : undefined)
|
|
59
|
+
}) : undefined), characters && /*#__PURE__*/React.createElement("span", {
|
|
60
|
+
"data-testid": "characters-counter"
|
|
61
|
+
}, value.toString().length, "/", inputProps === null || inputProps === void 0 || (_inputProps$inputProp = inputProps.inputProps) === null || _inputProps$inputProp === void 0 ? void 0 : _inputProps$inputProp.maxLength));
|
|
57
62
|
};
|
|
58
63
|
var _default = exports["default"] = Default;
|