lecom-ui 2.5.1 → 2.5.3
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/dist/components/Notification/Notification.js +2 -2
- package/dist/components/Notification/NotificationBase.js +1 -0
- package/dist/components/Notification/NotificationCallout.js +10 -10
- package/dist/components/Notification/NotificationContent.js +2 -2
- package/dist/components/Notification/NotificationIcon.js +1 -0
- package/dist/components/Notification/NotificationInline.js +2 -2
- package/dist/components/Notification/NotificationToast.js +10 -10
- package/dist/components/Notification/useNotificationToast.js +3 -3
- package/dist/index.d.ts +7 -8
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../lib/utils.js';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import { NotificationCallout } from './NotificationCallout.js';
|
|
@@ -52,7 +52,7 @@ const getPositionClass = (type, placement = "topRight") => {
|
|
|
52
52
|
}
|
|
53
53
|
return "";
|
|
54
54
|
};
|
|
55
|
-
const Notification = forwardRef(
|
|
55
|
+
const Notification = React.forwardRef(
|
|
56
56
|
({ ...props }, ref) => {
|
|
57
57
|
const { type, placement } = props;
|
|
58
58
|
const { shouldExpand } = props;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../lib/utils.js';
|
|
3
3
|
import { ChevronUpIcon } from 'lucide-react';
|
|
4
4
|
import { NotificationBase } from './NotificationBase.js';
|
|
@@ -6,13 +6,13 @@ import { NotificationContent } from './NotificationContent.js';
|
|
|
6
6
|
import { NotificationIcon } from './NotificationIcon.js';
|
|
7
7
|
|
|
8
8
|
const NotificationCallout = ({ ...props }) => {
|
|
9
|
-
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
10
|
-
const [shouldCollapse, setShouldCollapse] = useState(false);
|
|
11
|
-
const [contentHeight, setContentHeight] = useState(0);
|
|
12
|
-
const [lineHeight, setLineHeight] = useState(0);
|
|
13
|
-
const refCollapse = useRef(null);
|
|
14
|
-
const contentRef = useRef(null);
|
|
15
|
-
useEffect(() => {
|
|
9
|
+
const [isCollapsed, setIsCollapsed] = React.useState(false);
|
|
10
|
+
const [shouldCollapse, setShouldCollapse] = React.useState(false);
|
|
11
|
+
const [contentHeight, setContentHeight] = React.useState(0);
|
|
12
|
+
const [lineHeight, setLineHeight] = React.useState(0);
|
|
13
|
+
const refCollapse = React.useRef(null);
|
|
14
|
+
const contentRef = React.useRef(null);
|
|
15
|
+
React.useEffect(() => {
|
|
16
16
|
if (contentRef.current) {
|
|
17
17
|
const computedStyle = window.getComputedStyle(contentRef.current);
|
|
18
18
|
const lineHeight2 = parseFloat(computedStyle.lineHeight);
|
|
@@ -20,11 +20,11 @@ const NotificationCallout = ({ ...props }) => {
|
|
|
20
20
|
setContentHeight(contentRef.current.scrollHeight);
|
|
21
21
|
}
|
|
22
22
|
}, [props.content]);
|
|
23
|
-
useEffect(() => {
|
|
23
|
+
React.useEffect(() => {
|
|
24
24
|
const shouldCollapse2 = contentHeight > lineHeight * (props.action ? 3 : 2);
|
|
25
25
|
setShouldCollapse(shouldCollapse2);
|
|
26
26
|
}, [contentHeight, lineHeight]);
|
|
27
|
-
useEffect(() => {
|
|
27
|
+
React.useEffect(() => {
|
|
28
28
|
if (isCollapsed) {
|
|
29
29
|
refCollapse.current?.style.setProperty("transform", "rotate(180deg)");
|
|
30
30
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { Typography } from '../Typography/Typography.js';
|
|
3
3
|
|
|
4
|
-
const NotificationContent = forwardRef(({ title, content, className, children }, ref) => /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-0.5 flex-1" }, title && /* @__PURE__ */ React.createElement(
|
|
4
|
+
const NotificationContent = React.forwardRef(({ title, content, className, children }, ref) => /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-0.5 flex-1" }, title && /* @__PURE__ */ React.createElement(
|
|
5
5
|
Typography,
|
|
6
6
|
{
|
|
7
7
|
variant: "body-medium-500",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../lib/utils.js';
|
|
3
3
|
import { NotificationBase } from './NotificationBase.js';
|
|
4
4
|
import { NotificationCloseButton } from './NotificationCloseButton.js';
|
|
@@ -13,7 +13,7 @@ const NotificationInline = ({
|
|
|
13
13
|
action,
|
|
14
14
|
shouldExpand
|
|
15
15
|
}) => {
|
|
16
|
-
const [isVisible, setIsVisible] = useState(true);
|
|
16
|
+
const [isVisible, setIsVisible] = React.useState(true);
|
|
17
17
|
if (!isVisible) return null;
|
|
18
18
|
const defaultVariant = variant ?? "information";
|
|
19
19
|
const getFullWidthColumns = () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { cn } from '../../lib/utils.js';
|
|
3
3
|
import { NotificationBase } from './NotificationBase.js';
|
|
4
4
|
import { NotificationCloseButton } from './NotificationCloseButton.js';
|
|
@@ -8,12 +8,12 @@ import { useNotificationToast, TOAST_REMOVE_DELAY } from './useNotificationToast
|
|
|
8
8
|
|
|
9
9
|
const NotificationToast = (props) => {
|
|
10
10
|
const { toasts, closeNotification, pauseNotification, resumeNotification } = useNotificationToast();
|
|
11
|
-
const [progressMap, setProgressMap] = useState({});
|
|
12
|
-
const progressMapRef = useRef({});
|
|
13
|
-
const isPausedMapRef = useRef({});
|
|
14
|
-
const remainingTimeMapRef = useRef({});
|
|
15
|
-
const lastUpdateMapRef = useRef({});
|
|
16
|
-
useEffect(() => {
|
|
11
|
+
const [progressMap, setProgressMap] = React.useState({});
|
|
12
|
+
const progressMapRef = React.useRef({});
|
|
13
|
+
const isPausedMapRef = React.useRef({});
|
|
14
|
+
const remainingTimeMapRef = React.useRef({});
|
|
15
|
+
const lastUpdateMapRef = React.useRef({});
|
|
16
|
+
React.useEffect(() => {
|
|
17
17
|
const now = Date.now();
|
|
18
18
|
const newProgress = { ...progressMapRef.current };
|
|
19
19
|
const newRemainingTime = { ...remainingTimeMapRef.current };
|
|
@@ -30,7 +30,7 @@ const NotificationToast = (props) => {
|
|
|
30
30
|
lastUpdateMapRef.current = newLastUpdate;
|
|
31
31
|
setProgressMap(newProgress);
|
|
32
32
|
}, [toasts]);
|
|
33
|
-
useEffect(() => {
|
|
33
|
+
React.useEffect(() => {
|
|
34
34
|
if (toasts.length === 0) return;
|
|
35
35
|
const interval = setInterval(() => {
|
|
36
36
|
const now = Date.now();
|
|
@@ -72,7 +72,7 @@ const NotificationToast = (props) => {
|
|
|
72
72
|
return "grid-cols-[1.25rem_minmax(_auto,13.25rem)]";
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
const colorMap = useMemo(
|
|
75
|
+
const colorMap = React.useMemo(
|
|
76
76
|
() => ({
|
|
77
77
|
information: "bg-blue-600",
|
|
78
78
|
success: "bg-green-600",
|
|
@@ -123,6 +123,6 @@ const NotificationToast = (props) => {
|
|
|
123
123
|
)));
|
|
124
124
|
};
|
|
125
125
|
NotificationToast.displayName = "NotificationToast";
|
|
126
|
-
const MemoizedNotificationToast = memo(NotificationToast);
|
|
126
|
+
const MemoizedNotificationToast = React.memo(NotificationToast);
|
|
127
127
|
|
|
128
128
|
export { MemoizedNotificationToast };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
const TOAST_LIMIT = Infinity;
|
|
4
4
|
const TOAST_REMOVE_DELAY = 5e3;
|
|
@@ -150,8 +150,8 @@ function toast({ ...props }) {
|
|
|
150
150
|
dispatch({ type: actionTypes.ADD_TOAST, toast: newToast });
|
|
151
151
|
}
|
|
152
152
|
function useNotificationToast() {
|
|
153
|
-
const [state, setState] =
|
|
154
|
-
|
|
153
|
+
const [state, setState] = React.useState(memoryState);
|
|
154
|
+
React.useEffect(() => {
|
|
155
155
|
const id = genId();
|
|
156
156
|
listeners[id] = setState;
|
|
157
157
|
return () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { ReactNode } from 'react';
|
|
4
3
|
import { VariantProps } from 'class-variance-authority';
|
|
5
4
|
import { ColumnDef } from '@tanstack/react-table';
|
|
6
5
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
@@ -357,7 +356,7 @@ declare const notificationVariants: (props?: ({
|
|
|
357
356
|
variant?: "error" | "success" | "information" | "warning" | null | undefined;
|
|
358
357
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
359
358
|
type BaseNotificationProps = VariantProps<typeof notificationVariants> & {
|
|
360
|
-
action?: ReactNode;
|
|
359
|
+
action?: React.ReactNode;
|
|
361
360
|
};
|
|
362
361
|
interface ToastNotificationProps extends BaseNotificationProps {
|
|
363
362
|
type: 'toast';
|
|
@@ -368,14 +367,14 @@ interface ToastNotificationProps extends BaseNotificationProps {
|
|
|
368
367
|
}
|
|
369
368
|
interface CalloutNotificationProps extends BaseNotificationProps {
|
|
370
369
|
type: 'callout';
|
|
371
|
-
title?: ReactNode;
|
|
372
|
-
content: ReactNode;
|
|
370
|
+
title?: React.ReactNode;
|
|
371
|
+
content: React.ReactNode;
|
|
373
372
|
shouldExpand?: boolean;
|
|
374
373
|
}
|
|
375
374
|
interface InlineNotificationProps extends BaseNotificationProps {
|
|
376
375
|
type: 'inline';
|
|
377
|
-
title?: ReactNode;
|
|
378
|
-
content: ReactNode;
|
|
376
|
+
title?: React.ReactNode;
|
|
377
|
+
content: React.ReactNode;
|
|
379
378
|
enableClose?: boolean;
|
|
380
379
|
shouldExpand?: boolean;
|
|
381
380
|
}
|
|
@@ -392,8 +391,8 @@ declare const Notification: React.ForwardRefExoticComponent<NotificationProps &
|
|
|
392
391
|
declare const TOAST_REMOVE_DELAY = 5000;
|
|
393
392
|
type ToasterToast = {
|
|
394
393
|
id: string;
|
|
395
|
-
title?:
|
|
396
|
-
content:
|
|
394
|
+
title?: React.ReactNode;
|
|
395
|
+
content: React.ReactNode;
|
|
397
396
|
variant: 'success' | 'error' | 'warning' | 'information';
|
|
398
397
|
toastLimit?: number;
|
|
399
398
|
open: boolean;
|