FIX-1847 added all the changes and removed the truncate algo.
This commit is contained in:
1 parent
0eebd2929b
commit
4d437a8898
5 files changed
+15
-78
No files matched your search
@@ -2,7 +2,6 @@ import PropTypes from "prop-types";
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material";
|
import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material";
|
||||||
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
|
||||||
import { renderTruncatedValue } from "../../../Utils/Input/utils";
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,8 +49,6 @@ const Select = ({
|
|||||||
sx,
|
sx,
|
||||||
name = "",
|
name = "",
|
||||||
labelControlSpacing = 2,
|
labelControlSpacing = 2,
|
||||||
truncate = false,
|
|
||||||
maxTruncateLength = 15,
|
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@@ -65,10 +62,6 @@ const Select = ({
|
|||||||
margin: theme.spacing(2),
|
margin: theme.spacing(2),
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderShortValue = () => {
|
|
||||||
return renderTruncatedValue(displayName, truncate, maxTruncateLength, placeholder);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gap={theme.spacing(labelControlSpacing)}
|
gap={theme.spacing(labelControlSpacing)}
|
||||||
@@ -109,7 +102,6 @@ const Select = ({
|
|||||||
},
|
},
|
||||||
...sx,
|
...sx,
|
||||||
}}
|
}}
|
||||||
renderValue={renderShortValue}
|
|
||||||
>
|
>
|
||||||
{placeholder && (
|
{placeholder && (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|||||||
@@ -63,17 +63,7 @@ const OptionsHeader = ({
|
|||||||
>
|
>
|
||||||
Filter by:
|
Filter by:
|
||||||
</Typography>
|
</Typography>
|
||||||
<ButtonGroup
|
<ButtonGroup>
|
||||||
sx={{
|
|
||||||
ml: "auto",
|
|
||||||
alignItems: "stretch",
|
|
||||||
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
|
||||||
width: "auto",
|
|
||||||
whiteSpace: "nowrap",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
variant="group"
|
variant="group"
|
||||||
filled={(filter === "all").toString()}
|
filled={(filter === "all").toString()}
|
||||||
@@ -105,17 +95,7 @@ const OptionsHeader = ({
|
|||||||
>
|
>
|
||||||
Show:
|
Show:
|
||||||
</Typography>
|
</Typography>
|
||||||
<ButtonGroup
|
<ButtonGroup>
|
||||||
sx={{
|
|
||||||
ml: "auto",
|
|
||||||
alignItems: "stretch",
|
|
||||||
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
|
||||||
width: "auto",
|
|
||||||
whiteSpace: "nowrap",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
<Button
|
||||||
variant="group"
|
variant="group"
|
||||||
filled={(dateRange === "hour").toString()}
|
filled={(dateRange === "hour").toString()}
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import PropTypes from "prop-types";
|
|
||||||
import { isEmpty } from "../stringUtils";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Utility function to render a truncated value with an optional title.
|
|
||||||
* @param {string} displayName - The name or text to display.
|
|
||||||
* @param {boolean} truncate - Whether to truncate the text or not.
|
|
||||||
* @param {number} maxLength - The maximum length of the text.
|
|
||||||
* @param {string} placeholder - Placeholder text if no value is provided.
|
|
||||||
* @returns {JSX.Element} - The JSX element for the rendered value.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const renderTruncatedValue = function (
|
|
||||||
displayName,
|
|
||||||
truncate,
|
|
||||||
maxLength,
|
|
||||||
placeholder
|
|
||||||
) {
|
|
||||||
if (isEmpty(displayName)) return placeholder;
|
|
||||||
|
|
||||||
const truncateTextWithDottedEnds = function (text, maxLength) {
|
|
||||||
if (!text || text.length <= maxLength) return text;
|
|
||||||
return `${text.substring(0, maxLength)}...`;
|
|
||||||
};
|
|
||||||
|
|
||||||
return truncate ? (
|
|
||||||
<span title={displayName}>{truncateTextWithDottedEnds(displayName, maxLength)}</span>
|
|
||||||
) : (
|
|
||||||
<span title={displayName}>{displayName}</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
renderTruncatedValue.propTypes = {
|
|
||||||
displayName: PropTypes.string, // The name or text to display
|
|
||||||
truncate: PropTypes.bool, // Whether to truncate the text or not
|
|
||||||
maxLength: PropTypes.number, // The maximum length of the text
|
|
||||||
placeholder: PropTypes.string, // Placeholder text if no value is provided
|
|
||||||
};
|
|
||||||
@@ -382,6 +382,18 @@ const baseTheme = (palette) => ({
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
MuiButtonGroup: {
|
||||||
|
styleOverrides: {
|
||||||
|
root: ({ theme }) => ({
|
||||||
|
ml: "auto",
|
||||||
|
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
||||||
|
borderColor: theme.palette.primary.lowContrast,
|
||||||
|
width: "auto",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
shape: {
|
shape: {
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
|
|||||||
@@ -42,14 +42,5 @@ export const toLowerCaseFirstLetter = (str) => {
|
|||||||
*/
|
*/
|
||||||
export const isEmpty = (str) => {
|
export const isEmpty = (str) => {
|
||||||
// Check if string is null, undefined, or empty (including whitespace only)
|
// Check if string is null, undefined, or empty (including whitespace only)
|
||||||
return str === null || str === undefined || str.trim().length === 0;
|
return str === null || typeof str === "undefined" || str.trim().length === 0;
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a string is not null, undefined, and not empty (including strings with only whitespace).
|
|
||||||
* @param {string} str - The string to check.
|
|
||||||
* @returns {boolean} - Returns true if the string is not null, undefined, and not empty.
|
|
||||||
*/
|
|
||||||
export const isNotEmpty = (str) => {
|
|
||||||
return !isEmpty(str);
|
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user