@sarunyu/system-one 4.5.2 → 4.6.0
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/AGENTS.md +25 -4
- package/DESIGN.md +1 -0
- package/dist/index.cjs +146 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -97
- package/dist/index.js.map +1 -1
- package/dist/src/components/badge.d.ts.map +1 -1
- package/dist/src/components/checkbox.d.ts +4 -0
- package/dist/src/components/checkbox.d.ts.map +1 -1
- package/dist/src/components/notification.d.ts +6 -1
- package/dist/src/components/notification.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/llms.txt +21 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import React__default, { forwardRef, useState, useRef, useEffect, useCallback, useId, useMemo, useLayoutEffect, useContext, createContext } from "react";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { twMerge } from "tailwind-merge";
|
|
7
|
-
import { BellSimple, FunnelSimple, CheckCircle, Warning, XCircle, Info, BookmarkSimpleIcon, BroadcastIcon as BroadcastIcon$1, CalendarBlank, MapPin, Users, Lock, Check, Plus, Circle, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, ImageSquare, MegaphoneSimple, GearSix, MagnifyingGlass, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
|
|
7
|
+
import { BellSimple, FunnelSimple, CheckCircle, Warning, XCircle, Info, BookmarkSimpleIcon, BroadcastIcon as BroadcastIcon$1, CalendarBlank, MapPin, Users, Lock, Check, Plus, Circle, Minus, CaretLeft, CaretRight, CaretDoubleLeft, CaretDoubleRight, CaretUp, CaretDown, X, ImageSquare, Gift, MegaphoneSimple, GearSix, MagnifyingGlass, ArrowUp, ArrowDown, ArrowsDownUp, Clock } from "@phosphor-icons/react";
|
|
8
8
|
import { DayPicker, useNavigation } from "react-day-picker";
|
|
9
9
|
import * as Popover from "@radix-ui/react-popover";
|
|
10
10
|
import { Drawer as Drawer$1 } from "vaul";
|
|
@@ -244,11 +244,10 @@ function Badge({
|
|
|
244
244
|
...props
|
|
245
245
|
}) {
|
|
246
246
|
const hasCount = count > 0;
|
|
247
|
-
const isActive = hasCount;
|
|
248
247
|
const resolvedNotificationState = notificationState ?? (hasCount ? "noti" : "default");
|
|
249
248
|
const notificationIsFilled = resolvedNotificationState === "active" || resolvedNotificationState === "noti";
|
|
250
249
|
const showNotificationDot = resolvedNotificationState === "noti" && hasCount;
|
|
251
|
-
const visualIcon = variant === "notification" ?
|
|
250
|
+
const visualIcon = variant === "notification" ? /* @__PURE__ */ jsx(BellSimple, { size: 18, weight: notificationIsFilled ? "fill" : "regular" }) : icon ?? /* @__PURE__ */ jsx(FunnelSimple, { size: 18, weight: "regular" });
|
|
252
251
|
return /* @__PURE__ */ jsxs("div", { className: cn("relative inline-flex", className), children: [
|
|
253
252
|
variant === "notification" ? /* @__PURE__ */ jsx(
|
|
254
253
|
Button,
|
|
@@ -256,10 +255,7 @@ function Badge({
|
|
|
256
255
|
"aria-label": "Notification",
|
|
257
256
|
size: "icon-xs",
|
|
258
257
|
variant: "plain-black",
|
|
259
|
-
className:
|
|
260
|
-
"text-subtle-text",
|
|
261
|
-
notificationIsFilled && "text-primary-action"
|
|
262
|
-
),
|
|
258
|
+
className: "text-icon-brand [&>span]:!h-[18px] [&>span]:!w-[18px]",
|
|
263
259
|
...props,
|
|
264
260
|
children: visualIcon
|
|
265
261
|
}
|
|
@@ -268,8 +264,8 @@ function Badge({
|
|
|
268
264
|
{
|
|
269
265
|
"aria-label": label,
|
|
270
266
|
size: "icon-md",
|
|
271
|
-
variant:
|
|
272
|
-
className: cn(
|
|
267
|
+
variant: hasCount ? "outline" : "outline-black",
|
|
268
|
+
className: cn(hasCount && "bg-primary-action-light border-primary-action-light"),
|
|
273
269
|
...props,
|
|
274
270
|
children: visualIcon
|
|
275
271
|
}
|
|
@@ -278,8 +274,8 @@ function Badge({
|
|
|
278
274
|
{
|
|
279
275
|
size: "md",
|
|
280
276
|
leftIcon: visualIcon,
|
|
281
|
-
variant:
|
|
282
|
-
className: cn(
|
|
277
|
+
variant: hasCount ? "outline" : "outline-black",
|
|
278
|
+
className: cn(hasCount && "bg-primary-action-light border-primary-action-light"),
|
|
283
279
|
...props,
|
|
284
280
|
children: label
|
|
285
281
|
}
|
|
@@ -288,10 +284,10 @@ function Badge({
|
|
|
288
284
|
"div",
|
|
289
285
|
{
|
|
290
286
|
className: cn(
|
|
291
|
-
"absolute flex items-center justify-center rounded-[60px]
|
|
292
|
-
variant === "notification" ? "-right-0.5 -top-0.5
|
|
287
|
+
"absolute flex h-[14px] min-h-[14px] min-w-[14px] items-center justify-center rounded-[60px]",
|
|
288
|
+
variant === "notification" ? "-right-0.5 -top-0.5 bg-destructive px-[2.5px]" : "-right-1 -top-[7px] h-4 min-w-4 bg-primary-action"
|
|
293
289
|
),
|
|
294
|
-
children: /* @__PURE__ */ jsx("p", { className: "text-center text-xs leading-4 text-
|
|
290
|
+
children: /* @__PURE__ */ jsx("p", { className: "text-center text-xs leading-4 font-normal text-text-default-white", children: formatCount(count, maxCount) })
|
|
295
291
|
}
|
|
296
292
|
)
|
|
297
293
|
] });
|
|
@@ -972,7 +968,8 @@ function NewsContent({
|
|
|
972
968
|
}
|
|
973
969
|
function CheckboxVisual({
|
|
974
970
|
state,
|
|
975
|
-
disabled
|
|
971
|
+
disabled,
|
|
972
|
+
error
|
|
976
973
|
}) {
|
|
977
974
|
if (state === "default") {
|
|
978
975
|
return /* @__PURE__ */ jsx(
|
|
@@ -981,12 +978,12 @@ function CheckboxVisual({
|
|
|
981
978
|
"aria-hidden": "true",
|
|
982
979
|
className: cn(
|
|
983
980
|
"block w-4 h-4 rounded-[2px] border-[1.5px]",
|
|
984
|
-
disabled ? "bg-disabled-bg border-[var(--fill-black-100)]" : "bg-background border-[var(--fill-black-200)]"
|
|
981
|
+
disabled ? "bg-disabled-bg border-[var(--fill-black-100)]" : error ? "bg-background border-destructive" : "bg-background border-[var(--fill-black-200)]"
|
|
985
982
|
)
|
|
986
983
|
}
|
|
987
984
|
);
|
|
988
985
|
}
|
|
989
|
-
const containerFill = disabled ? "var(--
|
|
986
|
+
const containerFill = disabled ? "var(--disabled-bg)" : "var(--fill-p1-600)";
|
|
990
987
|
const iconFill = disabled ? "var(--fill-gray-400)" : "var(--fill-white-1000)";
|
|
991
988
|
if (state === "checked") {
|
|
992
989
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1048,6 +1045,8 @@ function CheckboxVisual({
|
|
|
1048
1045
|
const Checkbox = forwardRef(function Checkbox2({
|
|
1049
1046
|
checked = false,
|
|
1050
1047
|
disabled = false,
|
|
1048
|
+
error = false,
|
|
1049
|
+
errorMessage = "Error message",
|
|
1051
1050
|
label,
|
|
1052
1051
|
description,
|
|
1053
1052
|
variant = "text",
|
|
@@ -1079,59 +1078,72 @@ const Checkbox = forwardRef(function Checkbox2({
|
|
|
1079
1078
|
const hasText = label !== void 0 || description !== void 0;
|
|
1080
1079
|
const hasActiveBorder = state === "checked" || state === "indeterminate";
|
|
1081
1080
|
const isButton = variant === "button";
|
|
1082
|
-
const buttonBorder = disabled ? "border-[var(--fill-black-100)]" : hasActiveBorder ? "border-primary-action" : "border-[var(--fill-black-200)]";
|
|
1081
|
+
const buttonBorder = disabled ? "border-[var(--fill-black-100)]" : error ? "border-destructive" : hasActiveBorder ? "border-primary-action" : "border-[var(--fill-black-200)]";
|
|
1082
|
+
const showError = error && !disabled;
|
|
1083
1083
|
return /* @__PURE__ */ jsxs(
|
|
1084
1084
|
"label",
|
|
1085
1085
|
{
|
|
1086
1086
|
className: cn(
|
|
1087
|
-
"
|
|
1088
|
-
description ? "items-start" : "items-center",
|
|
1087
|
+
"flex flex-col select-none",
|
|
1089
1088
|
disabled ? "cursor-not-allowed" : "cursor-pointer",
|
|
1090
|
-
isButton && cn("bg-background rounded-lg border py-2.5 pl-3 pr-4", buttonBorder),
|
|
1091
1089
|
className
|
|
1092
1090
|
),
|
|
1093
1091
|
children: [
|
|
1094
|
-
/* @__PURE__ */ jsxs(
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1092
|
+
/* @__PURE__ */ jsxs(
|
|
1093
|
+
"span",
|
|
1094
|
+
{
|
|
1095
|
+
className: cn(
|
|
1096
|
+
"inline-flex gap-1",
|
|
1097
|
+
description ? "items-start" : "items-center",
|
|
1098
|
+
isButton && cn("bg-background rounded-lg border py-2.5 pl-3 pr-4", buttonBorder)
|
|
1099
|
+
),
|
|
1100
|
+
children: [
|
|
1101
|
+
/* @__PURE__ */ jsxs("span", { className: "relative inline-flex items-center justify-center w-6 h-6 shrink-0", children: [
|
|
1102
|
+
/* @__PURE__ */ jsx(
|
|
1103
|
+
"input",
|
|
1104
|
+
{
|
|
1105
|
+
ref: setRefs,
|
|
1106
|
+
id,
|
|
1107
|
+
name,
|
|
1108
|
+
value,
|
|
1109
|
+
type: "checkbox",
|
|
1110
|
+
checked: checked === true,
|
|
1111
|
+
disabled,
|
|
1112
|
+
onChange: handleChange,
|
|
1113
|
+
"aria-label": ariaLabel,
|
|
1114
|
+
"aria-checked": checked === "indeterminate" ? "mixed" : checked,
|
|
1115
|
+
"aria-invalid": showError || void 0,
|
|
1116
|
+
className: "absolute inset-0 w-full h-full opacity-0 m-0 cursor-[inherit] disabled:cursor-[inherit]"
|
|
1117
|
+
}
|
|
1118
|
+
),
|
|
1119
|
+
/* @__PURE__ */ jsx(CheckboxVisual, { state, disabled, error: showError })
|
|
1120
|
+
] }),
|
|
1121
|
+
hasText && /* @__PURE__ */ jsxs("span", { className: "flex flex-col", children: [
|
|
1122
|
+
label !== void 0 && /* @__PURE__ */ jsx(
|
|
1123
|
+
"span",
|
|
1124
|
+
{
|
|
1125
|
+
className: cn(
|
|
1126
|
+
"text-base leading-6",
|
|
1127
|
+
disabled ? "text-disabled" : "text-foreground"
|
|
1128
|
+
),
|
|
1129
|
+
children: label
|
|
1130
|
+
}
|
|
1131
|
+
),
|
|
1132
|
+
description !== void 0 && /* @__PURE__ */ jsx(
|
|
1133
|
+
"span",
|
|
1134
|
+
{
|
|
1135
|
+
className: cn(
|
|
1136
|
+
"text-xs leading-4",
|
|
1137
|
+
disabled ? "text-disabled" : "text-subtle-text"
|
|
1138
|
+
),
|
|
1139
|
+
children: description
|
|
1140
|
+
}
|
|
1141
|
+
)
|
|
1142
|
+
] })
|
|
1143
|
+
]
|
|
1144
|
+
}
|
|
1145
|
+
),
|
|
1146
|
+
showError && /* @__PURE__ */ jsx("span", { className: "mt-1 ml-7 text-xs text-destructive", children: errorMessage })
|
|
1135
1147
|
]
|
|
1136
1148
|
}
|
|
1137
1149
|
);
|
|
@@ -3649,7 +3661,7 @@ const Input = forwardRef(function Input2({
|
|
|
3649
3661
|
Input.displayName = "Input";
|
|
3650
3662
|
const ALERT_CONFIG = {
|
|
3651
3663
|
warning: {
|
|
3652
|
-
titleColor: "var(--
|
|
3664
|
+
titleColor: "var(--text-warning-primary)",
|
|
3653
3665
|
background: "https://www.figma.com/api/mcp/asset/f4ca68ad-5732-4124-9ff4-cfb69330cc02",
|
|
3654
3666
|
layers: [
|
|
3655
3667
|
{
|
|
@@ -3667,7 +3679,7 @@ const ALERT_CONFIG = {
|
|
|
3667
3679
|
]
|
|
3668
3680
|
},
|
|
3669
3681
|
success: {
|
|
3670
|
-
titleColor: "var(--success)",
|
|
3682
|
+
titleColor: "var(--text-success-primary)",
|
|
3671
3683
|
background: "https://www.figma.com/api/mcp/asset/2a865e6f-8a92-4496-88b5-71ac99e2c385",
|
|
3672
3684
|
layers: [
|
|
3673
3685
|
{
|
|
@@ -3681,7 +3693,7 @@ const ALERT_CONFIG = {
|
|
|
3681
3693
|
]
|
|
3682
3694
|
},
|
|
3683
3695
|
danger: {
|
|
3684
|
-
titleColor: "var(--
|
|
3696
|
+
titleColor: "var(--text-danger-primary)",
|
|
3685
3697
|
background: "https://www.figma.com/api/mcp/asset/c7a65595-684e-4a04-b7fd-d443951f680a",
|
|
3686
3698
|
layers: [
|
|
3687
3699
|
{
|
|
@@ -3866,18 +3878,19 @@ function NotificationDivider({ label }) {
|
|
|
3866
3878
|
}
|
|
3867
3879
|
function NotificationRow({
|
|
3868
3880
|
item,
|
|
3869
|
-
onItemClick
|
|
3881
|
+
onItemClick,
|
|
3882
|
+
hideIndicator = false,
|
|
3883
|
+
demoteNewBackground = false
|
|
3870
3884
|
}) {
|
|
3871
3885
|
const rowType = item.type ?? "icon";
|
|
3872
3886
|
const showImage = rowType === "image";
|
|
3873
|
-
const
|
|
3887
|
+
const status = item.status ?? (item.unread ? "unread" : "read");
|
|
3888
|
+
const showIndicator = (status === "new" || status === "unread") && !hideIndicator;
|
|
3889
|
+
const rowBackground = status === "new" && !demoteNewBackground ? "bg-muted" : "bg-background";
|
|
3874
3890
|
return /* @__PURE__ */ jsxs(
|
|
3875
3891
|
"div",
|
|
3876
3892
|
{
|
|
3877
|
-
className: cn(
|
|
3878
|
-
"flex w-full items-start gap-3 px-4 py-3",
|
|
3879
|
-
showUnread ? "bg-primary-action-light/40" : "bg-background"
|
|
3880
|
-
),
|
|
3893
|
+
className: cn("flex w-full items-start gap-3 px-4 py-3", rowBackground),
|
|
3881
3894
|
role: "button",
|
|
3882
3895
|
tabIndex: 0,
|
|
3883
3896
|
onClick: () => onItemClick == null ? void 0 : onItemClick(item),
|
|
@@ -3895,22 +3908,11 @@ function NotificationRow({
|
|
|
3895
3908
|
className: "h-10 w-10 rounded object-cover",
|
|
3896
3909
|
src: item.imageSrc
|
|
3897
3910
|
}
|
|
3898
|
-
) : /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded bg-disabled-bg text-disabled", children: /* @__PURE__ */ jsx(ImageSquare, { size: 20, weight: "regular" }) }) : /* @__PURE__ */ jsx("div", { className: "flex h-6 w-6 items-center justify-center text-subtle-text", children: item.icon ?? /* @__PURE__ */ jsx(
|
|
3899
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3900
|
-
/* @__PURE__ */
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
showUnread && /* @__PURE__ */ jsx(
|
|
3904
|
-
"span",
|
|
3905
|
-
{
|
|
3906
|
-
"aria-hidden": "true",
|
|
3907
|
-
className: "h-2 w-2 rounded-full bg-primary-action"
|
|
3908
|
-
}
|
|
3909
|
-
),
|
|
3910
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs leading-4 text-muted-foreground", children: item.time })
|
|
3911
|
-
] }),
|
|
3912
|
-
/* @__PURE__ */ jsx("p", { className: "col-start-1 mt-1 line-clamp-2 text-sm leading-5 text-muted-foreground", children: item.description })
|
|
3913
|
-
] }),
|
|
3911
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded bg-disabled-bg text-disabled", children: /* @__PURE__ */ jsx(ImageSquare, { size: 20, weight: "regular" }) }) : /* @__PURE__ */ jsx("div", { className: "flex h-6 w-6 items-center justify-center text-subtle-text", children: item.icon ?? /* @__PURE__ */ jsx(Gift, { size: 20, weight: "regular" }) }) }),
|
|
3912
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
3913
|
+
/* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-base leading-6 font-semibold text-foreground", children: item.title }),
|
|
3914
|
+
/* @__PURE__ */ jsx("p", { className: "line-clamp-3 text-sm leading-5 text-muted-foreground", children: item.description }),
|
|
3915
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs leading-4 text-muted-foreground", children: item.time }),
|
|
3914
3916
|
item.actionLabel && /* @__PURE__ */ jsx(
|
|
3915
3917
|
Button,
|
|
3916
3918
|
{
|
|
@@ -3925,7 +3927,14 @@ function NotificationRow({
|
|
|
3925
3927
|
children: item.actionLabel
|
|
3926
3928
|
}
|
|
3927
3929
|
)
|
|
3928
|
-
] })
|
|
3930
|
+
] }),
|
|
3931
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-2 shrink-0 items-start justify-center pt-2", children: showIndicator ? /* @__PURE__ */ jsx(
|
|
3932
|
+
"span",
|
|
3933
|
+
{
|
|
3934
|
+
"aria-hidden": "true",
|
|
3935
|
+
className: "h-2 w-2 rounded-full bg-destructive"
|
|
3936
|
+
}
|
|
3937
|
+
) : null })
|
|
3929
3938
|
]
|
|
3930
3939
|
}
|
|
3931
3940
|
);
|
|
@@ -3936,6 +3945,7 @@ const Notification = forwardRef(
|
|
|
3936
3945
|
badgeCount,
|
|
3937
3946
|
panelWidth = 375,
|
|
3938
3947
|
emptyText = "No notifications",
|
|
3948
|
+
showGroupLabels = true,
|
|
3939
3949
|
clearBadgeOnOpen = true,
|
|
3940
3950
|
open,
|
|
3941
3951
|
defaultOpen,
|
|
@@ -3947,16 +3957,23 @@ const Notification = forwardRef(
|
|
|
3947
3957
|
}, ref) {
|
|
3948
3958
|
const [internalOpen, setInternalOpen] = useState(defaultOpen ?? false);
|
|
3949
3959
|
const [isBadgeCleared, setIsBadgeCleared] = useState(false);
|
|
3960
|
+
const [clickedItemIds, setClickedItemIds] = useState(/* @__PURE__ */ new Set());
|
|
3961
|
+
const [wasDismissed, setWasDismissed] = useState(false);
|
|
3962
|
+
const [mobileAlign, setMobileAlign] = useState(null);
|
|
3963
|
+
const triggerRef = useRef(null);
|
|
3950
3964
|
const controlled = open !== void 0;
|
|
3951
3965
|
const resolvedOpen = controlled ? open : internalOpen;
|
|
3952
|
-
const
|
|
3966
|
+
const newCount = useMemo(
|
|
3953
3967
|
() => groups.reduce(
|
|
3954
|
-
(acc, group) => acc + group.items.filter((item) =>
|
|
3968
|
+
(acc, group) => acc + group.items.filter((item) => {
|
|
3969
|
+
const status = item.status ?? (item.unread ? "unread" : "read");
|
|
3970
|
+
return status === "new";
|
|
3971
|
+
}).length,
|
|
3955
3972
|
0
|
|
3956
3973
|
),
|
|
3957
3974
|
[groups]
|
|
3958
3975
|
);
|
|
3959
|
-
const nextCount = badgeCount ??
|
|
3976
|
+
const nextCount = badgeCount ?? newCount;
|
|
3960
3977
|
const prevCountRef = useRef(nextCount);
|
|
3961
3978
|
useEffect(() => {
|
|
3962
3979
|
const prevCount = prevCountRef.current;
|
|
@@ -3965,9 +3982,29 @@ const Notification = forwardRef(
|
|
|
3965
3982
|
}
|
|
3966
3983
|
prevCountRef.current = nextCount;
|
|
3967
3984
|
}, [nextCount]);
|
|
3985
|
+
useEffect(() => {
|
|
3986
|
+
const update = () => {
|
|
3987
|
+
if (window.innerWidth > 640 || !triggerRef.current) {
|
|
3988
|
+
setMobileAlign(null);
|
|
3989
|
+
return;
|
|
3990
|
+
}
|
|
3991
|
+
const contentWidth = Math.min(panelWidth, window.innerWidth - 32);
|
|
3992
|
+
const triggerLeft = triggerRef.current.getBoundingClientRect().left;
|
|
3993
|
+
setMobileAlign({
|
|
3994
|
+
alignOffset: (window.innerWidth - contentWidth) / 2 - triggerLeft,
|
|
3995
|
+
width: contentWidth
|
|
3996
|
+
});
|
|
3997
|
+
};
|
|
3998
|
+
update();
|
|
3999
|
+
window.addEventListener("resize", update);
|
|
4000
|
+
return () => window.removeEventListener("resize", update);
|
|
4001
|
+
}, [panelWidth]);
|
|
3968
4002
|
const displayCount = clearBadgeOnOpen && isBadgeCleared ? 0 : nextCount;
|
|
3969
4003
|
const hasItems = groups.some((group) => group.items.length > 0);
|
|
3970
4004
|
const handleOpenChange = (next) => {
|
|
4005
|
+
if (resolvedOpen && !next) {
|
|
4006
|
+
setWasDismissed(true);
|
|
4007
|
+
}
|
|
3971
4008
|
if (next && clearBadgeOnOpen && nextCount > 0) {
|
|
3972
4009
|
setIsBadgeCleared(true);
|
|
3973
4010
|
onBadgeCleared == null ? void 0 : onBadgeCleared();
|
|
@@ -3975,8 +4012,17 @@ const Notification = forwardRef(
|
|
|
3975
4012
|
if (!controlled) setInternalOpen(next);
|
|
3976
4013
|
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
3977
4014
|
};
|
|
4015
|
+
const handleItemClick = (item) => {
|
|
4016
|
+
setClickedItemIds((prev) => {
|
|
4017
|
+
if (prev.has(item.id)) return prev;
|
|
4018
|
+
const next = new Set(prev);
|
|
4019
|
+
next.add(item.id);
|
|
4020
|
+
return next;
|
|
4021
|
+
});
|
|
4022
|
+
onItemClick == null ? void 0 : onItemClick(item);
|
|
4023
|
+
};
|
|
3978
4024
|
return /* @__PURE__ */ jsxs(Popover.Root, { open: resolvedOpen, onOpenChange: handleOpenChange, children: [
|
|
3979
|
-
/* @__PURE__ */ jsx("div", { ref, className: cn("inline-flex", className), children: /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsx(
|
|
4025
|
+
/* @__PURE__ */ jsx("div", { ref, className: cn("inline-flex", className), children: /* @__PURE__ */ jsx(Popover.Trigger, { asChild: true, children: /* @__PURE__ */ jsx("div", { ref: triggerRef, className: "relative", children: /* @__PURE__ */ jsx(
|
|
3980
4026
|
Badge,
|
|
3981
4027
|
{
|
|
3982
4028
|
variant: "notification",
|
|
@@ -3989,22 +4035,26 @@ const Notification = forwardRef(
|
|
|
3989
4035
|
/* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
|
|
3990
4036
|
Popover.Content,
|
|
3991
4037
|
{
|
|
3992
|
-
align: "end",
|
|
4038
|
+
align: mobileAlign ? "start" : "end",
|
|
4039
|
+
alignOffset: (mobileAlign == null ? void 0 : mobileAlign.alignOffset) ?? 0,
|
|
4040
|
+
avoidCollisions: !mobileAlign,
|
|
3993
4041
|
sideOffset: 10,
|
|
3994
4042
|
className: cn(
|
|
3995
4043
|
"z-50 overflow-hidden rounded-lg border border-border bg-background shadow-lg",
|
|
3996
4044
|
panelClassName
|
|
3997
4045
|
),
|
|
3998
|
-
style: { width: panelWidth },
|
|
3999
|
-
children: /* @__PURE__ */ jsxs("div", { className: "max-h-[480px] overflow-y-auto
|
|
4046
|
+
style: { width: (mobileAlign == null ? void 0 : mobileAlign.width) ?? panelWidth },
|
|
4047
|
+
children: /* @__PURE__ */ jsxs("div", { className: "max-h-[480px] overflow-y-auto", children: [
|
|
4000
4048
|
!hasItems && /* @__PURE__ */ jsx("div", { className: "px-4 py-8 text-center text-sm text-muted-foreground", children: emptyText }),
|
|
4001
4049
|
groups.map((group) => /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4002
|
-
/* @__PURE__ */ jsx(NotificationDivider, { label: group.label }),
|
|
4050
|
+
showGroupLabels && group.label ? /* @__PURE__ */ jsx(NotificationDivider, { label: group.label }) : null,
|
|
4003
4051
|
/* @__PURE__ */ jsx("div", { className: "divide-y divide-divider", children: group.items.map((item) => /* @__PURE__ */ jsx(
|
|
4004
4052
|
NotificationRow,
|
|
4005
4053
|
{
|
|
4006
4054
|
item,
|
|
4007
|
-
onItemClick
|
|
4055
|
+
onItemClick: handleItemClick,
|
|
4056
|
+
hideIndicator: clickedItemIds.has(item.id),
|
|
4057
|
+
demoteNewBackground: wasDismissed
|
|
4008
4058
|
},
|
|
4009
4059
|
item.id
|
|
4010
4060
|
)) })
|