@lunit/oui 2.2.16 → 2.2.17
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.
|
@@ -3,9 +3,10 @@ import { Theme } from '@mui/material';
|
|
|
3
3
|
import { InputMsg } from '../BaseTextField/BaseTextField.styled';
|
|
4
4
|
import type { RootTextInputProps } from './TextInput.types';
|
|
5
5
|
declare const BaseTextInput: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & RootTextInputProps, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
|
|
6
|
+
declare const FileInputLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & RootTextInputProps, import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {}>;
|
|
6
7
|
declare const LeftIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
7
8
|
declare const RightIconContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme> & {
|
|
8
9
|
error?: string | undefined;
|
|
9
10
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
10
11
|
declare const ButtonWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<Theme>, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
11
|
-
export { BaseTextInput, InputMsg, LeftIconContainer, RightIconContainer, ButtonWrapper };
|
|
12
|
+
export { BaseTextInput, FileInputLabel, InputMsg, LeftIconContainer, RightIconContainer, ButtonWrapper, };
|
|
@@ -51,6 +51,59 @@ const BaseTextInput = styled('input', {
|
|
|
51
51
|
}
|
|
52
52
|
return resultStyle;
|
|
53
53
|
});
|
|
54
|
+
const FileInputLabel = styled('label', {
|
|
55
|
+
shouldForwardProp: (prop) => ![
|
|
56
|
+
'error',
|
|
57
|
+
'large',
|
|
58
|
+
'showClear',
|
|
59
|
+
'leftIcon',
|
|
60
|
+
'width',
|
|
61
|
+
'OuterBoxProps',
|
|
62
|
+
'InputContainerProps',
|
|
63
|
+
'sx',
|
|
64
|
+
].includes(prop.toString()),
|
|
65
|
+
})(({ theme, large, error, leftIcon, width, disabled, readOnly }) => {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
let resultStyle = {
|
|
68
|
+
...baseTextInputStyle(theme),
|
|
69
|
+
width:
|
|
70
|
+
// eslint-disable-next-line no-nested-ternary
|
|
71
|
+
typeof width !== 'undefined' ? (typeof width === 'number' ? `${width}px` : width) : width,
|
|
72
|
+
};
|
|
73
|
+
if (error) {
|
|
74
|
+
resultStyle = {
|
|
75
|
+
...resultStyle,
|
|
76
|
+
...styles.baseTextFieldErrorStyle(theme),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (large) {
|
|
80
|
+
resultStyle = {
|
|
81
|
+
...resultStyle,
|
|
82
|
+
...textInputLarge,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (leftIcon) {
|
|
86
|
+
resultStyle = {
|
|
87
|
+
...resultStyle,
|
|
88
|
+
...textInputWithLeftIcon,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (disabled || readOnly) {
|
|
92
|
+
resultStyle = {
|
|
93
|
+
...resultStyle,
|
|
94
|
+
opacity: '0.8',
|
|
95
|
+
border: `1px solid ${theme.palette.neutralGrey[70]}`,
|
|
96
|
+
borderColor: 'unset',
|
|
97
|
+
backgroundColor: 'transparent',
|
|
98
|
+
color: theme.palette.neutralGrey[45],
|
|
99
|
+
pointerEvents: 'none',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
...resultStyle,
|
|
104
|
+
'&:read-only': undefined,
|
|
105
|
+
};
|
|
106
|
+
});
|
|
54
107
|
const LeftIconContainer = styled('div')(() => {
|
|
55
108
|
return {
|
|
56
109
|
position: 'absolute',
|
|
@@ -100,4 +153,4 @@ const ButtonWrapper = styled('button')(({ theme }) => {
|
|
|
100
153
|
},
|
|
101
154
|
};
|
|
102
155
|
});
|
|
103
|
-
export { BaseTextInput, InputMsg, LeftIconContainer, RightIconContainer, ButtonWrapper };
|
|
156
|
+
export { BaseTextInput, FileInputLabel, InputMsg, LeftIconContainer, RightIconContainer, ButtonWrapper, };
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { InputMsg, BaseTextFieldContainer, BaseTextFieldBox, } from '../../BaseTextField/BaseTextField.styled';
|
|
4
|
-
import { BaseTextInput, LeftIconContainer, RightIconContainer } from '../TextInput.styled';
|
|
5
|
-
import { FileInputWrapperButton } from './Buttons';
|
|
6
|
-
import { Project } from '../../../icons';
|
|
2
|
+
import { forwardRef, useState } from 'react';
|
|
7
3
|
import { uniqueId } from 'lodash';
|
|
4
|
+
import { Box, Typography } from '@mui/material';
|
|
5
|
+
import { Project } from '../../../icons';
|
|
6
|
+
import theme from '../../../theme';
|
|
7
|
+
import { InputMsg, BaseTextFieldContainer, BaseTextFieldBox, } from '../../BaseTextField/BaseTextField.styled';
|
|
8
|
+
import { FileInputLabel, LeftIconContainer, RightIconContainer } from '../TextInput.styled';
|
|
9
|
+
function fileNameFromFullPath(path) {
|
|
10
|
+
return path.split('\\').pop();
|
|
11
|
+
}
|
|
8
12
|
const FileInput = forwardRef((props, ref) => {
|
|
9
13
|
const { error, helperMsg, leftIcon, rightIcon, inputSX, type: inputType, value, onChange, onClick, ...inputProps } = props;
|
|
10
14
|
// Unique ID used to select hidden file input and click on it
|
|
11
15
|
const uID = uniqueId('hidden-file-input-');
|
|
12
16
|
const baseSX = inputSX ?? {
|
|
13
17
|
paddingRight: '44px',
|
|
14
|
-
pointerEvents: 'none',
|
|
15
18
|
width: '100%',
|
|
16
19
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const [labelText, setLabelText] = useState('');
|
|
21
|
+
const handleChange = (event) => {
|
|
22
|
+
const filePath = event.target.value;
|
|
23
|
+
if (filePath) {
|
|
24
|
+
setLabelText(fileNameFromFullPath(filePath));
|
|
25
|
+
}
|
|
26
|
+
onChange?.(event);
|
|
27
|
+
};
|
|
28
|
+
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 })), _jsxs(FileInputLabel, { disabled: props.disabled, readOnly: props.readOnly, large: props.large, error: !!error, leftIcon: leftIcon, sx: baseSX, children: [_jsx("input", { ref: ref, type: "file", name: uID, accept: props.accept, style: { display: 'none' }, disabled: inputProps.disabled, onChange: handleChange, readOnly: false }), labelText ? (_jsx(Box, { children: labelText })) : (_jsx(Typography, { variant: "body5", sx: { color: theme.palette.neutralGrey[45] }, children: props.placeholder })), _jsx(RightIconContainer, { sx: { pointerEvents: 'none' }, children: _jsx(Project, {}) })] })] }), error ? (_jsx(InputMsg, { variant: "body5", error: true, children: error })) : (helperMsg && _jsx(InputMsg, { variant: "body5", children: helperMsg }))] }));
|
|
23
29
|
});
|
|
24
30
|
export default FileInput;
|
|
@@ -9,6 +9,8 @@ export const HistogramContainer = styled(Box)({
|
|
|
9
9
|
export const HistogramTitle = styled(Typography)({
|
|
10
10
|
width: '100%',
|
|
11
11
|
paddingBottom: '12px',
|
|
12
|
+
textWrap: 'wrap',
|
|
13
|
+
wordBreak: 'break-all',
|
|
12
14
|
});
|
|
13
15
|
export const HistogramNoData = styled(Typography)(({ theme }) => ({
|
|
14
16
|
top: '42%',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunit/oui",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.17",
|
|
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)"
|