@toptal/picasso-outlined-input 5.1.1 → 5.1.2-alpha-pf-fix-alpha-release-ea13b5aca.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.
- package/dist-package/src/OutlinedInput/OutlinedInput.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/OutlinedInput.js +38 -28
- package/dist-package/src/OutlinedInput/OutlinedInput.js.map +1 -1
- package/dist-package/src/OutlinedInput/stylesInput.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/stylesInput.js +3 -2
- package/dist-package/src/OutlinedInput/stylesInput.js.map +1 -1
- package/dist-package/src/OutlinedInput/types.d.ts +7 -5
- package/dist-package/src/OutlinedInput/types.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/utils.d.ts.map +1 -1
- package/dist-package/src/OutlinedInput/utils.js +5 -1
- package/dist-package/src/OutlinedInput/utils.js.map +1 -1
- package/package.json +12 -12
- package/src/OutlinedInput/OutlinedInput.tsx +109 -68
- package/src/OutlinedInput/stylesInput.ts +3 -2
- package/src/OutlinedInput/types.ts +16 -6
- package/src/OutlinedInput/utils.ts +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutlinedInput.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/OutlinedInput.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"OutlinedInput.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/OutlinedInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAKN,MAAM,OAAO,CAAA;AAed,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AA4CpC,QAAA,MAAM,aAAa,2EAkMjB,CAAA;AAIF,eAAe,aAAa,CAAA"}
|
|
@@ -9,14 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
12
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useRef, } from 'react';
|
|
13
13
|
import { InputAdornment, InputValidIconAdornment, } from '@toptal/picasso-input-adornment';
|
|
14
14
|
import { ButtonCircular } from '@toptal/picasso-button';
|
|
15
15
|
import { CloseMinor16 } from '@toptal/picasso-icons';
|
|
16
16
|
import { noop } from '@toptal/picasso-utils';
|
|
17
17
|
import { useFieldsLayoutContext } from '@toptal/picasso-form';
|
|
18
|
-
import
|
|
19
|
-
import { TextareaAutosize, } from '@mui/base/TextareaAutosize';
|
|
18
|
+
import TextareaAutosize from 'react-textarea-autosize';
|
|
20
19
|
import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge';
|
|
21
20
|
import { getRootClassName } from './stylesRoot';
|
|
22
21
|
import { getInputClassName } from './stylesInput';
|
|
@@ -28,16 +27,13 @@ const getResetButtonClassName = (visibility, hasValue) => {
|
|
|
28
27
|
return twJoin('invisible', hasValue && 'peer-focus:visible peer-active:visible group-hover:visible');
|
|
29
28
|
};
|
|
30
29
|
const ResetButton = ({ hasValue, visibility = 'hover', onClick, testIds, }) => (React.createElement(InputAdornment, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.resetButton, position: 'end', className: getResetButtonClassName(visibility, hasValue) },
|
|
31
|
-
React.createElement(ButtonCircular, { tabIndex: -1, icon: React.createElement(CloseMinor16, null), variant: 'flat', role: 'reset', onClick: onClick, onMouseDown:
|
|
32
|
-
const Textarea = forwardRef((_a, ref) => {
|
|
33
|
-
var {
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
-
ownerState } = _a, rest = __rest(_a, ["ownerState"]);
|
|
36
|
-
return React.createElement(TextareaAutosize, Object.assign({ ref: ref }, rest));
|
|
37
|
-
});
|
|
30
|
+
React.createElement(ButtonCircular, { tabIndex: -1, icon: React.createElement(CloseMinor16, null), variant: 'flat', role: 'reset', onClick: onClick, onMouseDown: event => event.preventDefault(), onFocus: event => event.stopPropagation() })));
|
|
38
31
|
const OutlinedInput = forwardRef(function OutlinedInput(_a, ref) {
|
|
39
32
|
var { width = 'auto', size = 'medium', onResetClick = noop, status = 'default', type = 'text' } = _a, props = __rest(_a, ["width", "size", "onResetClick", "status", "type"]);
|
|
40
|
-
const { className, style, multiline, multilineResizable, autoFocus, rows, rowsMax, inputComponent, inputProps, defaultValue, value, startAdornment, endAdornment: userDefinedEndAdornment, onChange, enableReset, resetVisibility, disabled, inputRef, testIds, highlight, classes
|
|
33
|
+
const { className, style, 'data-testid': dataTestId, multiline, multilineResizable, autoFocus, rows, rowsMax, inputComponent, inputProps, defaultValue, value, startAdornment, endAdornment: userDefinedEndAdornment, onChange, enableReset, resetVisibility, disabled, inputRef, testIds, highlight, classes, onClick,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
children: _children, 'aria-describedby': ariaDescribedby, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, autoComplete, id, name, onKeyDown, onKeyUp, onFocus, onBlur, placeholder, readOnly, required } = props, rootAttrs = __rest(props, ["className", "style", 'data-testid', "multiline", "multilineResizable", "autoFocus", "rows", "rowsMax", "inputComponent", "inputProps", "defaultValue", "value", "startAdornment", "endAdornment", "onChange", "enableReset", "resetVisibility", "disabled", "inputRef", "testIds", "highlight", "classes", "onClick", "children", 'aria-describedby', 'aria-label', 'aria-labelledby', "autoComplete", "id", "name", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required"]);
|
|
36
|
+
const rootElementAttrs = rootAttrs;
|
|
41
37
|
const { layout } = useFieldsLayoutContext();
|
|
42
38
|
const isDark = (inputProps === null || inputProps === void 0 ? void 0 : inputProps.variant) === 'dark';
|
|
43
39
|
const shouldShowReset = enableReset && !disabled;
|
|
@@ -47,9 +43,20 @@ const OutlinedInput = forwardRef(function OutlinedInput(_a, ref) {
|
|
|
47
43
|
!multiline && status === 'success' && (React.createElement(InputValidIconAdornment, { "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.validIcon })),
|
|
48
44
|
userDefinedEndAdornment)) : (userDefinedEndAdornment);
|
|
49
45
|
const divRef = useRef(null);
|
|
46
|
+
const controlRef = useRef(null);
|
|
50
47
|
useImperativeHandle(ref, () => divRef.current, []);
|
|
51
|
-
const
|
|
52
|
-
|
|
48
|
+
const setControlRef = useCallback((node) => {
|
|
49
|
+
controlRef.current = node;
|
|
50
|
+
if (typeof inputRef === 'function') {
|
|
51
|
+
inputRef(node);
|
|
52
|
+
}
|
|
53
|
+
else if (inputRef) {
|
|
54
|
+
const objectRef = inputRef;
|
|
55
|
+
objectRef.current = node;
|
|
56
|
+
}
|
|
57
|
+
}, [inputRef]);
|
|
58
|
+
const isError = status === 'error';
|
|
59
|
+
const isWarning = status === 'warning';
|
|
53
60
|
const inputClassName = getInputClassName({
|
|
54
61
|
size,
|
|
55
62
|
disabled,
|
|
@@ -73,22 +80,25 @@ const OutlinedInput = forwardRef(function OutlinedInput(_a, ref) {
|
|
|
73
80
|
isError,
|
|
74
81
|
isWarning,
|
|
75
82
|
});
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
const computedInputClassName = twMerge(inputClassName, classes === null || classes === void 0 ? void 0 : classes.input, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className);
|
|
84
|
+
const ControlComponent = multiline
|
|
85
|
+
? TextareaAutosize
|
|
86
|
+
: inputComponent !== null && inputComponent !== void 0 ? inputComponent : 'input';
|
|
87
|
+
const control = (React.createElement(ControlComponent, Object.assign({ "aria-describedby": ariaDescribedby, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, autoComplete: autoComplete, id: id, name: name, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, placeholder: placeholder, readOnly: readOnly, required: required }, inputProps, { ref: setControlRef, className: computedInputClassName, type: type, "aria-invalid": isError, disabled: disabled, autoFocus: autoFocus, defaultValue: defaultValue, value: value, onChange: onChange }, (multiline && {
|
|
88
|
+
minRows: getRows(rows),
|
|
89
|
+
maxRows: getRows(rowsMax),
|
|
90
|
+
}))));
|
|
91
|
+
const handleRootClick = (event) => {
|
|
92
|
+
if (controlRef.current && event.currentTarget === event.target) {
|
|
93
|
+
controlRef.current.focus();
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, style: style, error: isError, defaultValue: defaultValue, value: value, startAdornment: startAdornment, endAdornment: endAdornment, autoFocus: autoFocus, onChange: onChange, disabled: disabled }, multilineProps)));
|
|
95
|
+
const onDivClick = onClick;
|
|
96
|
+
onDivClick === null || onDivClick === void 0 ? void 0 : onDivClick(event);
|
|
97
|
+
};
|
|
98
|
+
return (React.createElement("div", Object.assign({}, rootElementAttrs, { ref: divRef, className: twMerge(rootClassName, classes === null || classes === void 0 ? void 0 : classes.root, className), style: style, "data-testid": dataTestId, onClick: handleRootClick }),
|
|
99
|
+
startAdornment,
|
|
100
|
+
control,
|
|
101
|
+
endAdornment));
|
|
92
102
|
});
|
|
93
103
|
OutlinedInput.displayName = 'OutlinedInput';
|
|
94
104
|
export default OutlinedInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutlinedInput.js","sourceRoot":"","sources":["../../../src/OutlinedInput/OutlinedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"OutlinedInput.js","sourceRoot":"","sources":["../../../src/OutlinedInput/OutlinedInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EACZ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,GACP,MAAM,OAAO,CAAA;AACd,OAAO,EACL,cAAc,EACd,uBAAuB,GACxB,MAAM,iCAAiC,CAA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AC;YAC/D,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAC5B,CAAC;QACD,MAAM,UAAU,GAAG,OAEN,CAAA;QAEb,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,KAAK,CAAC,CAAA;IACrB,CAAC,CAAA;IAED,OAAO,CACL,6CACM,gBAAgB,IACpB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,SAAS,CAAC,EAC3D,KAAK,EAAE,KAAK,iBACC,UAAU,EACvB,OAAO,EAAE,eAAe;QAEvB,cAAc;QACd,OAAO;QACP,YAAY,CACT,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA;AAE3C,eAAe,aAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesInput.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/stylesInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAI9C,CAAA;AAED,eAAO,MAAM,gBAAgB;;cAOtB,MAAM,EAAE;;;CAGd,CAAA;AAED,eAAO,MAAM,iBAAiB,oDAK3B;IACD,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,sBAeA,CAAA;AAED,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"stylesInput.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/stylesInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAI9C,CAAA;AAED,eAAO,MAAM,gBAAgB;;cAOtB,MAAM,EAAE;;;CAGd,CAAA;AAED,eAAO,MAAM,iBAAiB,oDAK3B;IACD,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,sBAeA,CAAA;AAED,eAAO,MAAM,kBAAkB;;;CAG9B,CAAA;AAED,eAAO,MAAM,YAAY,UAYxB,CAAA;AAED,eAAO,MAAM,iBAAiB,iFAQ3B,OAAO,CAAC,KAAK,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,8CAalD,CAAA"}
|
|
@@ -42,7 +42,6 @@ export const inputClasses = [
|
|
|
42
42
|
'p-0',
|
|
43
43
|
'peer',
|
|
44
44
|
'resize-none',
|
|
45
|
-
'resize-none',
|
|
46
45
|
'w-full',
|
|
47
46
|
];
|
|
48
47
|
export const getInputClassName = ({ size, disabled, isDark, multiline, multilineResizable, type, inputProps, }) => [
|
|
@@ -52,7 +51,9 @@ export const getInputClassName = ({ size, disabled, isDark, multiline, multiline
|
|
|
52
51
|
isDark,
|
|
53
52
|
disabled,
|
|
54
53
|
type,
|
|
55
|
-
|
|
54
|
+
// `inputProps` carries an index signature (`[k: string]: unknown`), so
|
|
55
|
+
// `disabled` reads as `unknown`; it is only used as a boolean flag below.
|
|
56
|
+
inputPropsDisabled: Boolean(inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled),
|
|
56
57
|
}),
|
|
57
58
|
isDark ? placeholderClasses.dark : placeholderClasses.default,
|
|
58
59
|
multiline && multilineResizable && 'resize-y',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesInput.js","sourceRoot":"","sources":["../../../src/OutlinedInput/stylesInput.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAyB;IACjD,KAAK,EAAE,oBAAoB;IAC3B,MAAM,EAAE,mBAAmB;IAC3B,KAAK,EAAE,mBAAmB;CAC3B,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE;QACR,eAAe;QACf,qFAAqF;QACrF,wEAAwE;QACxE,4CAA4C;KACjC;IACb,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,YAAY;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,kBAAkB,GAMnB,EAAE,EAAE;IACH,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,gBAAgB,CAAC,IAAI,CAAA;IAC9B,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,IAAI,kBAAkB,EAAE,CAAC;QAC1C,qCAAqC;QACrC,OAAO,gBAAgB,CAAC,UAAU,CAAA;IACpC,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,gBAAgB,CAAC,QAAQ,CAAA;IAClC,CAAC;IAED,OAAO,gBAAgB,CAAC,OAAO,CAAA;AACjC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,CAAC,gCAAgC,EAAE,8BAA8B,CAAC;IAC3E,IAAI,EAAE,CAAC,6BAA6B,EAAE,iCAAiC,CAAC;CACzE,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,gDAAgD;IAChD,gBAAgB;IAChB,aAAa;IACb,YAAY;IACZ,kBAAkB;IAClB,QAAQ;IACR,gBAAgB;IAChB,KAAK;IACL,MAAM;IACN,aAAa;IACb,
|
|
1
|
+
{"version":3,"file":"stylesInput.js","sourceRoot":"","sources":["../../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R,MAAM,EACN,SAAS,EACT,kBAAkB,EAClB,IAAI,EACJ,UAAU,GACuC,EAAE,EAAE,CAAC;IACtD,YAAY;IACZ,aAAa,CAAC,IAAI,CAAC;IACnB,iBAAiB,CAAC;QAChB,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,uEAAuE;QACvE,0EAA0E;QAC1E,kBAAkB,EAAE,OAAO,CAAC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,CAAC;KAClD,CAAC;IACF,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO;IAC7D,SAAS,IAAI,kBAAkB,IAAI,UAAU;CAC9C,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ChangeEventHandler,
|
|
2
|
-
import type { SizeType, BaseProps } from '@toptal/picasso-shared';
|
|
3
|
-
|
|
1
|
+
import type { ChangeEventHandler, ElementType, ReactNode, InputHTMLAttributes, HTMLAttributes, MouseEvent } from 'react';
|
|
2
|
+
import type { SizeType, BaseProps, StandardProps } from '@toptal/picasso-shared';
|
|
3
|
+
export interface InputBaseComponentProps extends HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> {
|
|
4
|
+
[arbitrary: string]: unknown;
|
|
5
|
+
}
|
|
4
6
|
export type WidthType = 'full' | 'shrink' | 'auto';
|
|
5
7
|
export type Size = SizeType<'small' | 'medium' | 'large'>;
|
|
6
8
|
export type ValueType = (string | number | boolean | object)[] | string | number | boolean | object;
|
|
@@ -12,7 +14,7 @@ export interface InputProps extends React.HTMLAttributes<HTMLInputElement>, Base
|
|
|
12
14
|
size?: number | 'small' | 'medium' | 'large';
|
|
13
15
|
multiple?: boolean | undefined;
|
|
14
16
|
}
|
|
15
|
-
export interface Props extends
|
|
17
|
+
export interface Props extends Omit<StandardProps, 'classes'>, Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'size' | 'color'> {
|
|
16
18
|
/** Classes for input and root */
|
|
17
19
|
classes?: {
|
|
18
20
|
input?: string;
|
|
@@ -20,7 +22,7 @@ export interface Props extends BaseProps, Omit<InputHTMLAttributes<HTMLInputElem
|
|
|
20
22
|
};
|
|
21
23
|
/** Width of the component */
|
|
22
24
|
width?: WidthType;
|
|
23
|
-
inputComponent?:
|
|
25
|
+
inputComponent?: ElementType<InputBaseComponentProps>;
|
|
24
26
|
inputProps?: BaseInputProps;
|
|
25
27
|
defaultValue?: ValueType;
|
|
26
28
|
value?: ValueType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,cAAc,EACd,UAAU,EACX,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAMhF,MAAM,WAAW,uBACf,SAAQ,cAAc,CAAC,gBAAgB,GAAG,mBAAmB,CAAC;IAG9D,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;CAC7B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA;AAElD,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAA;AAEzD,MAAM,MAAM,SAAS,GACjB,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GACtC,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,CAAA;AAEV,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,G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,SAAS,CAAA;IAC1B,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAC/C,qBAAqB;IACrB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,qNAAqN;IACrN,eAAe,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IACpC,qDAAqD;IACrD,YAAY,CAAC,EAAE,CACb,KAAK,EAAE,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,KACrD,IAAI,CAAA;IACT,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,SAAS,CAAC,EAAE,UAAU,CAAA;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,SAAU,MAAM,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/OutlinedInput/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,SAAU,MAAM,GAAG,MAAM,GAAG,SAAS,uBAKxD,CAAA"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export const getRows = (rows) =>
|
|
1
|
+
export const getRows = (rows) => {
|
|
2
|
+
// Number(undefined) is NaN; react-textarea-autosize needs undefined for "no constraint"
|
|
3
|
+
const parsed = Number(rows);
|
|
4
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
5
|
+
};
|
|
2
6
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/OutlinedInput/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAiC,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/OutlinedInput/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAiC,EAAE,EAAE;IAC3D,wFAAwF;IACxF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAE3B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;AAClD,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-outlined-input",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
4
4
|
"description": "Toptal UI components library - OutlinedInput",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,26 +18,26 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@mui/base": "5.0.0-beta.58",
|
|
22
21
|
"classnames": "^2.5.1",
|
|
23
|
-
"
|
|
24
|
-
"@toptal/picasso-
|
|
25
|
-
"@toptal/picasso-icons": "1.15.
|
|
26
|
-
"@toptal/picasso-
|
|
27
|
-
"@toptal/picasso-
|
|
28
|
-
"@toptal/picasso-form": "7.0.
|
|
22
|
+
"react-textarea-autosize": "^8.5.9",
|
|
23
|
+
"@toptal/picasso-button": "5.0.3-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
24
|
+
"@toptal/picasso-icons": "1.15.4-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
25
|
+
"@toptal/picasso-input-adornment": "4.0.2-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
26
|
+
"@toptal/picasso-shared": "16.0.1-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
27
|
+
"@toptal/picasso-form": "7.0.3-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
28
|
+
"@toptal/picasso-utils": "4.0.2-alpha-pf-fix-alpha-release-ea13b5aca.0"
|
|
29
29
|
},
|
|
30
30
|
"sideEffects": [
|
|
31
31
|
"**/styles.ts",
|
|
32
32
|
"**/styles.js"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@toptal/picasso-tailwind-merge": "
|
|
36
|
-
"@toptal/picasso-tailwind": "
|
|
37
|
-
"react": ">=16.12.0
|
|
35
|
+
"@toptal/picasso-tailwind-merge": "2.0.6-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
36
|
+
"@toptal/picasso-tailwind": "4.0.1-alpha-pf-fix-alpha-release-ea13b5aca.0",
|
|
37
|
+
"react": ">=16.12.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@toptal/picasso-tailwind-merge": "2.0.
|
|
40
|
+
"@toptal/picasso-tailwind-merge": "2.0.6-alpha-pf-fix-alpha-release-ea13b5aca.0"
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": "./dist-package/src/index.js",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { MouseEvent } from 'react'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useRef,
|
|
7
|
+
} from 'react'
|
|
3
8
|
import {
|
|
4
9
|
InputAdornment,
|
|
5
10
|
InputValidIconAdornment,
|
|
@@ -8,11 +13,7 @@ import { ButtonCircular } from '@toptal/picasso-button'
|
|
|
8
13
|
import { CloseMinor16 } from '@toptal/picasso-icons'
|
|
9
14
|
import { noop } from '@toptal/picasso-utils'
|
|
10
15
|
import { useFieldsLayoutContext } from '@toptal/picasso-form'
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
TextareaAutosize,
|
|
14
|
-
type TextareaAutosizeProps,
|
|
15
|
-
} from '@mui/base/TextareaAutosize'
|
|
16
|
+
import TextareaAutosize from 'react-textarea-autosize'
|
|
16
17
|
import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge'
|
|
17
18
|
|
|
18
19
|
import { getRootClassName } from './stylesRoot'
|
|
@@ -56,32 +57,12 @@ const ResetButton = ({
|
|
|
56
57
|
variant='flat'
|
|
57
58
|
role='reset'
|
|
58
59
|
onClick={onClick}
|
|
59
|
-
onMouseDown={(
|
|
60
|
-
|
|
61
|
-
) => event.preventDefault()}
|
|
62
|
-
onFocus={(
|
|
63
|
-
event: React.FocusEvent<HTMLButtonElement | HTMLAnchorElement>
|
|
64
|
-
) => event.stopPropagation()}
|
|
60
|
+
onMouseDown={event => event.preventDefault()}
|
|
61
|
+
onFocus={event => event.stopPropagation()}
|
|
65
62
|
/>
|
|
66
63
|
</InputAdornment>
|
|
67
64
|
)
|
|
68
65
|
|
|
69
|
-
const Textarea = forwardRef<
|
|
70
|
-
HTMLTextAreaElement,
|
|
71
|
-
{ ownerState: InputOwnerState } & TextareaAutosizeProps
|
|
72
|
-
>(
|
|
73
|
-
(
|
|
74
|
-
{
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
-
ownerState,
|
|
77
|
-
...rest
|
|
78
|
-
},
|
|
79
|
-
ref
|
|
80
|
-
) => {
|
|
81
|
-
return <TextareaAutosize ref={ref} {...rest} />
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
|
|
85
66
|
const OutlinedInput = forwardRef<HTMLElement, Props>(function OutlinedInput(
|
|
86
67
|
{
|
|
87
68
|
width = 'auto',
|
|
@@ -96,6 +77,7 @@ const OutlinedInput = forwardRef<HTMLElement, Props>(function OutlinedInput(
|
|
|
96
77
|
const {
|
|
97
78
|
className,
|
|
98
79
|
style,
|
|
80
|
+
'data-testid': dataTestId,
|
|
99
81
|
multiline,
|
|
100
82
|
multilineResizable,
|
|
101
83
|
autoFocus,
|
|
@@ -115,9 +97,27 @@ const OutlinedInput = forwardRef<HTMLElement, Props>(function OutlinedInput(
|
|
|
115
97
|
testIds,
|
|
116
98
|
highlight,
|
|
117
99
|
classes,
|
|
118
|
-
|
|
100
|
+
onClick,
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
|
+
children: _children,
|
|
103
|
+
'aria-describedby': ariaDescribedby,
|
|
104
|
+
'aria-label': ariaLabel,
|
|
105
|
+
'aria-labelledby': ariaLabelledby,
|
|
106
|
+
autoComplete,
|
|
107
|
+
id,
|
|
108
|
+
name,
|
|
109
|
+
onKeyDown,
|
|
110
|
+
onKeyUp,
|
|
111
|
+
onFocus,
|
|
112
|
+
onBlur,
|
|
113
|
+
placeholder,
|
|
114
|
+
readOnly,
|
|
115
|
+
required,
|
|
116
|
+
...rootAttrs
|
|
119
117
|
} = props
|
|
120
118
|
|
|
119
|
+
const rootElementAttrs = rootAttrs as React.HTMLAttributes<HTMLDivElement>
|
|
120
|
+
|
|
121
121
|
const { layout } = useFieldsLayoutContext()
|
|
122
122
|
const isDark = inputProps?.variant === 'dark'
|
|
123
123
|
const shouldShowReset = enableReset && !disabled
|
|
@@ -142,11 +142,28 @@ const OutlinedInput = forwardRef<HTMLElement, Props>(function OutlinedInput(
|
|
|
142
142
|
)
|
|
143
143
|
|
|
144
144
|
const divRef = useRef<HTMLDivElement | null>(null)
|
|
145
|
+
const controlRef = useRef<HTMLElement | null>(null)
|
|
145
146
|
|
|
146
147
|
useImperativeHandle(ref, () => divRef.current as HTMLElement, [])
|
|
147
148
|
|
|
148
|
-
const
|
|
149
|
-
|
|
149
|
+
const setControlRef = useCallback(
|
|
150
|
+
(node: HTMLElement | null) => {
|
|
151
|
+
controlRef.current = node
|
|
152
|
+
|
|
153
|
+
if (typeof inputRef === 'function') {
|
|
154
|
+
inputRef(node as HTMLInputElement)
|
|
155
|
+
} else if (inputRef) {
|
|
156
|
+
const objectRef =
|
|
157
|
+
inputRef as React.MutableRefObject<HTMLInputElement | null>
|
|
158
|
+
|
|
159
|
+
objectRef.current = node as HTMLInputElement
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
[inputRef]
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
const isError = status === 'error'
|
|
166
|
+
const isWarning = status === 'warning'
|
|
150
167
|
|
|
151
168
|
const inputClassName = getInputClassName({
|
|
152
169
|
size,
|
|
@@ -173,49 +190,73 @@ const OutlinedInput = forwardRef<HTMLElement, Props>(function OutlinedInput(
|
|
|
173
190
|
isWarning,
|
|
174
191
|
})
|
|
175
192
|
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
minRows: getRows(rows),
|
|
182
|
-
maxRows: getRows(rowsMax),
|
|
183
|
-
} as const)
|
|
184
|
-
: {}
|
|
193
|
+
const computedInputClassName = twMerge(
|
|
194
|
+
inputClassName,
|
|
195
|
+
classes?.input,
|
|
196
|
+
inputProps?.className
|
|
197
|
+
)
|
|
185
198
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
199
|
+
const ControlComponent: React.ElementType = multiline
|
|
200
|
+
? TextareaAutosize
|
|
201
|
+
: inputComponent ?? 'input'
|
|
202
|
+
|
|
203
|
+
const control = (
|
|
204
|
+
<ControlComponent
|
|
205
|
+
aria-describedby={ariaDescribedby}
|
|
206
|
+
aria-label={ariaLabel}
|
|
207
|
+
aria-labelledby={ariaLabelledby}
|
|
208
|
+
autoComplete={autoComplete}
|
|
209
|
+
id={id}
|
|
210
|
+
name={name}
|
|
211
|
+
onKeyDown={onKeyDown}
|
|
212
|
+
onKeyUp={onKeyUp}
|
|
213
|
+
onFocus={onFocus}
|
|
214
|
+
onBlur={onBlur}
|
|
215
|
+
placeholder={placeholder}
|
|
216
|
+
readOnly={readOnly}
|
|
217
|
+
required={required}
|
|
218
|
+
{...inputProps}
|
|
219
|
+
ref={setControlRef}
|
|
220
|
+
className={computedInputClassName}
|
|
221
|
+
type={type}
|
|
222
|
+
aria-invalid={isError}
|
|
223
|
+
disabled={disabled}
|
|
224
|
+
autoFocus={autoFocus}
|
|
209
225
|
defaultValue={defaultValue}
|
|
210
226
|
value={value}
|
|
211
|
-
startAdornment={startAdornment}
|
|
212
|
-
endAdornment={endAdornment}
|
|
213
|
-
autoFocus={autoFocus}
|
|
214
227
|
onChange={onChange}
|
|
215
|
-
|
|
216
|
-
|
|
228
|
+
{...(multiline && {
|
|
229
|
+
minRows: getRows(rows),
|
|
230
|
+
maxRows: getRows(rowsMax),
|
|
231
|
+
})}
|
|
217
232
|
/>
|
|
218
233
|
)
|
|
234
|
+
|
|
235
|
+
const handleRootClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
236
|
+
if (controlRef.current && event.currentTarget === event.target) {
|
|
237
|
+
controlRef.current.focus()
|
|
238
|
+
}
|
|
239
|
+
const onDivClick = onClick as
|
|
240
|
+
| React.MouseEventHandler<HTMLDivElement>
|
|
241
|
+
| undefined
|
|
242
|
+
|
|
243
|
+
onDivClick?.(event)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<div
|
|
248
|
+
{...rootElementAttrs}
|
|
249
|
+
ref={divRef}
|
|
250
|
+
className={twMerge(rootClassName, classes?.root, className)}
|
|
251
|
+
style={style}
|
|
252
|
+
data-testid={dataTestId}
|
|
253
|
+
onClick={handleRootClick}
|
|
254
|
+
>
|
|
255
|
+
{startAdornment}
|
|
256
|
+
{control}
|
|
257
|
+
{endAdornment}
|
|
258
|
+
</div>
|
|
259
|
+
)
|
|
219
260
|
})
|
|
220
261
|
|
|
221
262
|
OutlinedInput.displayName = 'OutlinedInput'
|
|
@@ -61,7 +61,6 @@ export const inputClasses = [
|
|
|
61
61
|
'p-0',
|
|
62
62
|
'peer',
|
|
63
63
|
'resize-none',
|
|
64
|
-
'resize-none',
|
|
65
64
|
'w-full',
|
|
66
65
|
]
|
|
67
66
|
|
|
@@ -80,7 +79,9 @@ export const getInputClassName = ({
|
|
|
80
79
|
isDark,
|
|
81
80
|
disabled,
|
|
82
81
|
type,
|
|
83
|
-
|
|
82
|
+
// `inputProps` carries an index signature (`[k: string]: unknown`), so
|
|
83
|
+
// `disabled` reads as `unknown`; it is only used as a boolean flag below.
|
|
84
|
+
inputPropsDisabled: Boolean(inputProps?.disabled),
|
|
84
85
|
}),
|
|
85
86
|
isDark ? placeholderClasses.dark : placeholderClasses.default,
|
|
86
87
|
multiline && multilineResizable && 'resize-y',
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ChangeEventHandler,
|
|
3
|
-
|
|
3
|
+
ElementType,
|
|
4
4
|
ReactNode,
|
|
5
5
|
InputHTMLAttributes,
|
|
6
|
+
HTMLAttributes,
|
|
6
7
|
MouseEvent,
|
|
7
8
|
} from 'react'
|
|
8
|
-
import type { SizeType, BaseProps } from '@toptal/picasso-shared'
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import type { SizeType, BaseProps, StandardProps } from '@toptal/picasso-shared'
|
|
10
|
+
|
|
11
|
+
// Mirrors @material-ui/core's `InputBaseComponentProps`: based on
|
|
12
|
+
// `HTMLAttributes` (NOT `InputHTMLAttributes`) so it does not strictly type
|
|
13
|
+
// `size` / `disabled` — consumers (e.g. Input) declare their own widened
|
|
14
|
+
// `size` union, which an `InputHTMLAttributes`-based shape would reject.
|
|
15
|
+
export interface InputBaseComponentProps
|
|
16
|
+
extends HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> {
|
|
17
|
+
// Accommodate arbitrary additional props forwarded to a custom `inputComponent`
|
|
18
|
+
// (e.g. NativeSelectInput's `IconComponent` / `multiple`).
|
|
19
|
+
[arbitrary: string]: unknown
|
|
20
|
+
}
|
|
11
21
|
|
|
12
22
|
export type WidthType = 'full' | 'shrink' | 'auto'
|
|
13
23
|
|
|
@@ -34,7 +44,7 @@ export interface InputProps
|
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
export interface Props
|
|
37
|
-
extends
|
|
47
|
+
extends Omit<StandardProps, 'classes'>,
|
|
38
48
|
Omit<
|
|
39
49
|
InputHTMLAttributes<HTMLInputElement>,
|
|
40
50
|
'value' | 'defaultValue' | 'size' | 'color'
|
|
@@ -43,7 +53,7 @@ export interface Props
|
|
|
43
53
|
classes?: { input?: string; root?: string }
|
|
44
54
|
/** Width of the component */
|
|
45
55
|
width?: WidthType
|
|
46
|
-
inputComponent?:
|
|
56
|
+
inputComponent?: ElementType<InputBaseComponentProps>
|
|
47
57
|
inputProps?: BaseInputProps
|
|
48
58
|
defaultValue?: ValueType
|
|
49
59
|
value?: ValueType
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export const getRows = (rows: number | string | undefined) =>
|
|
2
|
-
|
|
1
|
+
export const getRows = (rows: number | string | undefined) => {
|
|
2
|
+
// Number(undefined) is NaN; react-textarea-autosize needs undefined for "no constraint"
|
|
3
|
+
const parsed = Number(rows)
|
|
4
|
+
|
|
5
|
+
return Number.isNaN(parsed) ? undefined : parsed
|
|
6
|
+
}
|