@cryptlex/web-components 6.6.6-alpha07 → 6.6.6-alpha08
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,27 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { alertVariants } from './alert';
|
|
3
|
+
export interface ToastProps {
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
variant: VariantProps<typeof alertVariants>['variant'];
|
|
7
|
+
action?: () => void;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Toast provider.
|
|
12
|
+
* @returns The toast provider.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ToastProvider(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* Show a toast notification.
|
|
17
|
+
* @param title - The title of the toast.
|
|
18
|
+
* @param description - The description of the toast.
|
|
19
|
+
* @param variant - The variant of the toast.
|
|
20
|
+
* @param timeout - The timeout of the toast.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toast({ title, description, variant, timeout, }: {
|
|
23
|
+
title: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
variant: ToastProps['variant'];
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}): void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as t,jsxs as r}from"react/jsx-runtime";import{UNSTABLE_ToastQueue as a,UNSTABLE_ToastRegion as l,UNSTABLE_Toast as m,UNSTABLE_ToastContent as d}from"react-aria-components";import{flushSync as u}from"react-dom";import{classNames as p}from"../utilities/theme.js";import{alertVariants as f}from"./alert.js";import{Button as h}from"./button.js";import{IcInfo as i,IcCheck as T,IcError as v}from"./icons.js";import"clsx";import"class-variance-authority";import"./loader.js";import"react";const n=new a({wrapUpdate(e){"startViewTransition"in document?document.startViewTransition(()=>{u(e)}):e()}});function _(){return t(l,{queue:n,className:"fixed z-50 top-4 right-4 flex flex-col-reverse justify-end gap-2",children:({toast:e})=>t(m,{style:{viewTransitionName:e.key},toast:e,children:r(d,{className:p(f({variant:e.content.variant}),"flex flex-row items-center gap-3 w-full"),children:[t("div",{className:"shrink-0",children:N(e.content.variant)}),r("div",{className:"flex-1 min-w-0",children:[t("p",{slot:"title",children:e.content.title}),e.content.description&&t("p",{slot:"description",children:e.content.description})]}),t(h,{slot:"close",variant:"neutral",children:"Close"})]})})})}function N(e){switch(e){case"destructive":return t(v,{});case"success":return t(T,{});case"muted":return t(i,{});default:return t(i,{})}}function j({title:e,description:o,variant:s,timeout:c}){n.add({title:e,description:o,variant:s},{timeout:c??2e3})}export{_ as ToastProvider,j as toast};
|
|
2
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.js","sources":["../../lib/components/toast.tsx"],"sourcesContent":["import type { VariantProps } from 'class-variance-authority';\nimport {\n UNSTABLE_Toast as AriaToast,\n UNSTABLE_ToastContent as AriaToastContent,\n UNSTABLE_ToastQueue as AriaToastQueue,\n UNSTABLE_ToastRegion as AriaToastRegion,\n} from 'react-aria-components';\nimport { flushSync } from 'react-dom';\nimport { classNames } from '../utilities/theme';\nimport { alertVariants } from './alert';\nimport { Button } from './button';\nimport { IcCheck, IcError, IcInfo } from './icons';\n\nexport interface ToastProps {\n title: string;\n description?: string;\n variant: VariantProps<typeof alertVariants>['variant'];\n action?: () => void;\n timeout?: number;\n}\n\n/**\n * Toast queue.\n * @returns The toast queue.\n */\nconst queue = new AriaToastQueue<ToastProps>({\n wrapUpdate(fn) {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n });\n } else {\n fn();\n }\n },\n});\n\n/**\n * Toast provider.\n * @returns The toast provider.\n */\nexport function ToastProvider() {\n return (\n <AriaToastRegion queue={queue} className=\"fixed z-50 top-4 right-4 flex flex-col-reverse justify-end gap-2\">\n {({ toast }) => (\n <AriaToast style={{ viewTransitionName: toast.key }} toast={toast}>\n <AriaToastContent\n className={classNames(\n alertVariants({ variant: toast.content.variant }),\n 'flex flex-row items-center gap-3 w-full'\n )}\n >\n <div className=\"shrink-0\">{getToastIcon(toast.content.variant)}</div>\n <div className=\"flex-1 min-w-0\">\n <p slot=\"title\">{toast.content.title}</p>\n {toast.content.description && <p slot=\"description\">{toast.content.description}</p>}\n </div>\n <Button slot=\"close\" variant=\"neutral\">\n Close\n </Button>\n </AriaToastContent>\n </AriaToast>\n )}\n </AriaToastRegion>\n );\n}\n\n/**\n * Get the icon for a toast notification.\n * @param variant - The variant of the toast.\n * @returns The icon for the toast.\n */\nfunction getToastIcon(variant: ToastProps['variant']) {\n switch (variant) {\n case 'destructive':\n return <IcError />;\n case 'success':\n return <IcCheck />;\n case 'muted':\n return <IcInfo />;\n default:\n return <IcInfo />;\n }\n}\n\n/**\n * Show a toast notification.\n * @param title - The title of the toast.\n * @param description - The description of the toast.\n * @param variant - The variant of the toast.\n * @param timeout - The timeout of the toast.\n */\nexport function toast({\n title,\n description,\n variant,\n timeout,\n}: {\n title: string;\n description?: string;\n variant: ToastProps['variant'];\n timeout?: number;\n}) {\n queue.add({ title, description, variant }, { timeout: timeout ?? 2000 });\n}\n"],"names":["queue","AriaToastQueue","fn","flushSync","ToastProvider","AriaToastRegion","toast","jsx","AriaToast","jsxs","AriaToastContent","classNames","alertVariants","Button","getToastIcon","variant","IcError","IcCheck","IcInfo","title","description","timeout"],"mappings":"8eAyBA,MAAMA,EAAQ,IAAIC,EAA2B,CACzC,WAAWC,EAAI,CACP,wBAAyB,SACzB,SAAS,oBAAoB,IAAM,CAC/BC,EAAUD,CAAE,CAChB,CAAC,EAEDA,EAAA,CAER,CACJ,CAAC,EAMM,SAASE,GAAgB,CAC5B,SACKC,EAAA,CAAgB,MAAAL,EAAc,UAAU,mEACpC,SAAA,CAAC,CAAE,MAAAM,CAAAA,IACAC,EAACC,EAAA,CAAU,MAAO,CAAE,mBAAoBF,EAAM,GAAA,EAAO,MAAOA,EACxD,SAAAG,EAACC,EAAA,CACG,UAAWC,EACPC,EAAc,CAAE,QAASN,EAAM,QAAQ,QAAS,EAChD,yCAAA,EAGJ,SAAA,CAAAC,EAAC,OAAI,UAAU,WAAY,WAAaD,EAAM,QAAQ,OAAO,EAAE,EAC/DG,EAAC,MAAA,CAAI,UAAU,iBACX,SAAA,CAAAF,EAAC,KAAE,KAAK,QAAS,SAAAD,EAAM,QAAQ,MAAM,EACpCA,EAAM,QAAQ,aAAeC,EAAC,IAAA,CAAE,KAAK,cAAe,SAAAD,EAAM,QAAQ,WAAA,CAAY,CAAA,EACnF,IACCO,EAAA,CAAO,KAAK,QAAQ,QAAQ,UAAU,SAAA,OAAA,CAEvC,CAAA,CAAA,CAAA,EAER,CAAA,CAER,CAER,CAOA,SAASC,EAAaC,EAAgC,CAClD,OAAQA,EAAA,CACJ,IAAK,cACD,SAAQC,EAAA,EAAQ,EACpB,IAAK,UACD,SAAQC,EAAA,EAAQ,EACpB,IAAK,QACD,SAAQC,EAAA,EAAO,EACnB,QACI,SAAQA,EAAA,EAAO,CAAA,CAE3B,CASO,SAASZ,EAAM,CAClB,MAAAa,EACA,YAAAC,EACA,QAAAL,EACA,QAAAM,CACJ,EAKG,CACCrB,EAAM,IAAI,CAAE,MAAAmB,EAAO,YAAAC,EAAa,QAAAL,CAAA,EAAW,CAAE,QAASM,GAAW,IAAM,CAC3E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptlex/web-components",
|
|
3
|
-
"version": "6.6.6-
|
|
3
|
+
"version": "6.6.6-alpha08",
|
|
4
4
|
"description": "React component library for Cryptlex web applications",
|
|
5
5
|
"author": "Cryptlex",
|
|
6
6
|
"type": "module",
|
|
@@ -61,10 +61,9 @@
|
|
|
61
61
|
"lodash-es": "4.17.21",
|
|
62
62
|
"openapi-fetch": "0.14.0",
|
|
63
63
|
"react": "^19.1.0",
|
|
64
|
-
"react-aria-components": "1.
|
|
64
|
+
"react-aria-components": "1.12.0",
|
|
65
65
|
"react-dom": "^19.1.0",
|
|
66
66
|
"recharts": "2.15.3",
|
|
67
|
-
"sonner": "1.7.0",
|
|
68
67
|
"tailwindcss": "4.1.12",
|
|
69
68
|
"tw-animate-css": "1.3.0",
|
|
70
69
|
"tw-type-css": "0.0.1",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{jsx as o}from"react/jsx-runtime";import{Toaster as r}from"sonner";function s({...t}){return o(r,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})}export{s as Toaster};
|
|
2
|
-
//# sourceMappingURL=sonner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sonner.js","sources":["../../lib/components/sonner.tsx"],"sourcesContent":["'use client';\nimport { Toaster as Sonner } from 'sonner';\n\ntype ToasterProps = React.ComponentProps<typeof Sonner>;\n\n// TODO, this doesn't conform to our styles\nexport function Toaster({ ...props }: ToasterProps) {\n return (\n <Sonner\n className=\"toaster group\"\n toastOptions={{\n classNames: {\n toast: 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border',\n description: 'group-[.toast]:text-muted-foreground',\n actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',\n cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',\n },\n }}\n {...props}\n />\n );\n}\n"],"names":["Toaster","props","jsx","Sonner"],"mappings":"sFAMO,SAASA,EAAQ,CAAE,GAAGC,GAAuB,CAChD,OACIC,EAACC,EAAA,CACG,UAAU,gBACV,aAAc,CACV,WAAY,CACR,MAAO,6GACP,YAAa,uCACb,aAAc,mEACd,aAAc,8DAAA,CAClB,EAEH,GAAGF,CAAA,CAAA,CAGhB"}
|