@lunit/oui 2.3.9 → 2.4.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.
- package/dist/components/TextField/components/Buttons.js +2 -12
- package/dist/components/TextField/components/NormalTextInput.js +1 -1
- package/dist/components/TextField/components/PasswordInput.js +13 -2
- package/dist/presentations/AnalysisBar/AnalysisBar.js +8 -9
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.d.ts +4 -9
- package/dist/presentations/AnalysisBar/AnalysisBar.styled.js +17 -42
- package/dist/presentations/AnalysisBar/HeatmapGraphIcon/HeatmapGraphSVG.js +1 -1
- package/package.json +1 -1
|
@@ -2,20 +2,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { CloseSmall, HideSmall, ShowSmall } from '../../../icons';
|
|
3
3
|
import { ButtonWrapper } from '../TextInput.styled';
|
|
4
4
|
function ClearButton({ onClick }) {
|
|
5
|
-
return (_jsx(ButtonWrapper, { onClick: onClick,
|
|
6
|
-
if (event.key === 'Enter') {
|
|
7
|
-
event.preventDefault();
|
|
8
|
-
event.stopPropagation();
|
|
9
|
-
}
|
|
10
|
-
}, children: _jsx(CloseSmall, { fontSize: "small" }) }));
|
|
5
|
+
return (_jsx(ButtonWrapper, { onClick: onClick, children: _jsx(CloseSmall, { fontSize: "small" }) }));
|
|
11
6
|
}
|
|
12
7
|
function ShowHidePasswordButton({ onClick, isHidden, }) {
|
|
13
|
-
return (_jsx(ButtonWrapper, { onClick: onClick,
|
|
14
|
-
if (event.key === 'Enter') {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
}
|
|
18
|
-
}, children: isHidden ? _jsx(HideSmall, {}) : _jsx(ShowSmall, {}) }));
|
|
8
|
+
return (_jsx(ButtonWrapper, { onClick: onClick, children: isHidden ? _jsx(HideSmall, {}) : _jsx(ShowSmall, {}) }));
|
|
19
9
|
}
|
|
20
10
|
function FileInputWrapperButton({ children, onClick, width, }) {
|
|
21
11
|
return (_jsx("button", { onClick: onClick, style: {
|
|
@@ -5,7 +5,7 @@ import { BaseTextInput, LeftIconContainer, RightIconContainer } from '../TextInp
|
|
|
5
5
|
import { ClearButton } from './Buttons';
|
|
6
6
|
const NormalTextInput = forwardRef((props, ref) => {
|
|
7
7
|
const { error, helperMsg, leftIcon, rightIcon, onClearButtonClick, inputSX, ...inputProps } = props;
|
|
8
|
-
const [showClear, setShowClear] = useState(!!props.defaultValue
|
|
8
|
+
const [showClear, setShowClear] = useState(!!props.defaultValue);
|
|
9
9
|
const showRightIcon = useMemo(() => {
|
|
10
10
|
return (rightIcon ?? // if rightIcon is passed, use it, else use clear button
|
|
11
11
|
(!props.disabled && // hide if disabled
|
|
@@ -11,11 +11,22 @@ function PasswordInputContainer(props) {
|
|
|
11
11
|
}, isHidden: hidePassword })) }), error ? (_jsx(InputMsg, { variant: "body5", error: true, children: error })) : (helperMsg && _jsx(InputMsg, { variant: "body5", children: helperMsg }))] }));
|
|
12
12
|
}
|
|
13
13
|
const PasswordInput = forwardRef((props, ref) => {
|
|
14
|
-
const { error, helperMsg, leftIcon, type, inputSX, ...otherInputProps } = props;
|
|
14
|
+
const { error, helperMsg, leftIcon, type, inputSX, onKeyDown, ...otherInputProps } = props;
|
|
15
15
|
const [hidePassword, setHidePassword] = useState(true);
|
|
16
16
|
function handlePasswordShowHide() {
|
|
17
17
|
setHidePassword(!hidePassword);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const handleKeyDown = (event) => {
|
|
20
|
+
// Call the original onKeyDown if provided
|
|
21
|
+
if (onKeyDown) {
|
|
22
|
+
onKeyDown(event);
|
|
23
|
+
}
|
|
24
|
+
// Prevent Enter key from changing password visibility
|
|
25
|
+
if (event.key === 'Enter') {
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(PasswordInputContainer, { ...props, hidePassword: hidePassword, handlePasswordShowHide: () => handlePasswordShowHide(), children: _jsx(BaseTextInput, { type: hidePassword ? 'password' : 'text', ref: ref, ...otherInputProps, onKeyDown: handleKeyDown, leftIcon: leftIcon, sx: inputSX }) }));
|
|
20
31
|
});
|
|
21
32
|
export default PasswordInput;
|
|
@@ -3,19 +3,19 @@ import { Box } from '@mui/material';
|
|
|
3
3
|
import { AnalysisBarSegmentContainer, AnalysisBarOuter, AxisLabels, GraphAxisLabel, GraphScoreIndicator, GraphSegment, } from './AnalysisBar.styled';
|
|
4
4
|
import { parseStringValToNumber } from './AnalysisBar.utils';
|
|
5
5
|
import HeatmapGraphSVG from './HeatmapGraphIcon/HeatmapGraphSVG';
|
|
6
|
-
const Segments = ({ segments
|
|
6
|
+
const Segments = ({ segments }) => {
|
|
7
7
|
if (!segments) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const validSegments = segments.filter((segment) => segment.width > 0);
|
|
11
11
|
if (segments?.length === 1 && segments[0].color === 'jet') {
|
|
12
12
|
return (_jsx(Box, { sx: { width: '100%', height: '14px', transform: 'scaleY(0.8)' }, children: _jsx(HeatmapGraphSVG, {}) }));
|
|
13
13
|
}
|
|
14
|
-
return (_jsx(_Fragment, { children:
|
|
14
|
+
return (_jsx(_Fragment, { children: validSegments?.map((segment, i) => {
|
|
15
15
|
if (segment.color === 'jet') {
|
|
16
16
|
return _jsx(HeatmapGraphSVG, { width: `${segment.width}%` });
|
|
17
17
|
}
|
|
18
|
-
return (_jsx(GraphSegment, { color: segment.color,
|
|
18
|
+
return (_jsx(GraphSegment, { color: segment.color, width: segment.width, isFirstSegment: i === 0, isLastSegment: i === segments.length - 1 }, i));
|
|
19
19
|
}) }));
|
|
20
20
|
};
|
|
21
21
|
const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption, expressionLevels = [], expressionLabels = [], segments, isDimmed = false, }) => {
|
|
@@ -23,11 +23,10 @@ const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption,
|
|
|
23
23
|
throw new Error("The 'componentType' prop is required.");
|
|
24
24
|
if (!expressionLevels.length)
|
|
25
25
|
throw new Error("The 'expressionLevels' prop must contain at least one item.");
|
|
26
|
-
const
|
|
27
|
-
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, {
|
|
26
|
+
const validSegments = segments.filter((segment) => segment.width > 0);
|
|
27
|
+
return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { value: expressionValue, isJet: segments?.[0].color === 'jet' })), _jsx(Segments, { segments: validSegments })] }), (expressionLevels.length > 0 || caption) && (_jsxs(AxisLabels, { children: [expressionLevels.length > 0 &&
|
|
28
28
|
expressionLevels.map((val, i) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}), caption && (_jsx(GraphAxisLabel, { label: caption, adjustForOnePercent: hasAdjustedOnePercentSegment, leftPos: 50 }))] }))] }));
|
|
29
|
+
return (_jsx(GraphAxisLabel, { label: expressionLabels[i] || val, leftPos: parseStringValToNumber(val) }, i));
|
|
30
|
+
}), caption && (_jsx(GraphAxisLabel, { label: caption, leftPos: 50 }))] }))] }));
|
|
32
31
|
};
|
|
33
32
|
export default AnalysisBar;
|
|
@@ -7,15 +7,13 @@ export declare const AnalysisBarOuter: import("@emotion/styled").StyledComponent
|
|
|
7
7
|
export declare const AnalysisBarSegmentContainer: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
8
8
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
9
9
|
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
10
|
-
export declare const GraphScoreIndicator: ({ value,
|
|
10
|
+
export declare const GraphScoreIndicator: ({ value, isJet }: {
|
|
11
11
|
value: string;
|
|
12
|
-
adjustForOnePercent: boolean;
|
|
13
12
|
isJet?: boolean | undefined;
|
|
14
13
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export declare const GraphAxisLabel: ({ label, leftPos
|
|
14
|
+
export declare const GraphAxisLabel: ({ label, leftPos }: {
|
|
16
15
|
label: string;
|
|
17
16
|
leftPos: number;
|
|
18
|
-
adjustForOnePercent: boolean;
|
|
19
17
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
18
|
export declare const AxisLabels: ({ children }: {
|
|
21
19
|
percent?: boolean;
|
|
@@ -26,11 +24,8 @@ export declare const AnalysisBarCaption: ({ label }: {
|
|
|
26
24
|
interface GraphSegmentProps {
|
|
27
25
|
color: string | undefined;
|
|
28
26
|
width: number;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
combinedWidth?: number;
|
|
32
|
-
isNextSegment?: boolean;
|
|
33
|
-
isOnePercentSegment?: boolean;
|
|
27
|
+
isFirstSegment: boolean;
|
|
28
|
+
isLastSegment: boolean;
|
|
34
29
|
}
|
|
35
30
|
export declare const GraphSegment: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & GraphSegmentProps, React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
36
31
|
export {};
|
|
@@ -17,8 +17,9 @@ export const AnalysisBarSegmentContainer = styled(Box)(() => ({
|
|
|
17
17
|
alignItems: 'center',
|
|
18
18
|
position: 'relative',
|
|
19
19
|
width: '100%',
|
|
20
|
+
gap: '1px',
|
|
20
21
|
}));
|
|
21
|
-
const GraphScoreIndicatorContainer = styled(
|
|
22
|
+
const GraphScoreIndicatorContainer = styled(Box, {
|
|
22
23
|
shouldForwardProp: (prop) => prop !== 'isJet',
|
|
23
24
|
})(({ isJet }) => {
|
|
24
25
|
return {
|
|
@@ -41,11 +42,8 @@ const GraphScoreIndicatorPip = styled('span')(() => {
|
|
|
41
42
|
boxSizing: 'content-box',
|
|
42
43
|
};
|
|
43
44
|
});
|
|
44
|
-
export const GraphScoreIndicator = ({ value,
|
|
45
|
-
|
|
46
|
-
if (adjustForOnePercent && +value <= 1) {
|
|
47
|
-
leftPos = '12px';
|
|
48
|
-
}
|
|
45
|
+
export const GraphScoreIndicator = ({ value, isJet }) => {
|
|
46
|
+
const leftPos = `${parseStringValToNumber(value)}%`;
|
|
49
47
|
return (_jsxs(GraphScoreIndicatorContainer, { className: "analysis-bar-score-indicator", sx: {
|
|
50
48
|
left: leftPos,
|
|
51
49
|
transform: isJet ? 'translateX(-50%) translateY(8px)' : 'translateX(-50%)',
|
|
@@ -61,15 +59,12 @@ const GraphAxisLabelContainer = styled('span')(() => {
|
|
|
61
59
|
alignItems: 'center',
|
|
62
60
|
};
|
|
63
61
|
});
|
|
64
|
-
export const GraphAxisLabel = ({ label, leftPos
|
|
65
|
-
const getLeft = (value
|
|
66
|
-
if (adjustForOnePercent) {
|
|
67
|
-
return '12px';
|
|
68
|
-
}
|
|
62
|
+
export const GraphAxisLabel = ({ label, leftPos }) => {
|
|
63
|
+
const getLeft = (value) => {
|
|
69
64
|
return `${clampBarLabelPosition(value)}%`;
|
|
70
65
|
};
|
|
71
66
|
return (_jsx(GraphAxisLabelContainer, { sx: {
|
|
72
|
-
left: getLeft(leftPos
|
|
67
|
+
left: getLeft(leftPos),
|
|
73
68
|
transform: 'translateX(-50%)',
|
|
74
69
|
}, className: "analysis-bar-axis-label", children: _jsx(Typography, { variant: "small_body_m5", sx: { textAlign: 'center' }, children: label }) }));
|
|
75
70
|
};
|
|
@@ -89,43 +84,23 @@ export const AnalysisBarCaption = ({ label }) => {
|
|
|
89
84
|
width: 'auto',
|
|
90
85
|
}, className: "analysis-bar-caption", children: _jsx(Typography, { variant: "small_body_m5", sx: { textAlign: 'center' }, children: label }) }));
|
|
91
86
|
};
|
|
92
|
-
const segmentStyle = (color, width,
|
|
93
|
-
|
|
87
|
+
const segmentStyle = (color, width, isFirstSegment, isLastSegment) => {
|
|
88
|
+
return {
|
|
94
89
|
backgroundColor: color,
|
|
95
90
|
height: '8px',
|
|
96
|
-
|
|
91
|
+
borderTopLeftRadius: isFirstSegment ? '2px' : '0px',
|
|
92
|
+
borderTopRightRadius: isLastSegment ? '2px' : '0px',
|
|
93
|
+
borderBottomLeftRadius: isFirstSegment ? '2px' : '0px',
|
|
94
|
+
borderBottomRightRadius: isLastSegment ? '2px' : '0px',
|
|
95
|
+
width: `${width}%`,
|
|
97
96
|
};
|
|
98
|
-
if (isOnePercentSegment) {
|
|
99
|
-
return {
|
|
100
|
-
...baseStyle,
|
|
101
|
-
width: '12px',
|
|
102
|
-
minWidth: '12px',
|
|
103
|
-
maxWidth: '12px',
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return {
|
|
108
|
-
...baseStyle,
|
|
109
|
-
width: hasAdjustedOnePercentSegment && isNextSegment
|
|
110
|
-
? `calc(${combinedWidth}% - 12px)`
|
|
111
|
-
: `${width}%`,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
97
|
};
|
|
115
98
|
export const GraphSegment = styled('span', {
|
|
116
|
-
shouldForwardProp: (prop) => ![
|
|
117
|
-
|
|
118
|
-
'width',
|
|
119
|
-
'square',
|
|
120
|
-
'hasAdjustedOnePercentSegment',
|
|
121
|
-
'combinedWidth',
|
|
122
|
-
'isNextSegment',
|
|
123
|
-
'isOnePercentSegment',
|
|
124
|
-
].includes(prop.toString()),
|
|
125
|
-
})(({ color, width, square, hasAdjustedOnePercentSegment, combinedWidth, isNextSegment, isOnePercentSegment, }) => {
|
|
99
|
+
shouldForwardProp: (prop) => !['color', 'width', 'isFirstSegment', 'isLastSegment'].includes(prop.toString()),
|
|
100
|
+
})(({ color, width, isFirstSegment, isLastSegment }) => {
|
|
126
101
|
// cover undefined and empty string
|
|
127
102
|
const barColor = color && color.length ? color : 'red';
|
|
128
103
|
return {
|
|
129
|
-
...segmentStyle(barColor, width,
|
|
104
|
+
...segmentStyle(barColor, width, isFirstSegment, isLastSegment), // fallback color
|
|
130
105
|
};
|
|
131
106
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
const HeatmapGraphSVG = (props) => (_jsxs("svg", { width: "100%", height: "100%", viewBox: "0 0 234 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "
|
|
2
|
+
const HeatmapGraphSVG = (props) => (_jsxs("svg", { width: "100%", height: "100%", viewBox: "0 0 234 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [_jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M2 0C0.895431 0 0 0.895431 0 2V6C0 7.10457 0.895431 8 2 8H232C233.105 8 234 7.10457 234 6V2C234 0.895431 233.105 0 232 0H2Z", fill: "url(#paint0_linear_4060_316245)" }), _jsx("defs", { children: _jsxs("linearGradient", { id: "paint0_linear_4060_316245", x1: "-0.585003", y1: "5.99984", x2: "228.159", y2: "4.97311", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { stopColor: "#3000FF" }), _jsx("stop", { offset: "0.239583", stopColor: "#5CFFE2" }), _jsx("stop", { offset: "0.447917", stopColor: "#E2FFA4" }), _jsx("stop", { offset: "0.546875", stopColor: "#FCFF75" }), _jsx("stop", { offset: "0.78125", stopColor: "#FDBA73" }), _jsx("stop", { offset: "1", stopColor: "#FF0F00" })] }) })] }));
|
|
3
3
|
export default HeatmapGraphSVG;
|
package/package.json
CHANGED