@codezee/sixtify-brahma 0.2.82 → 0.2.83
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/package.json +1 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.d.ts.map +1 -1
- package/packages/shared-components/dist/CellSelectionTable/CellSelectionTable.js +16 -2
- package/packages/shared-components/dist/CellSelectionTable/hook/useOutsideClick.d.ts +4 -0
- package/packages/shared-components/dist/CellSelectionTable/hook/useOutsideClick.d.ts.map +1 -0
- package/packages/shared-components/dist/CellSelectionTable/hook/useOutsideClick.js +48 -0
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts +2 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.d.ts.map +1 -1
- package/packages/shared-components/dist/FormFields/DatePicker/DatePicker.js +9 -6
- package/packages/shared-components/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/packages/shared-components/dist/Tooltip/Tooltip.js +13 -2
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CellSelectionTable.d.ts","sourceRoot":"","sources":["../../src/CellSelectionTable/CellSelectionTable.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAaf,OAAO,KAAK,EACV,SAAS,EACT,MAAM,EAGP,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,IAAI,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,eAAe,EAAE,CACf,aAAa,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC,EACtC,CAAC,EAAE,UAAU,KACV,IAAI,CAAC;IACV,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,oFAQhC,QAAQ,CAAC,uBAAuB,CAAC,4CA4YnC,CAAC"}
|
|
@@ -6,6 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const Tooltip_1 = require("../Tooltip");
|
|
9
|
+
const useOutsideClick_1 = require("./hook/useOutsideClick");
|
|
9
10
|
const useStickyColumns_1 = require("./hook/useStickyColumns");
|
|
10
11
|
const EmployeeCell_1 = require("./SubComponents/EmployeeCell");
|
|
11
12
|
const TableBodyLoader_1 = require("./SubComponents/TableBodyLoader");
|
|
@@ -14,12 +15,23 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
14
15
|
const theme = (0, material_1.useTheme)();
|
|
15
16
|
const { slate, iron, butterflyBlue } = theme.palette.app.color;
|
|
16
17
|
const selectingRef = (0, react_1.useRef)(false);
|
|
18
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
17
19
|
const selectionModeRef = (0, react_1.useRef)("add");
|
|
18
20
|
const anchorRef = (0, react_1.useRef)(null);
|
|
19
21
|
const hoveringRef = (0, react_1.useRef)(null);
|
|
20
22
|
const [selectedRanges, setSelectedRanges] = (0, react_1.useState)([]);
|
|
21
23
|
const [currentSelectedRanges, setCurrentSelectedRanges] = (0, react_1.useState)([]);
|
|
22
24
|
const { stickyMap } = (0, useStickyColumns_1.useStickyColumns)(columns);
|
|
25
|
+
(0, useOutsideClick_1.useOutsideClick)(tableRef, () => {
|
|
26
|
+
setSelectedRanges([]);
|
|
27
|
+
setCurrentSelectedRanges([]);
|
|
28
|
+
});
|
|
29
|
+
(0, react_1.useMemo)(() => {
|
|
30
|
+
if (loading && selectedRanges.length > 0) {
|
|
31
|
+
setSelectedRanges([]);
|
|
32
|
+
setCurrentSelectedRanges([]);
|
|
33
|
+
}
|
|
34
|
+
}, [loading]);
|
|
23
35
|
const isSelectedCell = (rowIndex, colIndex) => {
|
|
24
36
|
if (selectedRanges.length === 0 && currentSelectedRanges.length === 0) {
|
|
25
37
|
return false;
|
|
@@ -59,7 +71,8 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
59
71
|
return iron[600];
|
|
60
72
|
}
|
|
61
73
|
const handleCellMouseDown = (0, react_1.useCallback)((ri, ci) => (e) => {
|
|
62
|
-
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
if (columns[ci]?.disableSelection && ci > 0) {
|
|
63
76
|
const nextSelectableIndex = columns.findIndex((col, index) => !col.disableSelection && index > ci);
|
|
64
77
|
if (nextSelectableIndex !== -1) {
|
|
65
78
|
return (0, helper_1.handleMouseDown)({
|
|
@@ -153,7 +166,8 @@ const CellSelectionTable = ({ columns, data, onCellSelection, cellColors, height
|
|
|
153
166
|
onCellSelection,
|
|
154
167
|
});
|
|
155
168
|
}, [onCellSelection, selectedRanges]);
|
|
156
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { position: "relative", overflow: "auto", height: height, bgcolor: iron[600], children: (0, jsx_runtime_1.jsxs)(material_1.Table, { stickyHeader: true, sx: {
|
|
169
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { position: "relative", overflow: "auto", height: height, bgcolor: iron[600], children: (0, jsx_runtime_1.jsxs)(material_1.Table, { ref: tableRef, stickyHeader: true, sx: {
|
|
170
|
+
userSelect: "none",
|
|
157
171
|
borderCollapse: "separate",
|
|
158
172
|
borderSpacing: 0,
|
|
159
173
|
"& th, & td": {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
export declare function isClickInsideAnyOverlay(event: MouseEvent): boolean;
|
|
3
|
+
export declare function useOutsideClick<T extends HTMLElement>(ref: RefObject<T>, onOutsideClick: () => void): void;
|
|
4
|
+
//# sourceMappingURL=useOutsideClick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOutsideClick.d.ts","sourceRoot":"","sources":["../../../src/CellSelectionTable/hook/useOutsideClick.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,OAAO,CAAC;AAWlD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAsBlE;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EACnD,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EACjB,cAAc,EAAE,MAAM,IAAI,QAyB3B"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClickInsideAnyOverlay = isClickInsideAnyOverlay;
|
|
4
|
+
exports.useOutsideClick = useOutsideClick;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const OVERLAY_ROLES = new Set([
|
|
7
|
+
"dialog",
|
|
8
|
+
"alertdialog",
|
|
9
|
+
"menu",
|
|
10
|
+
"listbox",
|
|
11
|
+
"tooltip",
|
|
12
|
+
"combobox",
|
|
13
|
+
]);
|
|
14
|
+
function isClickInsideAnyOverlay(event) {
|
|
15
|
+
const path = (event.composedPath ? event.composedPath() : []);
|
|
16
|
+
for (const node of path) {
|
|
17
|
+
if (!(node instanceof Element)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (node.getAttribute("aria-modal") === "true") {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const role = node.getAttribute("role");
|
|
24
|
+
if (role && OVERLAY_ROLES.has(role)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return getComputedStyle(document.body).overflow === "hidden";
|
|
29
|
+
}
|
|
30
|
+
function useOutsideClick(ref, onOutsideClick) {
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
const handleMouseDown = (event) => {
|
|
33
|
+
if (isClickInsideAnyOverlay(event)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const target = event.target;
|
|
37
|
+
const el = ref.current;
|
|
38
|
+
if (el && el.contains(target)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
onOutsideClick();
|
|
42
|
+
};
|
|
43
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
44
|
+
return () => {
|
|
45
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
46
|
+
};
|
|
47
|
+
}, [ref, onOutsideClick]);
|
|
48
|
+
}
|
|
@@ -13,6 +13,7 @@ export type DatePickerProps<P extends FieldValues> = UseControllerProps<P> & Mui
|
|
|
13
13
|
clearable?: boolean;
|
|
14
14
|
view?: DateView[];
|
|
15
15
|
disableKeyboardInput?: boolean;
|
|
16
|
+
setOnFinalChange?: boolean;
|
|
16
17
|
setError: (name: keyof P, error: FieldError | {
|
|
17
18
|
type: string;
|
|
18
19
|
message?: string;
|
|
@@ -24,5 +25,5 @@ export declare const dateFormats: {
|
|
|
24
25
|
};
|
|
25
26
|
export declare const LeftArrowIcon: React.FC;
|
|
26
27
|
export declare const RightArrowIcon: React.FC;
|
|
27
|
-
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, views, format, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function DatePicker<P extends FieldValues>({ setError, control, defaultValue, disabled, label, readOnly, name, error, helperText, loading, required, clearable, rules, disableKeyboardInput, setOnFinalChange, views, format, ...restProps }: DatePickerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
28
29
|
//# sourceMappingURL=DatePicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACxE,kBAAkB,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC,CAAC;AAEL,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAclC,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,SAAmC,EACnC,KAAK,EACL,oBAA4B,EAC5B,KAAgC,EAChC,MAAqC,EACrC,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/FormFields/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,IAAI,kBAAkB,CAAC,CAAC,CAAC,GACxE,kBAAkB,CAAC,eAAe,CAAC,GACnC,OAAO,CAAC;IACN,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KACnD,IAAI,CAAC;CACX,CAAC,CAAC;AAEL,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAclC,CAAC;AAEF,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,EAChD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,QAAgB,EAChB,KAAK,EACL,QAAgB,EAChB,IAAI,EACJ,KAAa,EACb,UAAU,EACV,OAAe,EACf,QAAgB,EAChB,SAAmC,EACnC,KAAK,EACL,oBAA4B,EAC5B,gBAAwB,EACxB,KAAgC,EAChC,MAAqC,EACrC,GAAG,SAAS,EACb,EAAE,eAAe,CAAC,CAAC,CAAC,2CAiMpB"}
|
|
@@ -40,18 +40,18 @@ const RightArrowIcon = () => {
|
|
|
40
40
|
} }));
|
|
41
41
|
};
|
|
42
42
|
exports.RightArrowIcon = RightArrowIcon;
|
|
43
|
-
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, disableKeyboardInput = false, views = ["year", "month", "day"], format = exports.dateFormats.dateWithEuropean, ...restProps }) {
|
|
43
|
+
function DatePicker({ setError, control, defaultValue, disabled = false, label, readOnly = false, name, error = false, helperText, loading = false, required = false, clearable = required ? false : true, rules, disableKeyboardInput = false, setOnFinalChange = false, views = ["year", "month", "day"], format = exports.dateFormats.dateWithEuropean, ...restProps }) {
|
|
44
44
|
const [localError, setLocalError] = (0, react_1.useState)();
|
|
45
45
|
const { field: { value, onChange, ...restField }, } = (0, react_hook_form_1.useController)({ name, control, defaultValue, rules });
|
|
46
46
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
47
47
|
const theme = (0, material_1.useTheme)();
|
|
48
48
|
const { iron, butterflyBlue, mirage } = theme.palette.app.color;
|
|
49
49
|
const finalValue = (0, react_1.useMemo)(() => {
|
|
50
|
-
if (disableKeyboardInput && open) {
|
|
50
|
+
if ((disableKeyboardInput || setOnFinalChange) && open) {
|
|
51
51
|
return value ? luxon_1.DateTime.fromISO(value) : undefined;
|
|
52
52
|
}
|
|
53
53
|
return value ? luxon_1.DateTime.fromISO(value) : undefined;
|
|
54
|
-
}, [value, disableKeyboardInput, open]);
|
|
54
|
+
}, [value, disableKeyboardInput, setOnFinalChange, open]);
|
|
55
55
|
// eslint-disable-next-line sonarjs/rules-of-hooks
|
|
56
56
|
(0, react_1.useMemo)(() => {
|
|
57
57
|
if (!error && localError) {
|
|
@@ -152,11 +152,14 @@ function DatePicker({ setError, control, defaultValue, disabled = false, label,
|
|
|
152
152
|
leftArrowIcon: exports.LeftArrowIcon,
|
|
153
153
|
rightArrowIcon: exports.RightArrowIcon,
|
|
154
154
|
}, dayOfWeekFormatter: (weekday) => `${weekday.toFormat("ccc")}`, onAccept: (value, details) => {
|
|
155
|
-
if (
|
|
156
|
-
|
|
155
|
+
if (setOnFinalChange && value?.isValid) {
|
|
156
|
+
onChange(value.toISODate());
|
|
157
|
+
setLocalError(undefined);
|
|
157
158
|
}
|
|
159
|
+
restProps?.onAccept?.(value, details);
|
|
158
160
|
}, onChange: (value, details) => {
|
|
159
|
-
if (disableKeyboardInput && open) {
|
|
161
|
+
if ((disableKeyboardInput || setOnFinalChange) && open) {
|
|
162
|
+
// ✅ block only while popup open
|
|
160
163
|
return;
|
|
161
164
|
}
|
|
162
165
|
if (!value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1D,KAAK,YAAY,GAAG,iBAAiB,CAAC;IACpC,YAAY,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,eAAO,MAAM,OAAO,GAAI,wDAMrB,YAAY,4CA4Cd,CAAC"}
|
|
@@ -3,12 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Tooltip = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
|
+
const react_1 = require("react");
|
|
6
7
|
const Tooltip = ({ toolTipLabel, children, placement = "top-start", hidden = false, ...rest }) => {
|
|
7
|
-
|
|
8
|
+
const wrapperRef = (0, react_1.useRef)(null);
|
|
9
|
+
const [isOverflowed, setIsOverflowed] = (0, react_1.useState)(false);
|
|
10
|
+
// Tried Managing with useMemo but it didn't work as expected
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
if (wrapperRef.current) {
|
|
13
|
+
const el = wrapperRef.current;
|
|
14
|
+
setIsOverflowed(el.scrollWidth > el.clientWidth || el.scrollHeight > el.clientHeight);
|
|
15
|
+
}
|
|
16
|
+
}, [children]);
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { arrow: true, placement: placement, title: isOverflowed ? toolTipLabel : "", disableHoverListener: !isOverflowed || hidden, ...rest, children: (0, jsx_runtime_1.jsx)(material_1.Box, { ref: wrapperRef, sx: {
|
|
8
18
|
maxWidth: "150px",
|
|
9
19
|
overflow: "hidden",
|
|
10
20
|
textOverflow: "ellipsis",
|
|
11
21
|
whiteSpace: "nowrap",
|
|
12
|
-
|
|
22
|
+
display: "inline-flex",
|
|
23
|
+
}, children: typeof children === "string" ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", fontWeight: 500, children: children })) : (children) }) }));
|
|
13
24
|
};
|
|
14
25
|
exports.Tooltip = Tooltip;
|