lecom-ui 4.5.7 → 4.5.9
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.
|
@@ -6,13 +6,14 @@ import { NotificationContent } from './NotificationContent.js';
|
|
|
6
6
|
import { NotificationIcon } from './NotificationIcon.js';
|
|
7
7
|
|
|
8
8
|
const NotificationCallout = ({ ...props }) => {
|
|
9
|
-
const defaultCollapsed = props.
|
|
9
|
+
const defaultCollapsed = props.defaultCollapsed ?? false;
|
|
10
10
|
const [isCollapsed, setIsCollapsed] = React.useState(defaultCollapsed);
|
|
11
11
|
const [shouldCollapse, setShouldCollapse] = React.useState(false);
|
|
12
12
|
const [contentHeight, setContentHeight] = React.useState(0);
|
|
13
13
|
const [lineHeight, setLineHeight] = React.useState(0);
|
|
14
14
|
const refCollapse = React.useRef(null);
|
|
15
15
|
const contentRef = React.useRef(null);
|
|
16
|
+
const getIsCollapsed = () => props.isCollapsed !== void 0 ? props.isCollapsed : isCollapsed;
|
|
16
17
|
React.useEffect(() => {
|
|
17
18
|
if (contentRef.current) {
|
|
18
19
|
const computedStyle = window.getComputedStyle(contentRef.current);
|
|
@@ -32,7 +33,13 @@ const NotificationCallout = ({ ...props }) => {
|
|
|
32
33
|
refCollapse.current?.style.setProperty("transform", "rotate(0deg)");
|
|
33
34
|
}
|
|
34
35
|
}, [isCollapsed]);
|
|
35
|
-
const handleCollapse = () =>
|
|
36
|
+
const handleCollapse = () => {
|
|
37
|
+
if (props.onCollapseChange) {
|
|
38
|
+
props.onCollapseChange(!isCollapsed);
|
|
39
|
+
} else {
|
|
40
|
+
setIsCollapsed(!isCollapsed);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
36
43
|
const defaultVariant = props.variant ?? "information";
|
|
37
44
|
const getGridColumns = () => {
|
|
38
45
|
if (props.fullWidth) {
|
|
@@ -42,16 +49,16 @@ const NotificationCallout = ({ ...props }) => {
|
|
|
42
49
|
}
|
|
43
50
|
};
|
|
44
51
|
const getCollapseClass = () => {
|
|
45
|
-
if (
|
|
52
|
+
if (getIsCollapsed() && !props.title)
|
|
46
53
|
return "max-h-6 overflow-hidden line-clamp-1";
|
|
47
|
-
if (
|
|
54
|
+
if (getIsCollapsed() && props.title) return "max-h-0 overflow-hidden";
|
|
48
55
|
return "no-collapse";
|
|
49
56
|
};
|
|
50
57
|
return /* @__PURE__ */ React.createElement(
|
|
51
58
|
NotificationBase,
|
|
52
59
|
{
|
|
53
60
|
variant: defaultVariant,
|
|
54
|
-
className: cn(getGridColumns(),
|
|
61
|
+
className: cn(getGridColumns(), getIsCollapsed() && "place-items-center"),
|
|
55
62
|
dataTestId: "notification-callout"
|
|
56
63
|
},
|
|
57
64
|
/* @__PURE__ */ React.createElement(NotificationIcon, { variant: defaultVariant }),
|
|
@@ -63,7 +70,7 @@ const NotificationCallout = ({ ...props }) => {
|
|
|
63
70
|
ref: contentRef,
|
|
64
71
|
className: cn(
|
|
65
72
|
"transition-all duration-300",
|
|
66
|
-
|
|
73
|
+
getIsCollapsed() && getCollapseClass()
|
|
67
74
|
)
|
|
68
75
|
}
|
|
69
76
|
), props.action),
|
|
@@ -11,7 +11,8 @@ const Upload = ({
|
|
|
11
11
|
onFilesSelected,
|
|
12
12
|
className,
|
|
13
13
|
accept,
|
|
14
|
-
multiple
|
|
14
|
+
multiple,
|
|
15
|
+
id
|
|
15
16
|
}) => {
|
|
16
17
|
const [files, setFiles] = React.useState([]);
|
|
17
18
|
const { t } = useTranslation();
|
|
@@ -100,7 +101,7 @@ const Upload = ({
|
|
|
100
101
|
{
|
|
101
102
|
type: "file",
|
|
102
103
|
hidden: true,
|
|
103
|
-
id
|
|
104
|
+
id,
|
|
104
105
|
onChange: handleFileChange,
|
|
105
106
|
accept: accept || "*",
|
|
106
107
|
multiple: !!multiple
|
package/dist/index.d.ts
CHANGED
|
@@ -605,6 +605,8 @@ interface CalloutNotificationProps extends BaseNotificationProps {
|
|
|
605
605
|
fullWidth?: boolean;
|
|
606
606
|
isCollapsed?: boolean;
|
|
607
607
|
action?: React$1.ReactNode;
|
|
608
|
+
defaultCollapsed?: boolean;
|
|
609
|
+
onCollapseChange?: (collapse: boolean) => void;
|
|
608
610
|
}
|
|
609
611
|
interface InlineNotificationProps extends BaseNotificationProps {
|
|
610
612
|
type: 'inline';
|
|
@@ -756,9 +758,10 @@ interface UploadProps {
|
|
|
756
758
|
className?: string;
|
|
757
759
|
accept?: string;
|
|
758
760
|
multiple?: boolean;
|
|
761
|
+
id?: string;
|
|
759
762
|
}
|
|
760
763
|
declare const Upload: {
|
|
761
|
-
({ onFilesSelected, className, accept, multiple, }: UploadProps): React$1.JSX.Element;
|
|
764
|
+
({ onFilesSelected, className, accept, multiple, id, }: UploadProps): React$1.JSX.Element;
|
|
762
765
|
displayName: string;
|
|
763
766
|
};
|
|
764
767
|
|