@neasg/design-system 0.4.28 → 0.4.30

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.
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ export interface AlertStackProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ children: React.ReactNode;
4
+ }
5
+ declare const AlertStack: React.ForwardRefExoticComponent<AlertStackProps & React.RefAttributes<HTMLDivElement>>;
6
+ export { AlertStack };
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { AnimatePresence, MotionConfig, motion } from "motion/react";
4
+ import { cn } from "./lib/utils";
5
+ const MAX_VISIBLE_ALERTS = 3;
6
+ const stackItemClasses = [
7
+ "z-50",
8
+ "pointer-events-none z-40 mx-1",
9
+ "pointer-events-none z-30 mx-2",
10
+ ];
11
+ const stackPaddingClasses = ["", "", "pb-2", "pb-4"];
12
+ const AlertStack = React.forwardRef(({ children, className, ...props }, ref) => {
13
+ const alerts = React.Children.toArray(children);
14
+ const visibleAlerts = alerts.slice(0, MAX_VISIBLE_ALERTS);
15
+ return (_jsx(MotionConfig, { reducedMotion: "user", children: _jsx("div", { ref: ref, "data-slot": "alert-stack", className: cn("grid", stackPaddingClasses[visibleAlerts.length], className), ...props, children: _jsx(AnimatePresence, { initial: true, children: visibleAlerts.map((alert, index) => {
16
+ const isFront = index === 0;
17
+ return (_jsx(motion.div, { "data-slot": "alert-stack-item", "data-position": isFront ? "front" : "back", "data-depth": index, className: cn("col-start-1 row-start-1 origin-top overflow-hidden rounded-surface", stackItemClasses[index], isFront
18
+ ? "cursor-pointer"
19
+ : "border border-border/80 bg-muted shadow-sm"), initial: { scale: 0.98, y: -12 }, animate: {
20
+ opacity: 1,
21
+ scale: 1,
22
+ y: index * 8,
23
+ }, whileHover: isFront ? { y: -2 } : undefined, exit: { opacity: 0, scale: 0.98, y: -16, zIndex: 60 }, transition: isFront
24
+ ? { duration: 0.2, ease: "easeOut" }
25
+ : { type: "spring", stiffness: 420, damping: 34 }, "aria-hidden": isFront ? undefined : true, ...(isFront ? {} : { inert: "" }), children: _jsx("div", { className: cn("h-full", !isFront && "invisible"), children: alert }) }, React.isValidElement(alert) && alert.key !== null
26
+ ? alert.key
27
+ : index));
28
+ }) }) }) }));
29
+ });
30
+ AlertStack.displayName = "AlertStack";
31
+ export { AlertStack };
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Badge } from "./badge";
3
3
  import { cn } from "./lib/utils";
4
+ const countFormatter = new Intl.NumberFormat("en-SG");
4
5
  function CountBadge({ count, variant = "default", size = "md", max, pulse = false, className, hideWhenZero = false, ...props }) {
5
6
  if (count < 0 || (count === 0 && hideWhenZero))
6
7
  return null;
@@ -9,7 +10,7 @@ function CountBadge({ count, variant = "default", size = "md", max, pulse = fals
9
10
  ? Math.floor(max)
10
11
  : undefined;
11
12
  const isCapped = resolvedMax !== undefined && count > resolvedMax;
12
- const displayCount = isCapped ? `${resolvedMax}+` : count;
13
+ const displayCount = `${countFormatter.format(isCapped ? resolvedMax : count)}${isCapped ? "+" : ""}`;
13
14
  const sizeClasses = {
14
15
  sm: "h-[18px] min-w-[18px] px-1",
15
16
  md: "h-[20px] min-w-[20px] px-1.5",
package/dist/index.d.ts CHANGED
@@ -3,8 +3,10 @@ export type { AvatarProps, AvatarSize, AvatarProfileProps, AvatarRootProps, } fr
3
3
  export { AvatarProfilePopover, AvatarProfilePopoverContent, AvatarProfilePopoverHeader, AvatarProfilePopoverSection, AvatarProfilePopoverFooter, AvatarProfilePopoverFooterAction, } from "./avatar-profile-popover";
4
4
  export type { AvatarProfilePopoverProps, AvatarProfilePopoverContentProps, AvatarProfilePopoverHeaderProps, AvatarProfilePopoverSectionProps, AvatarProfilePopoverFooterProps, AvatarProfilePopoverFooterActionProps, } from "./avatar-profile-popover";
5
5
  export * from "./animated-icons";
6
- export { Alert, AlertAction, AlertConsent, alertVariants } from "./alert";
7
- export type { AlertActionProps, AlertConsentProps, AlertProps } from "./alert";
6
+ export { Alert, AlertAction, AlertConsent, alertVariants, } from "./alert";
7
+ export type { AlertActionProps, AlertConsentProps, AlertProps, } from "./alert";
8
+ export { AlertStack } from "./alert-stack";
9
+ export type { AlertStackProps } from "./alert-stack";
8
10
  export { Badge, badgeVariants } from "./badge";
9
11
  export { Card, CardGrid, CardSplitGrid, CardList, CardListItem, } from "./card";
10
12
  export type { CardGridProps, CardListItemProps, CardListProps, CardProps, CardSplitGridProps, } from "./card";
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export { Avatar, AvatarProfile, AvatarRoot, AvatarImage, } from "./avatar";
2
2
  export { AvatarProfilePopover, AvatarProfilePopoverContent, AvatarProfilePopoverHeader, AvatarProfilePopoverSection, AvatarProfilePopoverFooter, AvatarProfilePopoverFooterAction, } from "./avatar-profile-popover";
3
3
  export * from "./animated-icons";
4
- export { Alert, AlertAction, AlertConsent, alertVariants } from "./alert";
4
+ export { Alert, AlertAction, AlertConsent, alertVariants, } from "./alert";
5
+ export { AlertStack } from "./alert-stack";
5
6
  export { Badge, badgeVariants } from "./badge";
6
7
  export { Card, CardGrid, CardSplitGrid, CardList, CardListItem, } from "./card";
7
8
  export { MessageAttachmentRow, MessageItem, MessageNewDivider, MessageThread, formatMessageDate, } from "./message-item";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neasg/design-system",
3
- "version": "0.4.28",
3
+ "version": "0.4.30",
4
4
  "description": "NEA shared design system primitives, theme tokens, and Storybook docs.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",