@wallarm-org/design-system 1.18.0 → 1.18.1-rc-fix-toast-description-layout.2
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
export declare const SIMPLE_TOAST_DURATION_MS = 5000;
|
|
3
|
+
export declare const EXTENDED_TOAST_DURATION_MS = 10000;
|
|
2
4
|
export interface ToastData {
|
|
3
5
|
id: string;
|
|
4
6
|
title?: string;
|
|
@@ -6,6 +8,7 @@ export interface ToastData {
|
|
|
6
8
|
type?: 'success' | 'error' | 'warning' | 'info' | 'loading' | 'default';
|
|
7
9
|
actions?: ReactNode;
|
|
8
10
|
icon?: ReactNode;
|
|
11
|
+
/** Layout. A `description` forces `extended` and its longer timer. */
|
|
9
12
|
variant?: 'extended' | 'simple';
|
|
10
13
|
closable?: boolean;
|
|
11
14
|
duration?: number;
|
|
@@ -18,3 +21,4 @@ export declare function Toast({ toast }: ToastProps): import("react").JSX.Elemen
|
|
|
18
21
|
export declare namespace Toast {
|
|
19
22
|
var displayName: string;
|
|
20
23
|
}
|
|
24
|
+
export declare const resolveToastVariant: (variant: unknown, description: unknown) => NonNullable<ToastData['variant']>;
|
|
@@ -19,7 +19,7 @@ const toastVariants = cva('group relative flex min-w-[256px] max-w-[560px] items
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
defaultVariants: {
|
|
22
|
-
variant: '
|
|
22
|
+
variant: 'simple'
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
const toastIconMap = {
|
|
@@ -43,7 +43,7 @@ const toastIconMap = {
|
|
|
43
43
|
const SIMPLE_TOAST_DURATION_MS = 5000;
|
|
44
44
|
const EXTENDED_TOAST_DURATION_MS = 10000;
|
|
45
45
|
const Toast_Toast = ({ toast })=>{
|
|
46
|
-
const toastVariant = toast.variant
|
|
46
|
+
const toastVariant = resolveToastVariant(toast.variant, toast.description);
|
|
47
47
|
const isSimple = 'simple' === toastVariant;
|
|
48
48
|
const closable = false !== toast.closable;
|
|
49
49
|
const getToastIcon = ()=>{
|
|
@@ -122,4 +122,5 @@ const Toast_Toast = ({ toast })=>{
|
|
|
122
122
|
}, toast.id);
|
|
123
123
|
};
|
|
124
124
|
Toast_Toast.displayName = 'Toast';
|
|
125
|
-
|
|
125
|
+
const resolveToastVariant = (variant, description)=>description || 'extended' === variant ? 'extended' : 'simple';
|
|
126
|
+
export { EXTENDED_TOAST_DURATION_MS, SIMPLE_TOAST_DURATION_MS, Toast_Toast as Toast, resolveToastVariant };
|
|
@@ -2,9 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Portal } from "@ark-ui/react/portal";
|
|
3
3
|
import { Toaster, createToaster } from "@ark-ui/react/toast";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
|
-
import { Toast } from "./Toast.js";
|
|
6
|
-
const SIMPLE_TOAST_DURATION_MS = 5000;
|
|
7
|
-
const EXTENDED_TOAST_DURATION_MS = 10000;
|
|
5
|
+
import { EXTENDED_TOAST_DURATION_MS, SIMPLE_TOAST_DURATION_MS, Toast, resolveToastVariant } from "./Toast.js";
|
|
8
6
|
const DEFAULT_TOAST_PRIORITY = {
|
|
9
7
|
actionable: 6,
|
|
10
8
|
nonActionable: 8
|
|
@@ -18,7 +16,7 @@ const toaster = {
|
|
|
18
16
|
__arkToaster: arkToaster,
|
|
19
17
|
create: (options)=>arkToaster.create({
|
|
20
18
|
...options,
|
|
21
|
-
duration: options.duration ?? ('extended' === options.variant ? EXTENDED_TOAST_DURATION_MS : SIMPLE_TOAST_DURATION_MS),
|
|
19
|
+
duration: options.duration ?? ('extended' === resolveToastVariant(options.variant, options.description) ? EXTENDED_TOAST_DURATION_MS : SIMPLE_TOAST_DURATION_MS),
|
|
22
20
|
priority: options.priority ?? ('default' === options.type ? options.actions ? DEFAULT_TOAST_PRIORITY.actionable : DEFAULT_TOAST_PRIORITY.nonActionable : void 0)
|
|
23
21
|
}),
|
|
24
22
|
update: (id, options)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
3
|
-
"generatedAt": "2026-09-
|
|
2
|
+
"version": "1.18.0",
|
|
3
|
+
"generatedAt": "2026-09-08T13:41:14.844Z",
|
|
4
4
|
"components": [
|
|
5
5
|
{
|
|
6
6
|
"name": "Accordion",
|
|
@@ -89946,6 +89946,7 @@
|
|
|
89946
89946
|
},
|
|
89947
89947
|
{
|
|
89948
89948
|
"name": "Toast",
|
|
89949
|
+
"description": "Floating notification rendered by `Toaster`.\n\nTwo layouts: `simple` is a one-line title, `extended` adds a description and\na longer timer. Passing a `description` selects `extended` on its own — see\n`resolveToastVariant`.",
|
|
89949
89950
|
"importPath": "@wallarm-org/design-system/Toast",
|
|
89950
89951
|
"props": [],
|
|
89951
89952
|
"variants": [
|
|
@@ -89955,7 +89956,7 @@
|
|
|
89955
89956
|
"extended",
|
|
89956
89957
|
"simple"
|
|
89957
89958
|
],
|
|
89958
|
-
"defaultValue": "
|
|
89959
|
+
"defaultValue": "simple"
|
|
89959
89960
|
}
|
|
89960
89961
|
],
|
|
89961
89962
|
"subComponents": [],
|
|
@@ -89975,10 +89976,15 @@
|
|
|
89975
89976
|
"code": "() => {\n const toast = useToast();\n const id = useRef<string | undefined>(undefined);\n\n const createToast = (duration?: number) => {\n id.current = toast.create({\n title: 'Loading',\n description: 'Loading ...',\n type: 'loading',\n variant: 'extended',\n duration,\n });\n };\n\n const updateToast = (duration?: number) => {\n if (!id.current) {\n return;\n }\n\n toast.update({\n id: id.current,\n title: 'Success',\n description: 'Success!',\n type: 'success',\n variant: 'extended',\n duration,\n });\n };\n\n return (\n <VStack gap={16} align='start'>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>timed</p>\n <HStack gap={8} wrap>\n <Button variant='outline' color='neutral' onClick={() => createToast()}>\n Create loading toast\n </Button>\n <Button variant='outline' color='neutral' onClick={() => updateToast()}>\n Update to success\n </Button>\n </HStack>\n </VStack>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>static — no timer</p>\n <HStack gap={8} wrap>\n <Button variant='secondary' color='neutral' onClick={() => createToast(STATIC_DURATION)}>\n Create loading toast\n </Button>\n <Button variant='secondary' color='neutral' onClick={() => updateToast(STATIC_DURATION)}>\n Update to success\n </Button>\n </HStack>\n </VStack>\n </VStack>\n );\n}",
|
|
89976
89977
|
"description": "A loading toast has no timer and no progress bar, so it will not clear itself: `update()` the same id to resolve it to success or error."
|
|
89977
89978
|
},
|
|
89979
|
+
{
|
|
89980
|
+
"name": "DescriptionKeepsExtended",
|
|
89981
|
+
"code": "() => {\n const toast = useToast();\n\n const withDescription = (duration?: number) =>\n toast.create({\n title: 'Failed to mark as True Positive',\n description: 'resolved vector count must not exceed 500000',\n type: 'error',\n variant: 'simple',\n duration,\n });\n\n const withoutDescription = (duration?: number) =>\n toast.create({ title: 'Marked 2 attacks', type: 'success', variant: 'simple', duration });\n\n return (\n <VStack gap={16} align='start'>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>timed</p>\n <HStack gap={8} wrap>\n <Button variant='outline' color='neutral' onClick={() => withDescription()}>\n Simple with description\n </Button>\n <Button variant='outline' color='neutral' onClick={() => withoutDescription()}>\n Simple without description\n </Button>\n </HStack>\n </VStack>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>static — no timer</p>\n <HStack gap={8} wrap>\n <Button\n variant='secondary'\n color='neutral'\n onClick={() => withDescription(STATIC_DURATION)}\n >\n Simple with description\n </Button>\n <Button\n variant='secondary'\n color='neutral'\n onClick={() => withoutDescription(STATIC_DURATION)}\n >\n Simple without description\n </Button>\n </HStack>\n </VStack>\n </VStack>\n );\n}",
|
|
89982
|
+
"description": "A `description` is never dropped: ask for `simple` alongside one and the toast still reflows to `extended`, timer included. Passing no description keeps the one-line layout."
|
|
89983
|
+
},
|
|
89978
89984
|
{
|
|
89979
89985
|
"name": "SimpleWithActions",
|
|
89980
89986
|
"code": "() => {\n const toast = useToast();\n\n const single = (duration?: number) =>\n toast.create({\n title: 'Message sent',\n type: 'success',\n variant: 'simple',\n duration,\n actions: (\n <ToastActions>\n <Button variant='secondary' size='small' color='neutral-alt' onClick={onToastAction}>\n Undo\n </Button>\n </ToastActions>\n ),\n });\n\n const double = (duration?: number) =>\n toast.create({\n title: 'Connection restored',\n type: 'info',\n variant: 'simple',\n duration,\n actions: (\n <ToastActions>\n <Button variant='secondary' size='small' color='neutral-alt' onClick={onToastAction}>\n View\n </Button>\n <Button variant='secondary' size='small' color='neutral-alt' onClick={onToastAction}>\n Dismiss\n </Button>\n </ToastActions>\n ),\n });\n\n return (\n <VStack gap={16} align='start'>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>timed</p>\n <HStack gap={8} wrap>\n <Button variant='outline' color='neutral' onClick={() => single()}>\n Simple Toast with Action\n </Button>\n <Button variant='outline' color='neutral' onClick={() => double()}>\n Simple Toast with Two Actions\n </Button>\n </HStack>\n </VStack>\n <VStack gap={4} align='start'>\n <p className='sb-annotation'>static — no timer</p>\n <HStack gap={8} wrap>\n <Button variant='secondary' color='neutral' onClick={() => single(STATIC_DURATION)}>\n Simple Toast with Action\n </Button>\n <Button variant='secondary' color='neutral' onClick={() => double(STATIC_DURATION)}>\n Simple Toast with Two Actions\n </Button>\n </HStack>\n </VStack>\n </VStack>\n );\n}",
|
|
89981
|
-
"description": "`simple` is a one-line title for about five seconds. One action is the norm and two is the ceiling — they have to be optional, since the toast leaves on its own."
|
|
89987
|
+
"description": "`simple` is a one-line title for about five seconds — as long as no `description` is passed with it. One action is the norm and two is the ceiling — they have to be optional, since the toast leaves on its own."
|
|
89982
89988
|
},
|
|
89983
89989
|
{
|
|
89984
89990
|
"name": "ExtendedWithActions",
|
package/package.json
CHANGED