@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.
@@ -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, onKeyDown: (event) => {
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, onKeyDown: (event) => {
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 ?? false);
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
- return (_jsx(PasswordInputContainer, { ...props, hidePassword: hidePassword, handlePasswordShowHide: () => handlePasswordShowHide(), children: _jsx(BaseTextInput, { type: hidePassword ? 'password' : 'text', ref: ref, ...otherInputProps, leftIcon: leftIcon, sx: inputSX }) }));
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, adjustForOnePercent }) => {
6
+ const Segments = ({ segments }) => {
7
7
  if (!segments) {
8
8
  return null;
9
9
  }
10
- const combinedWidth = segments.length > 1 ? segments[0].width + segments[1].width : 0;
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: segments?.map((segment, i) => {
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, hasAdjustedOnePercentSegment: adjustForOnePercent, isOnePercentSegment: segment.width > 0 && segment.width <= 1, combinedWidth: combinedWidth, width: segment.width, isNextSegment: i === 1 }, i));
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 hasAdjustedOnePercentSegment = segments?.[0]?.width > 0 && segments?.[0]?.width <= 1;
27
- return (_jsxs(AnalysisBarOuter, { className: "analysis-bar", isDimmed: isDimmed, children: [_jsxs(AnalysisBarSegmentContainer, { children: [expressionValue && (_jsx(GraphScoreIndicator, { adjustForOnePercent: hasAdjustedOnePercentSegment, value: expressionValue, isJet: segments?.[0].color === 'jet' })), _jsx(Segments, { segments: segments, adjustForOnePercent: hasAdjustedOnePercentSegment })] }), (expressionLevels.length > 0 || caption) && (_jsxs(AxisLabels, { children: [expressionLevels.length > 0 &&
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
- const adjustedForOnePercent = +val <= 1 && +val > 0;
30
- return (_jsx(GraphAxisLabel, { label: expressionLabels[i] || val, adjustForOnePercent: adjustedForOnePercent, leftPos: parseStringValToNumber(val) }, i));
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, adjustForOnePercent, isJet, }: {
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, adjustForOnePercent, }: {
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
- square?: boolean;
30
- hasAdjustedOnePercentSegment?: boolean;
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('span', {
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, adjustForOnePercent, isJet, }) => {
45
- let leftPos = `${parseStringValToNumber(value)}%`;
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, adjustForOnePercent, }) => {
65
- const getLeft = (value, adjustForOnePercent) => {
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, adjustForOnePercent),
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, square, hasAdjustedOnePercentSegment, combinedWidth, isNextSegment, isOnePercentSegment) => {
93
- const baseStyle = {
87
+ const segmentStyle = (color, width, isFirstSegment, isLastSegment) => {
88
+ return {
94
89
  backgroundColor: color,
95
90
  height: '8px',
96
- borderRadius: square ? '0px' : '12px',
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
- 'color',
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, square ?? false, hasAdjustedOnePercentSegment ?? false, combinedWidth ?? 0, isNextSegment ?? false, isOnePercentSegment ?? false), // fallback color
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: "M1.30733e-07 4C5.85312e-08 1.79086 1.79086 5.86502e-08 4 1.30999e-07L230 7.53243e-06C232.209 7.60478e-06 234 1.79087 234 4.00001C234 6.20915 232.209 8.00001 230 8.00001L4 8C1.79086 8 2.02935e-07 6.20914 1.30733e-07 4Z", 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" })] }) })] }));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/oui",
3
- "version": "2.3.9",
3
+ "version": "2.4.1",
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)"