@lunit/oui 2.2.9 → 2.2.11

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.
@@ -21,7 +21,7 @@ const FileInput = forwardRef((props, ref) => {
21
21
  return;
22
22
  fileInput[0].click();
23
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' }, onChange: (e) => {
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
25
  setFileName(e.target.value.split('\\').pop());
26
26
  } }), _jsxs(FileInputWrapperButton, { onClick: () => handleButtonClicksFile(), width: props.width, children: [_jsx(BaseTextInput, { ...inputProps, type: "text", error: !!error, value: fileName,
27
27
  // @Tobio89: this dummy onchange clears an error without triggering unwanted style changes
@@ -10,6 +10,12 @@ import { FreeText } from '../FreeText';
10
10
  import { Statistic } from '../Statistic';
11
11
  import { Score } from '../Score';
12
12
  const Accordion = ({ componentType = 'accordion', MuiAccordionProps, AccordionDetailsProps, AccordionSummaryProps, size = 'medium', tooltip = [], title, items, metrics, isOpen, onChange, }) => {
13
+ if (!componentType)
14
+ throw new Error("The 'componentType' prop is required.");
15
+ if (!title)
16
+ throw new Error("The 'title' prop is required.");
17
+ if (!items.length)
18
+ throw new Error("The 'items' prop must contain at least one item.");
13
19
  return (_jsxs(BaseAccordion, { ...MuiAccordionProps, expanded: isOpen, onChange: onChange, sx: { alignItems: 'center' }, children: [_jsxs(BaseAccordionSummary, { expandIcon: _jsx(ArrowDown, { sx: { fill: theme.palette.neutralGrey[40] } }), ...AccordionSummaryProps, children: [!!tooltip.length && (_jsx(Tooltip, { arrow: true, size: "large", onClick: (event) => event.stopPropagation(), title: _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, onClick: (event) => event.stopPropagation(), children: tooltip.map((item) => (_jsxs(Box, { children: [item.componentType === 'freeText' && (_jsx(FreeText, { componentType: item.componentType, size: item.size, content: item.content })), item.componentType === 'statistic' && (_jsx(Statistic, { componentType: item.componentType, title: item.title, size: item.size, layout: item.layout, symbol: item.symbol, color: item.color }))] }, uuidV4()))) }), children: _jsx(Box, { sx: {
14
20
  marginRight: size.includes('small') ? '4px' : '6px',
15
21
  display: 'flex',
@@ -18,6 +18,10 @@ const Segments = ({ segments, adjustForOnePercent }) => {
18
18
  }) }));
19
19
  };
20
20
  const AnalysisBar = ({ componentType = 'analysisBar', expressionValue, caption, expressionLevels = [], segments, isDimmed = false, }) => {
21
+ if (!componentType)
22
+ throw new Error("The 'componentType' prop is required.");
23
+ if (!expressionLevels.length)
24
+ throw new Error("The 'expressionLevels' prop must contain at least one item.");
21
25
  const hasAdjustedOnePercentSegment = segments?.[0].width === 1;
22
26
  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 &&
23
27
  expressionLevels.map((val, i) => {
@@ -3,6 +3,10 @@ import { Box } from '@mui/material';
3
3
  import theme from '../../theme';
4
4
  import { PresentationTypography } from '../presentations.styled';
5
5
  const FreeText = ({ componentType = 'freeText', size = 'medium', content, height, background = false, }) => {
6
+ if (!componentType)
7
+ throw new Error("The 'componentType' prop is required.");
8
+ if (!content)
9
+ throw new Error("The 'content' prop is required.");
6
10
  return (_jsx(Box, { sx: {
7
11
  padding: background ? '8px 6px 8px 16px' : 0,
8
12
  borderRadius: background ? '8px' : 0,
@@ -7,6 +7,16 @@ import HistogramTabs from './HistogramTabs';
7
7
  import HistogramChart from './HistogramCharts';
8
8
  import { FreeText } from '../FreeText';
9
9
  const Histogram = ({ componentType = 'histogram', title, xAxisLabels, yAxisLabels, tabs, description = [], }) => {
10
+ if (!componentType)
11
+ throw new Error("The 'componentType' prop is required.");
12
+ if (!title)
13
+ throw new Error("The 'title' prop is required.");
14
+ if (!xAxisLabels.length)
15
+ throw new Error("The 'xAxisLabels' prop must contain at least one item.");
16
+ if (!yAxisLabels.length)
17
+ throw new Error("The 'yAxisLabels' prop must contain at least one item.");
18
+ if (!tabs.length)
19
+ throw new Error("The 'tabs' prop must contain at least one item.");
10
20
  const [activeIndex, setActiveIndex] = useState(0);
11
21
  const noData = tabs[activeIndex].data.length === 0;
12
22
  return (_jsxs(HistogramContainer, { children: [noData && _jsx(HistogramNoData, { children: "No Data" }), title && _jsx(HistogramTitle, { children: title }), _jsx(HistogramTabs, { options: tabs.map((tab) => tab.label), active: activeIndex, onChange: setActiveIndex }), _jsx(HistogramChartContainer, { children: _jsx(Box, { sx: {
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Divider } from '../../components';
3
3
  const HorizonDivider = ({ componentType = 'divider' }) => {
4
+ if (!componentType)
5
+ throw new Error("The 'componentType' prop is required.");
4
6
  return _jsx(Divider, { orientation: "horizontal" });
5
7
  };
6
8
  export default HorizonDivider;
@@ -4,6 +4,12 @@ const capitalize = (str) => {
4
4
  return str.charAt(0).toUpperCase() + str.slice(1);
5
5
  };
6
6
  const Score = ({ componentType = 'score', title, size = 'medium', metrics }) => {
7
+ if (!componentType)
8
+ throw new Error("The 'componentType' prop is required.");
9
+ if (!title)
10
+ throw new Error("The 'title' prop is required.");
11
+ if (!metrics)
12
+ throw new Error("The 'metrics' prop is required.");
7
13
  return (_jsxs(PresentationTypography, { size: size, style: { color: metrics.isFullColored ? metrics.color : 'inherit' }, children: [title, ": ", metrics.value, metrics.scoreType && (_jsx("span", { style: { color: metrics.color, marginLeft: 4 }, children: capitalize(metrics.scoreType) }))] }));
8
14
  };
9
15
  export default Score;
@@ -3,6 +3,10 @@ import { Box } from '@mui/material';
3
3
  import { Container, HorizontalStatisticContainer, VerticalStatisticContainer, } from './Statistic.styled';
4
4
  import { PresentationSymbolIcon, PresentationTypography } from '../presentations.styled';
5
5
  const Statistic = ({ componentType = 'statistic', title, layout = 'vertical', metrics = '', size = 'medium', symbol, color, isDimmed = false, ...rest }) => {
6
+ if (!componentType)
7
+ throw new Error("The 'componentType' prop is required.");
8
+ if (!title)
9
+ throw new Error("The 'title' prop is required.");
6
10
  return (_jsx(Container, { ...rest, sx: { width: '100%' }, children: layout === 'horizontal' ? (_jsxs(HorizontalStatisticContainer, { children: [_jsxs(Box, { sx: {
7
11
  display: 'flex',
8
12
  alignItems: 'center',
@@ -11,6 +11,14 @@ import { HorizonDivider } from '../HorizonDivider';
11
11
  import { FreeText } from '../FreeText';
12
12
  import { getPresetValue, getSliderMarks } from './Threshold.utils';
13
13
  const Threshold = ({ componentType = 'threshold', title, totalScore, totalCells, statisticItems, options, description, controlStep = 1, isLoading = false, onChangeDropdown, onSliderChangeCommitted, onClickUpdateConfiguration, }) => {
14
+ if (!componentType)
15
+ throw new Error("The 'componentType' prop is required.");
16
+ if (!totalScore)
17
+ throw new Error("The 'totalScore' prop is required.");
18
+ if (!statisticItems.length)
19
+ throw new Error("The 'statisticItems' prop must contain at least one item.");
20
+ if (!options.length)
21
+ throw new Error("The 'options' prop must contain at least one item.");
14
22
  const [selectedItem, setSelectedItem] = useState(options[0].title.toString());
15
23
  const [selectedValue, setSelectedValue] = useState(options[0].value);
16
24
  const [selectedOptionValue, setSelectedOptionValue] = useState(options[0].value);
@@ -9,7 +9,13 @@ import { FreeText } from '../FreeText';
9
9
  import { Statistic } from '../Statistic';
10
10
  import { Tooltip } from '../../components';
11
11
  import { Information } from '../../icons';
12
- const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked = false, isDimmed = false, onChange, }) => {
12
+ const ToggleControl = ({ componentType = 'toggle', title, size = 'medium', symbol, tooltip = [], content = [], color, isParent = false, disabled = false, bar, checked, isDimmed = false, onChange, }) => {
13
+ if (!componentType)
14
+ throw new Error("The 'componentType' prop is required.");
15
+ if (!title)
16
+ throw new Error("The 'title' prop is required.");
17
+ if (checked === undefined)
18
+ throw new Error("The 'checked' prop is required.");
13
19
  return (_jsxs(ToggleControlOuter, { "data-toggle-name": `toggle-control-${title?.replace(/\s/g, '-')}`, hasBar: !!bar || !!content.length, style: { marginBottom: isParent ? '4px' : '0' }, children: [_jsxs(ToggleControlContainer, { className: "toggle-inner-container", size: size, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: '6px' }, className: "toggle-label", children: [!!tooltip.length && (_jsx(Tooltip, { arrow: true, size: "large", title: _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '8px' }, children: tooltip.map((item) => (_jsxs(Box, { children: [item.componentType === 'freeText' && (_jsx(FreeText, { componentType: item.componentType, size: item.size, content: item.content })), item.componentType === 'statistic' && (_jsx(Statistic, { componentType: item.componentType, title: item.title, size: item.size, layout: item.layout, symbol: item.symbol, color: item.color }))] }, uuidV4()))) }), children: _jsx(Box, { sx: {
14
20
  display: 'flex',
15
21
  alignItems: 'center',
@@ -9,7 +9,7 @@ export interface ToggleControlSpec {
9
9
  size?: PresentationElementSize;
10
10
  symbol?: PresentationSymbol;
11
11
  color?: string;
12
- checked?: boolean;
12
+ checked: boolean;
13
13
  tooltip?: (StatisticProps | FreeTextProps)[];
14
14
  content?: StatisticProps[];
15
15
  bar?: AnalysisBarProps;
@@ -2,7 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { v4 as uuidV4 } from 'uuid';
3
3
  import { ToggleControlGroupContainer } from './ToggleControlGroup.styled';
4
4
  import ToggleControl from '../ToggleControl/ToggleControl';
5
- const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', title, tooltip = [], bar, childToggles, disabled, checked = true, behavior = 'multi', isDimmed = false, onChange, }) => {
5
+ const ToggleControlGroup = ({ componentType = 'toggleGroup', size = 'medium', title, tooltip = [], bar, childToggles, disabled, checked, behavior = 'multi', isDimmed = false, onChange, }) => {
6
+ if (!componentType)
7
+ throw new Error("The 'componentType' prop is required.");
8
+ if (!title)
9
+ throw new Error("The 'title' prop is required.");
10
+ if (checked === undefined)
11
+ throw new Error("The 'checked' prop is required.");
12
+ if (!childToggles.length)
13
+ throw new Error("The 'childToggles' prop must contain at least one child toggle.");
6
14
  return (_jsxs(ToggleControlGroupContainer, { children: [_jsx(ToggleControl, { isParent: true, componentType: "toggle", bar: bar, disabled: disabled, size: size, title: title, tooltip: tooltip, checked: checked, isDimmed: isDimmed, onChange: onChange }), childToggles?.map((child, index) => {
7
15
  return (_jsx(ToggleControl, { componentType: "toggle", title: child.title, size: size, tooltip: child.tooltip, symbol: child.symbol, color: child.color, isDimmed: child.isDimmed || isDimmed, checked: child.checked, disabled: child.disabled, onChange: (event) => {
8
16
  child.onChange(event);
@@ -12,7 +12,7 @@ export interface ToggleGroupControlSpec {
12
12
  size?: PresentationElementSize;
13
13
  tooltip?: (StatisticProps | FreeTextProps)[];
14
14
  bar?: AnalysisBarProps;
15
- checked?: boolean;
15
+ checked: boolean;
16
16
  childToggles: ToggleControlProps[];
17
17
  }
18
18
  export interface ToggleControlGroupProps extends ToggleGroupControlSpec {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunit/oui",
3
- "version": "2.2.9",
3
+ "version": "2.2.11",
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)"