@wallarm-org/design-system 0.16.3 → 0.16.4

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.
@@ -8,6 +8,7 @@ export interface ToastData {
8
8
  icon?: ReactNode;
9
9
  variant?: 'extended' | 'simple';
10
10
  closable?: boolean;
11
+ duration?: number;
11
12
  [key: string]: unknown;
12
13
  }
13
14
  export interface ToastProps {
@@ -9,8 +9,9 @@ import { Loader } from "../Loader/index.js";
9
9
  import { ToastClose } from "./ToastClose.js";
10
10
  import { ToastDescription } from "./ToastDescription.js";
11
11
  import { ToastIcon } from "./ToastIcon.js";
12
+ import { ToastProgress } from "./ToastProgress.js";
12
13
  import { ToastTitle } from "./ToastTitle.js";
13
- const toastVariants = cva('group relative flex min-w-[256px] max-w-[560px] items-start gap-12 rounded-12 bg-slate-800 p-12 pl-16 shadow-lg transition-all', {
14
+ const toastVariants = cva('group relative flex min-w-[256px] max-w-[560px] items-start gap-12 rounded-16 bg-component-toast-bg p-12 pl-16 shadow-lg transition-all', {
14
15
  variants: {
15
16
  variant: {
16
17
  extended: 'flex-col',
@@ -39,6 +40,8 @@ const toastIconMap = {
39
40
  className: 'text-blue-500'
40
41
  }
41
42
  };
43
+ const SIMPLE_TOAST_DURATION_MS = 5000;
44
+ const EXTENDED_TOAST_DURATION_MS = 10000;
42
45
  const Toast_Toast = ({ toast })=>{
43
46
  const toastVariant = toast.variant || 'simple';
44
47
  const isSimple = 'simple' === toastVariant;
@@ -81,35 +84,40 @@ const Toast_Toast = ({ toast })=>{
81
84
  className: cn(toastVariants({
82
85
  variant: toastVariant
83
86
  })),
84
- children: /*#__PURE__*/ jsx(TestIdProvider, {
87
+ children: /*#__PURE__*/ jsxs(TestIdProvider, {
85
88
  value: toast.id,
86
- children: /*#__PURE__*/ jsxs("div", {
87
- className: cn('flex w-full items-start gap-8 relative z-10'),
88
- children: [
89
- toastIcon && /*#__PURE__*/ jsx(ToastIcon, {
90
- children: toastIcon
91
- }),
92
- /*#__PURE__*/ jsxs("div", {
93
- className: cn('flex-1 flex', isSimple ? 'flex-row gap-16 items-start' : 'flex-col gap-8'),
94
- children: [
95
- /*#__PURE__*/ jsxs("div", {
96
- className: "flex-1 py-2",
97
- children: [
98
- toast.title && /*#__PURE__*/ jsx(ToastTitle, {
99
- variant: toastVariant,
100
- children: toast.title
101
- }),
102
- !isSimple && toast.description && /*#__PURE__*/ jsx(ToastDescription, {
103
- children: toast.description
104
- })
105
- ]
106
- }),
107
- toast.actions && toast.actions
108
- ]
109
- }),
110
- closable && /*#__PURE__*/ jsx(ToastClose, {})
111
- ]
112
- })
89
+ children: [
90
+ /*#__PURE__*/ jsxs("div", {
91
+ className: cn('flex w-full gap-8 relative z-10', isSimple ? 'items-center' : 'items-start'),
92
+ children: [
93
+ toastIcon && /*#__PURE__*/ jsx(ToastIcon, {
94
+ children: toastIcon
95
+ }),
96
+ /*#__PURE__*/ jsxs("div", {
97
+ className: cn('flex-1 flex', isSimple ? 'flex-row gap-16 items-center' : 'flex-col gap-8'),
98
+ children: [
99
+ /*#__PURE__*/ jsxs("div", {
100
+ className: "flex-1 py-2",
101
+ children: [
102
+ toast.title && /*#__PURE__*/ jsx(ToastTitle, {
103
+ variant: toastVariant,
104
+ children: toast.title
105
+ }),
106
+ !isSimple && toast.description && /*#__PURE__*/ jsx(ToastDescription, {
107
+ children: toast.description
108
+ })
109
+ ]
110
+ }),
111
+ toast.actions && toast.actions
112
+ ]
113
+ }),
114
+ closable && /*#__PURE__*/ jsx(ToastClose, {})
115
+ ]
116
+ }),
117
+ 'loading' !== toast.type && /*#__PURE__*/ jsx(ToastProgress, {
118
+ duration: toast.duration ?? (isSimple ? SIMPLE_TOAST_DURATION_MS : EXTENDED_TOAST_DURATION_MS)
119
+ })
120
+ ]
113
121
  })
114
122
  }, toast.id);
115
123
  };
@@ -10,7 +10,7 @@ const ToastDescription = /*#__PURE__*/ forwardRef(({ children }, ref)=>{
10
10
  /*#__PURE__*/ jsx(OverflowTooltipTrigger, {
11
11
  children: /*#__PURE__*/ jsx(Text, {
12
12
  ref: ref,
13
- size: "md",
13
+ size: "sm",
14
14
  color: "secondary-alt",
15
15
  lineClamp: 4,
16
16
  "data-testid": testId,
@@ -0,0 +1,6 @@
1
+ import { type FC } from 'react';
2
+ interface ToastProgressProps {
3
+ duration: number;
4
+ }
5
+ export declare const ToastProgress: FC<ToastProgressProps>;
6
+ export {};
@@ -0,0 +1,41 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { cn } from "../../utils/cn.js";
4
+ const ToastProgress = ({ duration })=>{
5
+ const [progress, setProgress] = useState(0);
6
+ const elapsedRef = useRef(0);
7
+ const lastTickRef = useRef(0);
8
+ const rafRef = useRef(0);
9
+ const containerRef = useRef(null);
10
+ const isPaused = useCallback(()=>{
11
+ const root = containerRef.current?.closest('[data-scope="toast"][data-part="root"]');
12
+ return root?.hasAttribute('data-paused') ?? false;
13
+ }, []);
14
+ useEffect(()=>{
15
+ lastTickRef.current = performance.now();
16
+ const tick = (now)=>{
17
+ if (!isPaused()) elapsedRef.current += now - lastTickRef.current;
18
+ lastTickRef.current = now;
19
+ const fraction = Math.min(elapsedRef.current / duration, 1);
20
+ setProgress(fraction);
21
+ if (fraction < 1) rafRef.current = requestAnimationFrame(tick);
22
+ };
23
+ rafRef.current = requestAnimationFrame(tick);
24
+ return ()=>cancelAnimationFrame(rafRef.current);
25
+ }, [
26
+ duration,
27
+ isPaused
28
+ ]);
29
+ return /*#__PURE__*/ jsx("div", {
30
+ ref: containerRef,
31
+ className: cn('absolute inset-0 rounded-16 overflow-hidden pointer-events-none'),
32
+ children: /*#__PURE__*/ jsx("div", {
33
+ className: "h-full bg-states-primary-alt-default-alt transition-none",
34
+ style: {
35
+ width: `${100 * progress}%`
36
+ }
37
+ })
38
+ });
39
+ };
40
+ ToastProgress.displayName = 'ToastProgress';
41
+ export { ToastProgress };
@@ -11,7 +11,7 @@ const ToastTitle = /*#__PURE__*/ forwardRef(({ children, variant = 'extended' },
11
11
  /*#__PURE__*/ jsx(OverflowTooltipTrigger, {
12
12
  children: /*#__PURE__*/ jsx(Text, {
13
13
  ref: ref,
14
- size: "md",
14
+ size: "sm",
15
15
  weight: "medium",
16
16
  color: "primary-alt",
17
17
  lineClamp: isSimple ? 1 : 2,
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.16.2",
3
- "generatedAt": "2026-03-27T11:04:52.776Z",
2
+ "version": "0.16.3",
3
+ "generatedAt": "2026-03-30T15:26:37.885Z",
4
4
  "components": [
5
5
  {
6
6
  "name": "Alert",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",