@lunit/oui 2.2.14 → 2.2.15
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.
|
@@ -23,6 +23,7 @@ interface NormalTextInputProps extends InputWithHelperMsgProps {
|
|
|
23
23
|
interface FileInputProps extends NormalTextInputProps {
|
|
24
24
|
type: 'file';
|
|
25
25
|
accept: string;
|
|
26
|
+
onClick: () => void;
|
|
26
27
|
}
|
|
27
28
|
interface PasswordTextInputProps extends PasswordInputWithHelperMsgProps {
|
|
28
29
|
}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
3
|
import { InputMsg, BaseTextFieldContainer, BaseTextFieldBox, } from '../../BaseTextField/BaseTextField.styled';
|
|
4
4
|
import { BaseTextInput, LeftIconContainer, RightIconContainer } from '../TextInput.styled';
|
|
5
5
|
import { FileInputWrapperButton } from './Buttons';
|
|
6
6
|
import { Project } from '../../../icons';
|
|
7
7
|
import { uniqueId } from 'lodash';
|
|
8
8
|
const FileInput = forwardRef((props, ref) => {
|
|
9
|
-
const { error, helperMsg, leftIcon, rightIcon,
|
|
9
|
+
const { error, helperMsg, leftIcon, rightIcon, inputSX, type: inputType, value, onChange, onClick, ...inputProps } = props;
|
|
10
10
|
// Unique ID used to select hidden file input and click on it
|
|
11
11
|
const uID = uniqueId('hidden-file-input-');
|
|
12
|
-
const [fileName, setFileName] = useState('');
|
|
13
12
|
const baseSX = inputSX ?? {
|
|
14
13
|
paddingRight: '44px',
|
|
15
14
|
pointerEvents: 'none',
|
|
16
15
|
width: '100%',
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
const fileInput = document.getElementsByName(uID);
|
|
20
|
-
if (!fileInput.length)
|
|
21
|
-
return;
|
|
22
|
-
fileInput[0].click();
|
|
23
|
-
};
|
|
24
|
-
return (_jsxs(BaseTextFieldBox, { ...props.OuterBoxProps, width: props.width, children: [_jsxs(BaseTextFieldContainer, { ...props.InputContainerProps, width: props.width, children: [leftIcon && (_jsx(LeftIconContainer, { sx: inputProps.disabled ? { opacity: '0.8' } : undefined, children: leftIcon })), _jsx("input", { ref: ref, type: "file", name: uID, accept: props.accept, style: { display: 'none' }, disabled: inputProps.disabled, onChange: (e) => {
|
|
25
|
-
setFileName(e.target.value.split('\\').pop());
|
|
26
|
-
} }), _jsxs(FileInputWrapperButton, { onClick: () => handleButtonClicksFile(), width: props.width, children: [_jsx(BaseTextInput, { ...inputProps, type: "text", error: !!error, value: fileName,
|
|
17
|
+
return (_jsxs(BaseTextFieldBox, { ...props.OuterBoxProps, width: props.width, children: [_jsxs(BaseTextFieldContainer, { ...props.InputContainerProps, width: props.width, children: [leftIcon && (_jsx(LeftIconContainer, { sx: inputProps.disabled ? { opacity: '0.8' } : undefined, children: leftIcon })), _jsx("input", { ref: ref, type: "file", name: uID, accept: props.accept, style: { display: 'none' }, disabled: inputProps.disabled, onChange: onChange }), _jsxs(FileInputWrapperButton, { onClick: onClick, width: props.width, children: [_jsx(BaseTextInput, { ...inputProps, type: "text", error: !!error, value: value,
|
|
27
18
|
// @Tobio89: this dummy onchange clears an error without triggering unwanted style changes
|
|
28
|
-
onChange: () => { }, leftIcon: leftIcon, sx:
|
|
19
|
+
onChange: () => { }, leftIcon: leftIcon, sx: {
|
|
20
|
+
...baseSX,
|
|
21
|
+
cursor: 'pointer',
|
|
22
|
+
} }), _jsx(RightIconContainer, { sx: { pointerEvents: 'none' }, children: _jsx(Project, {}) })] })] }), error ? (_jsx(InputMsg, { variant: "body5", error: true, children: error })) : (helperMsg && _jsx(InputMsg, { variant: "body5", children: helperMsg }))] }));
|
|
29
23
|
});
|
|
30
24
|
export default FileInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunit/oui",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.15",
|
|
4
4
|
"validate-branch-name": {
|
|
5
5
|
"pattern": "^(main|develop)|(feature|fix|release|hotfix|qe)/.+$",
|
|
6
6
|
"errorMsg": "The branch name is not correct. Please check the pattern. (ex. feature/add-something)"
|