@medusajs/ui 2.4.3 → 3.0.0-next-20240425093236
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/README.md +1 -1
- package/dist/cjs/components/toast/toast.d.ts +11 -19
- package/dist/cjs/components/toast/toast.js +60 -53
- package/dist/cjs/components/toast/toast.js.map +1 -1
- package/dist/cjs/components/toaster/toaster.d.ts +7 -1
- package/dist/cjs/components/toaster/toaster.js +28 -9
- package/dist/cjs/components/toaster/toaster.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.d.ts +21 -0
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/toast.d.ts +86 -0
- package/dist/cjs/utils/toast.js +135 -0
- package/dist/cjs/utils/toast.js.map +1 -0
- package/dist/esm/components/toast/toast.d.ts +11 -19
- package/dist/esm/components/toast/toast.js +60 -52
- package/dist/esm/components/toast/toast.js.map +1 -1
- package/dist/esm/components/toaster/toaster.d.ts +7 -1
- package/dist/esm/components/toaster/toaster.js +28 -9
- package/dist/esm/components/toaster/toaster.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.d.ts +21 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/toast.d.ts +86 -0
- package/dist/esm/utils/toast.js +131 -0
- package/dist/esm/utils/toast.js.map +1 -0
- package/package.json +5 -5
- package/dist/cjs/hooks/use-toast/index.d.ts +0 -1
- package/dist/cjs/hooks/use-toast/index.js +0 -5
- package/dist/cjs/hooks/use-toast/index.js.map +0 -1
- package/dist/cjs/hooks/use-toast/use-toast.d.ts +0 -44
- package/dist/cjs/hooks/use-toast/use-toast.js +0 -132
- package/dist/cjs/hooks/use-toast/use-toast.js.map +0 -1
- package/dist/esm/hooks/use-toast/index.d.ts +0 -1
- package/dist/esm/hooks/use-toast/index.js +0 -2
- package/dist/esm/hooks/use-toast/index.js.map +0 -1
- package/dist/esm/hooks/use-toast/use-toast.d.ts +0 -44
- package/dist/esm/hooks/use-toast/use-toast.js +0 -126
- package/dist/esm/hooks/use-toast/use-toast.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import * as Primitives from "@radix-ui/react-toast";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
onClick: () => void | Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
interface ToastProps extends React.ComponentPropsWithoutRef<typeof Primitives.Root> {
|
|
11
|
-
variant?: "info" | "success" | "warning" | "error" | "loading";
|
|
12
|
-
title?: string;
|
|
2
|
+
import type { ToastAction, ToastVariant } from "../../types";
|
|
3
|
+
interface ToastComponentProps {
|
|
4
|
+
id: string | number;
|
|
5
|
+
variant?: ToastVariant;
|
|
6
|
+
title: string;
|
|
13
7
|
description?: string;
|
|
14
|
-
action?:
|
|
15
|
-
|
|
8
|
+
action?: ToastAction;
|
|
9
|
+
onDismiss?: (id?: string | number) => void;
|
|
10
|
+
dismissLabel?: string;
|
|
16
11
|
}
|
|
17
12
|
/**
|
|
18
|
-
* This component is based on the [
|
|
19
|
-
*
|
|
20
|
-
* @excludeExternal
|
|
13
|
+
* This component is based on the [Sonner](https://sonner.emilkowal.ski/toast) toast library.
|
|
21
14
|
*/
|
|
22
|
-
declare const Toast:
|
|
23
|
-
|
|
24
|
-
export { Toast, ToastProvider, ToastViewport, type ToastActionElement, type ToastProps, };
|
|
15
|
+
export declare const Toast: ({ id, variant, title, description, action, onDismiss, dismissLabel, }: ToastComponentProps) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -1,88 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
"use client";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
3
|
+
exports.Toast = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const icons_1 = require("@medusajs/icons");
|
|
7
|
-
const Primitives = tslib_1.__importStar(require("@radix-ui/react-toast"));
|
|
8
6
|
const React = tslib_1.__importStar(require("react"));
|
|
9
7
|
const clx_1 = require("../../utils/clx");
|
|
10
|
-
const ToastProvider = Primitives.Provider;
|
|
11
|
-
exports.ToastProvider = ToastProvider;
|
|
12
|
-
ToastProvider.displayName = "ToastProvider";
|
|
13
|
-
const ToastViewport = React.forwardRef(({ className, ...props }, ref) => (React.createElement(Primitives.Viewport, { ref: ref, className: (0, clx_1.clx)("fixed right-0 top-0 z-[9999] w-full p-6 md:max-w-[484px]", className), ...props })));
|
|
14
|
-
exports.ToastViewport = ToastViewport;
|
|
15
|
-
ToastViewport.displayName = "Toast.Viewport";
|
|
16
8
|
/**
|
|
17
|
-
* This component is based on the [
|
|
18
|
-
*
|
|
19
|
-
* @excludeExternal
|
|
9
|
+
* This component is based on the [Sonner](https://sonner.emilkowal.ski/toast) toast library.
|
|
20
10
|
*/
|
|
21
|
-
const Toast =
|
|
11
|
+
const Toast = ({
|
|
22
12
|
/**
|
|
23
|
-
*
|
|
13
|
+
* Optional ID of the toast.
|
|
24
14
|
*/
|
|
25
|
-
|
|
15
|
+
id,
|
|
26
16
|
/**
|
|
27
|
-
*
|
|
17
|
+
* @ignore
|
|
18
|
+
*
|
|
19
|
+
* @privateRemarks
|
|
20
|
+
* As the Toast component is created using
|
|
21
|
+
* the `toast` utility functions, the variant is inferred
|
|
22
|
+
* from the utility function.
|
|
23
|
+
*/
|
|
24
|
+
variant = "info",
|
|
25
|
+
/**
|
|
26
|
+
* @ignore
|
|
27
|
+
*
|
|
28
|
+
* @privateRemarks
|
|
29
|
+
* The `toast` utility functions accept this as a parameter.
|
|
28
30
|
*/
|
|
29
31
|
title,
|
|
30
32
|
/**
|
|
31
|
-
* The toast's
|
|
33
|
+
* The toast's text.
|
|
32
34
|
*/
|
|
33
35
|
description,
|
|
34
36
|
/**
|
|
35
|
-
* The
|
|
37
|
+
* The toast's action buttons.
|
|
36
38
|
*/
|
|
37
39
|
action,
|
|
38
40
|
/**
|
|
39
|
-
*
|
|
41
|
+
* @ignore
|
|
42
|
+
*
|
|
43
|
+
* @privateRemarks
|
|
44
|
+
* The `toast` utility functions don't allow
|
|
45
|
+
* passing this prop.
|
|
46
|
+
*/
|
|
47
|
+
onDismiss,
|
|
48
|
+
/**
|
|
49
|
+
* The label of the dismiss button, if available.
|
|
40
50
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
dismissLabel = "Close", }) => {
|
|
52
|
+
const hasActionables = !!action || onDismiss;
|
|
53
|
+
let icon = undefined;
|
|
43
54
|
switch (variant) {
|
|
44
55
|
case "success":
|
|
45
|
-
|
|
56
|
+
icon = React.createElement(icons_1.CheckCircleSolid, { className: "text-ui-tag-green-icon" });
|
|
46
57
|
break;
|
|
47
58
|
case "warning":
|
|
48
|
-
|
|
59
|
+
icon = React.createElement(icons_1.ExclamationCircleSolid, { className: "text-ui-tag-orange-icon" });
|
|
49
60
|
break;
|
|
50
61
|
case "error":
|
|
51
|
-
|
|
62
|
+
icon = React.createElement(icons_1.XCircleSolid, { className: "text-ui-tag-red-icon" });
|
|
52
63
|
break;
|
|
53
64
|
case "loading":
|
|
54
|
-
|
|
65
|
+
icon = React.createElement(icons_1.Spinner, { className: "text-ui-tag-blue-icon animate-spin" });
|
|
66
|
+
break;
|
|
67
|
+
case "info":
|
|
68
|
+
icon = React.createElement(icons_1.InformationCircleSolid, { className: "text-ui-fg-base" });
|
|
55
69
|
break;
|
|
56
70
|
default:
|
|
57
|
-
Icon = React.createElement(icons_1.InformationCircleSolid, { className: "text-ui-fg-base" });
|
|
58
71
|
break;
|
|
59
72
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
React.createElement("
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
!disableDismiss && (React.createElement(Primitives.Close, { className: (0, clx_1.clx)("txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex flex-1 items-center justify-center px-6 transition-colors", {
|
|
82
|
-
"h-1/2": action,
|
|
83
|
-
"h-full": !action,
|
|
84
|
-
}), "aria-label": "Close" }, "Close")))));
|
|
85
|
-
});
|
|
73
|
+
return (React.createElement("div", { className: "shadow-elevation-flyout bg-ui-bg-base flex w-fit min-w-[360px] max-w-[440px] overflow-hidden rounded-lg" },
|
|
74
|
+
React.createElement("div", { className: (0, clx_1.clx)("grid flex-1 items-start gap-3 py-3 pl-3", {
|
|
75
|
+
"border-r pr-3": hasActionables,
|
|
76
|
+
"pr-6": !hasActionables,
|
|
77
|
+
"grid-cols-[20px_1fr]": !!icon,
|
|
78
|
+
"grid-cols-1": !icon,
|
|
79
|
+
}) },
|
|
80
|
+
!!icon && (React.createElement("span", { className: "flex size-5 items-center justify-center", "aria-hidden": true }, icon)),
|
|
81
|
+
React.createElement("div", { className: "flex flex-col" },
|
|
82
|
+
React.createElement("span", { className: "txt-compact-small-plus text-ui-fg-base" }, title),
|
|
83
|
+
React.createElement("span", { className: "txt-small text-ui-fg-subtle text-pretty" }, description))),
|
|
84
|
+
hasActionables && (React.createElement("div", { className: (0, clx_1.clx)("grid grid-cols-1", {
|
|
85
|
+
"grid-rows-2": !!action && onDismiss,
|
|
86
|
+
"grid-rows-1": !action || !onDismiss,
|
|
87
|
+
}) },
|
|
88
|
+
!!action && (React.createElement("button", { type: "button", className: (0, clx_1.clx)("txt-compact-small-plus text-ui-fg-base bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex items-center justify-center px-4 transition-colors", {
|
|
89
|
+
"border-ui-border-base border-b": onDismiss,
|
|
90
|
+
"text-ui-fg-error": action.variant === "destructive",
|
|
91
|
+
}), onClick: action.onClick }, action.label)),
|
|
92
|
+
onDismiss && (React.createElement("button", { type: "button", onClick: () => onDismiss(id), className: (0, clx_1.clx)("txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex items-center justify-center px-4 transition-colors") }, dismissLabel))))));
|
|
93
|
+
};
|
|
86
94
|
exports.Toast = Toast;
|
|
87
|
-
Toast.displayName = "Toast";
|
|
88
95
|
//# sourceMappingURL=toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../../src/components/toast/toast.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../../src/components/toast/toast.tsx"],"names":[],"mappings":";;;;AAAA,2CAAyH;AACzH,qDAA8B;AAG9B,qCAAiC;AAYjC;;GAEG;AACI,MAAM,KAAK,GAAG,CAAC;AACpB;;GAEG;AACH,EAAE;AACF;;;;;;;GAOG;AACH,OAAO,GAAG,MAAM;AAChB;;;;;GAKG;AACH,KAAK;AACL;;GAEG;AACH,WAAW;AACX;;GAEG;AACH,MAAM;AACN;;;;;;GAMG;AACH,SAAS;AACT;;GAEG;AACH,YAAY,GAAG,OAAO,GACF,EAAE,EAAE;IACxB,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,IAAI,SAAS,CAAA;IAC5C,IAAI,IAAI,GAAG,SAAS,CAAA;IAEpB,QAAQ,OAAO,EAAE;QACf,KAAK,SAAS;YACZ,IAAI,GAAG,oBAAC,wBAAgB,IAAC,SAAS,EAAC,wBAAwB,GAAG,CAAA;YAC9D,MAAK;QACP,KAAK,SAAS;YACZ,IAAI,GAAG,oBAAC,8B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,OAAO,EAAE,MAAM,CAAC,OAAO,IAEtB,MAAM,CAAC,KAAK,CACN,CACV;YACA,SAAS,IAAI,CACZ,gCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,EAC5B,SAAS,EAAE,IAAA,SAAG,EACZ,uKAAuK,CACxK,IAEA,YAAY,CACN,CACV,CACG,CACP,CACG,CACP,CAAA;AACH,CAAC,CAAA;AA9HY,QAAA,KAAK,SA8HjB","sourcesContent":["import { CheckCircleSolid, ExclamationCircleSolid, InformationCircleSolid, Spinner, XCircleSolid } from \"@medusajs/icons\"\nimport * as React from \"react\"\n\nimport type { ToastAction, ToastVariant } from \"@/types\"\nimport { clx } from \"@/utils/clx\"\n\ninterface ToastComponentProps {\n id: string | number\n variant?: ToastVariant\n title: string\n description?: string\n action?: ToastAction\n onDismiss?: (id?: string | number) => void\n dismissLabel?: string\n}\n\n/**\n * This component is based on the [Sonner](https://sonner.emilkowal.ski/toast) toast library.\n */\nexport const Toast = ({\n /**\n * Optional ID of the toast.\n */\n id,\n /**\n * @ignore\n * \n * @privateRemarks\n * As the Toast component is created using\n * the `toast` utility functions, the variant is inferred\n * from the utility function.\n */\n variant = \"info\",\n /**\n * @ignore\n * \n * @privateRemarks\n * The `toast` utility functions accept this as a parameter.\n */\n title,\n /**\n * The toast's text.\n */\n description,\n /**\n * The toast's action buttons.\n */\n action,\n /**\n * @ignore\n * \n * @privateRemarks\n * The `toast` utility functions don't allow\n * passing this prop.\n */\n onDismiss,\n /**\n * The label of the dismiss button, if available.\n */\n dismissLabel = \"Close\",\n}: ToastComponentProps) => {\n const hasActionables = !!action || onDismiss\n let icon = undefined\n\n switch (variant) {\n case \"success\":\n icon = <CheckCircleSolid className=\"text-ui-tag-green-icon\" />\n break\n case \"warning\":\n icon = <ExclamationCircleSolid className=\"text-ui-tag-orange-icon\" />\n break\n case \"error\":\n icon = <XCircleSolid className=\"text-ui-tag-red-icon\" />\n break\n case \"loading\":\n icon = <Spinner className=\"text-ui-tag-blue-icon animate-spin\" />\n break\n case \"info\":\n icon = <InformationCircleSolid className=\"text-ui-fg-base\" />\n break\n default:\n break\n }\n\n return (\n <div className=\"shadow-elevation-flyout bg-ui-bg-base flex w-fit min-w-[360px] max-w-[440px] overflow-hidden rounded-lg\">\n <div\n className={clx(\"grid flex-1 items-start gap-3 py-3 pl-3\", {\n \"border-r pr-3\": hasActionables,\n \"pr-6\": !hasActionables,\n \"grid-cols-[20px_1fr]\": !!icon,\n \"grid-cols-1\": !icon,\n })}\n >\n {!!icon && (\n <span className=\"flex size-5 items-center justify-center\" aria-hidden>\n {icon}\n </span>\n )}\n <div className=\"flex flex-col\">\n <span className=\"txt-compact-small-plus text-ui-fg-base\">\n {title}\n </span>\n <span className=\"txt-small text-ui-fg-subtle text-pretty\">\n {description}\n </span>\n </div>\n </div>\n {hasActionables && (\n <div\n className={clx(\"grid grid-cols-1\", {\n \"grid-rows-2\": !!action && onDismiss,\n \"grid-rows-1\": !action || !onDismiss,\n })}\n >\n {!!action && (\n <button\n type=\"button\"\n className={clx(\n \"txt-compact-small-plus text-ui-fg-base bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex items-center justify-center px-4 transition-colors\",\n {\n \"border-ui-border-base border-b\": onDismiss,\n \"text-ui-fg-error\": action.variant === \"destructive\",\n }\n )}\n onClick={action.onClick}\n >\n {action.label}\n </button>\n )}\n {onDismiss && (\n <button\n type=\"button\"\n onClick={() => onDismiss(id)}\n className={clx(\n \"txt-compact-small-plus text-ui-fg-subtle bg-ui-bg-base hover:bg-ui-bg-base-hover active:bg-ui-bg-base-pressed flex items-center justify-center px-4 transition-colors\"\n )}\n >\n {dismissLabel}\n </button>\n )}\n </div>\n )}\n </div>\n )\n}"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import { Toaster as Primitive } from "sonner";
|
|
3
|
+
interface ToasterProps extends Omit<React.ComponentPropsWithoutRef<typeof Primitive>, "richColors" | "closeButton" | "icons" | "theme" | "invert" | "loadingIcon" | "cn" | "toastOptions"> {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* This component is based on the [Toaster component of the Sonner library](https://sonner.emilkowal.ski/toaster).
|
|
7
|
+
*/
|
|
8
|
+
declare const Toaster: ({ position, gap, offset, duration, ...props }: ToasterProps) => React.JSX.Element;
|
|
3
9
|
export { Toaster };
|
|
@@ -4,15 +4,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Toaster = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const React = tslib_1.__importStar(require("react"));
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const sonner_1 = require("sonner");
|
|
8
|
+
const clx_1 = require("../../utils/clx");
|
|
9
|
+
/**
|
|
10
|
+
* This component is based on the [Toaster component of the Sonner library](https://sonner.emilkowal.ski/toaster).
|
|
11
|
+
*/
|
|
12
|
+
const Toaster = ({
|
|
13
|
+
/**
|
|
14
|
+
* The position of the created toasts.
|
|
15
|
+
*/
|
|
16
|
+
position = "bottom-right",
|
|
17
|
+
/**
|
|
18
|
+
* The gap between the toast components.
|
|
19
|
+
*/
|
|
20
|
+
gap = 12,
|
|
21
|
+
/**
|
|
22
|
+
* The space from the edges of the screen.
|
|
23
|
+
*/
|
|
24
|
+
offset = 24,
|
|
25
|
+
/**
|
|
26
|
+
* The time in milliseconds that a toast is shown before it's
|
|
27
|
+
* automatically dismissed.
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue 4000
|
|
30
|
+
*/
|
|
31
|
+
duration, ...props }) => {
|
|
32
|
+
return (React.createElement(sonner_1.Toaster, { position: position, gap: gap, offset: offset, cn: clx_1.clx, toastOptions: {
|
|
33
|
+
duration,
|
|
34
|
+
}, ...props }));
|
|
16
35
|
};
|
|
17
36
|
exports.Toaster = Toaster;
|
|
18
37
|
//# sourceMappingURL=toaster.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toaster.js","sourceRoot":"","sources":["../../../../src/components/toaster/toaster.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,qDAA8B;
|
|
1
|
+
{"version":3,"file":"toaster.js","sourceRoot":"","sources":["../../../../src/components/toaster/toaster.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,qDAA8B;AAC9B,mCAA6C;AAE7C,qCAAiC;AAejC;;GAEG;AACH,MAAM,OAAO,GAAG,CAAC;AACf;;GAEG;AACH,QAAQ,GAAG,cAAc;AACzB;;GAEG;AACH,GAAG,GAAG,EAAE;AACR;;GAEG;AACH,MAAM,GAAG,EAAE;AACX;;;;;GAKG;AACH,QAAQ,EACR,GAAG,KAAK,EACK,EAAE,EAAE;IACjB,OAAO,CACL,oBAAC,gBAAS,IACR,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,SAAG,EACP,YAAY,EAAE;YACZ,QAAQ;SACT,KACG,KAAK,GACT,CACH,CAAA;AACH,CAAC,CAAA;AAEQ,0BAAO","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { Toaster as Primitive } from \"sonner\"\n\nimport { clx } from \"@/utils/clx\"\n\ninterface ToasterProps\n extends Omit<\n React.ComponentPropsWithoutRef<typeof Primitive>,\n | \"richColors\"\n | \"closeButton\"\n | \"icons\"\n | \"theme\"\n | \"invert\"\n | \"loadingIcon\"\n | \"cn\"\n | \"toastOptions\"\n > {}\n\n/**\n * This component is based on the [Toaster component of the Sonner library](https://sonner.emilkowal.ski/toaster).\n */\nconst Toaster = ({\n /**\n * The position of the created toasts.\n */\n position = \"bottom-right\",\n /**\n * The gap between the toast components.\n */\n gap = 12,\n /**\n * The space from the edges of the screen.\n */\n offset = 24,\n /**\n * The time in milliseconds that a toast is shown before it's\n * automatically dismissed.\n * \n * @defaultValue 4000\n */\n duration,\n ...props\n}: ToasterProps) => {\n return (\n <Primitive\n position={position}\n gap={gap}\n offset={offset}\n cn={clx}\n toastOptions={{\n duration,\n }}\n {...props}\n />\n )\n}\n\nexport { Toaster }\n"]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export { Toast } from "./components/toast";
|
|
|
38
38
|
export { Toaster } from "./components/toaster";
|
|
39
39
|
export { Tooltip } from "./components/tooltip";
|
|
40
40
|
export { usePrompt } from "./hooks/use-prompt";
|
|
41
|
-
export { useToast } from "./hooks/use-toast";
|
|
42
41
|
export { useToggleState } from "./hooks/use-toggle-state";
|
|
43
42
|
export { clx } from "./utils/clx";
|
|
43
|
+
export { toast } from "./utils/toast";
|
|
44
44
|
export * from "./types";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toast = exports.clx = exports.useToggleState = exports.usePrompt = exports.Tooltip = exports.Toaster = exports.Toast = exports.Textarea = exports.Text = exports.Tabs = exports.Table = exports.Switch = exports.StatusBadge = exports.Select = exports.RadioGroup = exports.Prompt = exports.ProgressTabs = exports.ProgressAccordion = exports.Popover = exports.Label = exports.Kbd = exports.Input = exports.IconButton = exports.IconBadge = exports.Hint = exports.Heading = exports.FocusModal = exports.DropdownMenu = exports.Drawer = exports.DatePicker = exports.CurrencyInput = exports.Copy = exports.Container = exports.CommandBar = exports.Command = exports.CodeBlock = exports.Code = exports.Checkbox = exports.Calendar = exports.Button = exports.Badge = exports.Avatar = exports.Alert = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var alert_1 = require("./components/alert");
|
|
6
6
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return alert_1.Alert; } });
|
|
@@ -83,13 +83,13 @@ Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () {
|
|
|
83
83
|
// Hooks
|
|
84
84
|
var use_prompt_1 = require("./hooks/use-prompt");
|
|
85
85
|
Object.defineProperty(exports, "usePrompt", { enumerable: true, get: function () { return use_prompt_1.usePrompt; } });
|
|
86
|
-
var use_toast_1 = require("./hooks/use-toast");
|
|
87
|
-
Object.defineProperty(exports, "useToast", { enumerable: true, get: function () { return use_toast_1.useToast; } });
|
|
88
86
|
var use_toggle_state_1 = require("./hooks/use-toggle-state");
|
|
89
87
|
Object.defineProperty(exports, "useToggleState", { enumerable: true, get: function () { return use_toggle_state_1.useToggleState; } });
|
|
90
88
|
// Utils
|
|
91
89
|
var clx_1 = require("./utils/clx");
|
|
92
90
|
Object.defineProperty(exports, "clx", { enumerable: true, get: function () { return clx_1.clx; } });
|
|
91
|
+
var toast_2 = require("./utils/toast");
|
|
92
|
+
Object.defineProperty(exports, "toast", { enumerable: true, get: function () { return toast_2.toast; } });
|
|
93
93
|
// Types
|
|
94
94
|
tslib_1.__exportStar(require("./types"), exports);
|
|
95
95
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,4CAA0C;AAAjC,8FAAA,KAAK,OAAA;AACd,8CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,4CAA0C;AAAjC,8FAAA,KAAK,OAAA;AACd,8CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,kDAAgD;AAAvC,oGAAA,QAAQ,OAAA;AACjB,kDAAgD;AAAvC,oGAAA,QAAQ,OAAA;AACjB,0CAAwC;AAA/B,4FAAA,IAAI,OAAA;AACb,sDAAmD;AAA1C,uGAAA,SAAS,OAAA;AAClB,gDAA8C;AAArC,kGAAA,OAAO,OAAA;AAChB,wDAAqD;AAA5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f,wDAAqD;AAA5C,yGAAA,UAAU,OAAA;AACnB,8CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,0DAAuD;AAA9C,2GAAA,WAAW,OAAA;AACpB,8CAA4C;AAAnC,gGAAA,MAAM,OAAA;AACf,4CAA0C;AAAjC,8FAAA,KAAK,OAAA;AACd,0CAAwC;AAA/B,4FAAA,IAAI,OAAA;AACb,0CAAwC;AAA/B,4FAAA,IAAI,OAAA;AACb,kDAAgD;AAAvC,oGAAA,QAAQ,OAAA;AACjB,4CAA0C;AAAjC,8FAAA,KAAK,OAAA;AACd,gDAA8C;AAArC,kGAAA,OAAO,OAAA;AAChB,gDAA8C;AAArC,kGAAA,OAAO,OAAA;AAEhB,QAAQ;AACR,iDAA8C;AAArC,uGAAA,SAAS,OAAA;AAClB,6DAAyD;AAAhD,kHAAA,cAAc,OAAA;AAEvB,QAAQ;AACR,mCAAiC;AAAxB,0FAAA,GAAG,OAAA;AACZ,uCAAqC;AAA5B,8FAAA,KAAK,OAAA;AAEd,QAAQ;AACR,kDAAuB","sourcesContent":["export { Alert } from \"./components/alert\"\nexport { Avatar } from \"./components/avatar\"\nexport { Badge } from \"./components/badge\"\nexport { Button } from \"./components/button\"\nexport { Calendar } from \"./components/calendar\"\nexport { Checkbox } from \"./components/checkbox\"\nexport { Code } from \"./components/code\"\nexport { CodeBlock } from \"./components/code-block\"\nexport { Command } from \"./components/command\"\nexport { CommandBar } from \"./components/command-bar\"\nexport { Container } from \"./components/container\"\nexport { Copy } from \"./components/copy\"\nexport { CurrencyInput } from \"./components/currency-input\"\nexport { DatePicker } from \"./components/date-picker\"\nexport { Drawer } from \"./components/drawer\"\nexport { DropdownMenu } from \"./components/dropdown-menu\"\nexport { FocusModal } from \"./components/focus-modal\"\nexport { Heading } from \"./components/heading\"\nexport { Hint } from \"./components/hint\"\nexport { IconBadge } from \"./components/icon-badge\"\nexport { IconButton } from \"./components/icon-button\"\nexport { Input } from \"./components/input\"\nexport { Kbd } from \"./components/kbd\"\nexport { Label } from \"./components/label\"\nexport { Popover } from \"./components/popover\"\nexport { ProgressAccordion } from \"./components/progress-accordion\"\nexport { ProgressTabs } from \"./components/progress-tabs\"\nexport { Prompt } from \"./components/prompt\"\nexport { RadioGroup } from \"./components/radio-group\"\nexport { Select } from \"./components/select\"\nexport { StatusBadge } from \"./components/status-badge\"\nexport { Switch } from \"./components/switch\"\nexport { Table } from \"./components/table\"\nexport { Tabs } from \"./components/tabs\"\nexport { Text } from \"./components/text\"\nexport { Textarea } from \"./components/textarea\"\nexport { Toast } from \"./components/toast\"\nexport { Toaster } from \"./components/toaster\"\nexport { Tooltip } from \"./components/tooltip\"\n\n// Hooks\nexport { usePrompt } from \"./hooks/use-prompt\"\nexport { useToggleState } from \"./hooks/use-toggle-state\"\n\n// Utils\nexport { clx } from \"./utils/clx\"\nexport { toast } from \"./utils/toast\"\n\n// Types\nexport * from \"./types\"\n"]}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -9,3 +9,24 @@ export type DateRange = {
|
|
|
9
9
|
*/
|
|
10
10
|
to?: Date | undefined;
|
|
11
11
|
};
|
|
12
|
+
export type ToasterPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
13
|
+
export type ToastVariant = "info" | "success" | "warning" | "error" | "loading" | "message";
|
|
14
|
+
export type ToastActionVariant = "default" | "destructive";
|
|
15
|
+
export type ToastAction = {
|
|
16
|
+
/**
|
|
17
|
+
* The button's text.
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
/**
|
|
21
|
+
* The button's alt text.
|
|
22
|
+
*/
|
|
23
|
+
altText: string;
|
|
24
|
+
/**
|
|
25
|
+
* The function to execute when the button is clicked.
|
|
26
|
+
*/
|
|
27
|
+
onClick: () => void | Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The button's variant.
|
|
30
|
+
*/
|
|
31
|
+
variant?: ToastActionVariant;
|
|
32
|
+
};
|
package/dist/cjs/types.js
CHANGED
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,iBAAiB","sourcesContent":["// Progress types\n\nexport type ProgressStatus = \"not-started\" | \"in-progress\" | \"completed\"\n\n// Calendar types\n\nexport type DateRange = {\n /**\n * The range's start date.\n */\n from: Date | undefined\n /**\n * The range's end date.\n */\n to?: Date | undefined\n}\n\n// Toast types\n\nexport type ToasterPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\"\n\nexport type ToastVariant =\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"loading\"\n | \"message\"\n\nexport type ToastActionVariant = \"default\" | \"destructive\"\n\nexport type ToastAction = {\n /**\n * The button's text.\n */\n label: string\n /**\n * The button's alt text.\n */\n altText: string\n /**\n * The function to execute when the button is clicked.\n */\n onClick: () => void | Promise<void>\n /**\n * The button's variant.\n */\n variant?: ToastActionVariant\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ToastAction, ToasterPosition } from "../types";
|
|
2
|
+
interface BaseToastProps {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
position?: ToasterPosition;
|
|
5
|
+
dismissable?: boolean;
|
|
6
|
+
dismissLabel?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
9
|
+
interface ToastProps extends BaseToastProps {
|
|
10
|
+
description?: string;
|
|
11
|
+
action?: ToastAction;
|
|
12
|
+
}
|
|
13
|
+
declare function message(
|
|
14
|
+
/**
|
|
15
|
+
* The title of the toast.
|
|
16
|
+
*/
|
|
17
|
+
title: string,
|
|
18
|
+
/**
|
|
19
|
+
* The props of the toast.
|
|
20
|
+
*/
|
|
21
|
+
props?: ToastProps): string | number;
|
|
22
|
+
declare function info(
|
|
23
|
+
/**
|
|
24
|
+
* The title of the toast.
|
|
25
|
+
*/ title: string,
|
|
26
|
+
/**
|
|
27
|
+
* The props of the toast.
|
|
28
|
+
*/
|
|
29
|
+
props?: ToastProps): string | number;
|
|
30
|
+
declare function error(
|
|
31
|
+
/**
|
|
32
|
+
* The title of the toast.
|
|
33
|
+
*/ title: string,
|
|
34
|
+
/**
|
|
35
|
+
* The props of the toast.
|
|
36
|
+
*/
|
|
37
|
+
props?: ToastProps): string | number;
|
|
38
|
+
declare function success(
|
|
39
|
+
/**
|
|
40
|
+
* The title of the toast.
|
|
41
|
+
*/ title: string,
|
|
42
|
+
/**
|
|
43
|
+
* The props of the toast.
|
|
44
|
+
*/
|
|
45
|
+
props?: ToastProps): string | number;
|
|
46
|
+
declare function warning(
|
|
47
|
+
/**
|
|
48
|
+
* The title of the toast.
|
|
49
|
+
*/ title: string,
|
|
50
|
+
/**
|
|
51
|
+
* The props of the toast.
|
|
52
|
+
*/
|
|
53
|
+
props?: ToastProps): string | number;
|
|
54
|
+
declare function loading(title: string,
|
|
55
|
+
/**
|
|
56
|
+
* The props of the toast.
|
|
57
|
+
*/
|
|
58
|
+
props?: ToastProps): string | number;
|
|
59
|
+
type PromiseStateProps = string | {
|
|
60
|
+
title: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
};
|
|
63
|
+
interface PromiseToastProps extends BaseToastProps {
|
|
64
|
+
loading: PromiseStateProps;
|
|
65
|
+
success: PromiseStateProps;
|
|
66
|
+
error: PromiseStateProps;
|
|
67
|
+
}
|
|
68
|
+
declare function promise<TData>(
|
|
69
|
+
/**
|
|
70
|
+
* The promise to be resolved.
|
|
71
|
+
*/
|
|
72
|
+
promise: Promise<TData> | (() => Promise<TData>),
|
|
73
|
+
/**
|
|
74
|
+
* The props of the toast.
|
|
75
|
+
*/
|
|
76
|
+
props: PromiseToastProps): Promise<string | number>;
|
|
77
|
+
export declare const toast: typeof message & {
|
|
78
|
+
info: typeof info;
|
|
79
|
+
error: typeof error;
|
|
80
|
+
warning: typeof warning;
|
|
81
|
+
success: typeof success;
|
|
82
|
+
promise: typeof promise;
|
|
83
|
+
loading: typeof loading;
|
|
84
|
+
dismiss: (id?: string | number | undefined) => string | number;
|
|
85
|
+
};
|
|
86
|
+
export {};
|