@rovula/ui 0.0.44 → 0.0.46
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/dist/cjs/bundle.css +27 -0
- package/dist/cjs/bundle.js +3 -3
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/Toast/Toast.stories.d.ts +8 -0
- package/dist/cjs/types/components/Toast/Toaster.d.ts +2 -1
- package/dist/cjs/types/components/Toast/useToast.d.ts +1 -0
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Toast/Toast.stories.js +19 -0
- package/dist/components/Toast/Toaster.js +4 -3
- package/dist/components/Toast/useToast.js +5 -2
- package/dist/esm/bundle.css +27 -0
- package/dist/esm/bundle.js +2 -2
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/Toast/Toast.stories.d.ts +8 -0
- package/dist/esm/types/components/Toast/Toaster.d.ts +2 -1
- package/dist/esm/types/components/Toast/useToast.d.ts +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/src/theme/global.css +34 -0
- package/package.json +1 -1
- package/src/components/Dropdown/Dropdown.tsx +1 -1
- package/src/components/Toast/Toast.stories.tsx +50 -0
- package/src/components/Toast/Toaster.tsx +5 -3
- package/src/components/Toast/useToast.ts +6 -2
|
@@ -356,3 +356,11 @@ export declare const WithAction: {
|
|
|
356
356
|
args: {};
|
|
357
357
|
render: (args: {}) => import("react/jsx-runtime").JSX.Element;
|
|
358
358
|
};
|
|
359
|
+
export declare const Custom: {
|
|
360
|
+
args: {
|
|
361
|
+
onClose: import("@storybook/addon-actions").HandlerFunction;
|
|
362
|
+
};
|
|
363
|
+
render: (args: {
|
|
364
|
+
onClose?: (() => void) | undefined;
|
|
365
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
366
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ToastProviderProps } from "@radix-ui/react-toast";
|
|
1
2
|
type ToasterProps = {
|
|
2
3
|
viewportClassName?: string;
|
|
3
4
|
titleClassName?: string;
|
|
@@ -6,5 +7,5 @@ type ToasterProps = {
|
|
|
6
7
|
iconWrapperClassName?: string;
|
|
7
8
|
actionWrapperClassName?: string;
|
|
8
9
|
};
|
|
9
|
-
export declare function Toaster({ viewportClassName, titleClassName, descriptionClassName, contentClassName, iconWrapperClassName, actionWrapperClassName, }: ToasterProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function Toaster({ viewportClassName, titleClassName, descriptionClassName, contentClassName, iconWrapperClassName, actionWrapperClassName, ...toastProviderProps }: ToasterProps & ToastProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -6,6 +6,7 @@ type ToasterToast = ToastProps & {
|
|
|
6
6
|
description?: React.ReactNode;
|
|
7
7
|
action?: ToastActionElement;
|
|
8
8
|
contentMode?: "vertical" | "horizontal";
|
|
9
|
+
onClose?: () => void;
|
|
9
10
|
};
|
|
10
11
|
type ToasterPosition = "top-center" | "top-left" | "top-right" | "bottom-center" | "bottom-left" | "bottom-right" | undefined;
|
|
11
12
|
declare const actionTypes: {
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
|
15
15
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
16
16
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
17
17
|
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
18
|
+
import { ToastProviderProps } from '@radix-ui/react-toast';
|
|
18
19
|
import { ClassValue } from 'clsx';
|
|
19
20
|
|
|
20
21
|
type ButtonProps = {
|
|
@@ -543,7 +544,7 @@ type ToasterProps = {
|
|
|
543
544
|
iconWrapperClassName?: string;
|
|
544
545
|
actionWrapperClassName?: string;
|
|
545
546
|
};
|
|
546
|
-
declare function Toaster({ viewportClassName, titleClassName, descriptionClassName, contentClassName, iconWrapperClassName, actionWrapperClassName, }: ToasterProps): react_jsx_runtime.JSX.Element;
|
|
547
|
+
declare function Toaster({ viewportClassName, titleClassName, descriptionClassName, contentClassName, iconWrapperClassName, actionWrapperClassName, ...toastProviderProps }: ToasterProps & ToastProviderProps): react_jsx_runtime.JSX.Element;
|
|
547
548
|
|
|
548
549
|
type ToasterToast = ToastProps & {
|
|
549
550
|
id: string;
|
|
@@ -551,6 +552,7 @@ type ToasterToast = ToastProps & {
|
|
|
551
552
|
description?: React.ReactNode;
|
|
552
553
|
action?: ToastActionElement;
|
|
553
554
|
contentMode?: "vertical" | "horizontal";
|
|
555
|
+
onClose?: () => void;
|
|
554
556
|
};
|
|
555
557
|
type ToasterPosition = "top-center" | "top-left" | "top-right" | "bottom-center" | "bottom-left" | "bottom-right" | undefined;
|
|
556
558
|
declare const actionTypes: {
|
|
@@ -2307,6 +2307,10 @@ input[type=number] {
|
|
|
2307
2307
|
margin-right: -0.5rem;
|
|
2308
2308
|
}
|
|
2309
2309
|
|
|
2310
|
+
.-mt-\[30px\] {
|
|
2311
|
+
margin-top: -30px;
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2310
2314
|
.ml-2 {
|
|
2311
2315
|
margin-left: 0.5rem;
|
|
2312
2316
|
}
|
|
@@ -3165,6 +3169,11 @@ input[type=number] {
|
|
|
3165
3169
|
border-color: color-mix(in srgb, var(--function-default-solid) calc(100% * var(--tw-border-opacity)), transparent);
|
|
3166
3170
|
}
|
|
3167
3171
|
|
|
3172
|
+
.border-info {
|
|
3173
|
+
--tw-border-opacity: 1;
|
|
3174
|
+
border-color: color-mix(in srgb, var(--state-color-info-default) calc(100% * var(--tw-border-opacity)), transparent);
|
|
3175
|
+
}
|
|
3176
|
+
|
|
3168
3177
|
.border-info-stroke {
|
|
3169
3178
|
--tw-border-opacity: 1;
|
|
3170
3179
|
border-color: color-mix(in srgb, var(--state-color-info-stroke) calc(100% * var(--tw-border-opacity)), transparent);
|
|
@@ -3658,6 +3667,11 @@ input[type=number] {
|
|
|
3658
3667
|
background-color: rgb(229 231 235 / var(--tw-bg-opacity));
|
|
3659
3668
|
}
|
|
3660
3669
|
|
|
3670
|
+
.bg-green-500 {
|
|
3671
|
+
--tw-bg-opacity: 1;
|
|
3672
|
+
background-color: rgb(34 197 94 / var(--tw-bg-opacity));
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3661
3675
|
.bg-grey-10 {
|
|
3662
3676
|
--tw-bg-opacity: 1;
|
|
3663
3677
|
background-color: color-mix(in srgb, var(--grey-grey-10) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -3983,6 +3997,11 @@ input[type=number] {
|
|
|
3983
3997
|
background-color: color-mix(in srgb, var(--input-color-label-bg) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
3984
3998
|
}
|
|
3985
3999
|
|
|
4000
|
+
.bg-pink-100 {
|
|
4001
|
+
--tw-bg-opacity: 1;
|
|
4002
|
+
background-color: rgb(252 231 243 / var(--tw-bg-opacity));
|
|
4003
|
+
}
|
|
4004
|
+
|
|
3986
4005
|
.bg-primary {
|
|
3987
4006
|
--tw-bg-opacity: 1;
|
|
3988
4007
|
background-color: color-mix(in srgb, var(--state-color-primary-default) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -4143,6 +4162,11 @@ input[type=number] {
|
|
|
4143
4162
|
background-color: color-mix(in srgb, var(--main-transparency-primary-8) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
4144
4163
|
}
|
|
4145
4164
|
|
|
4165
|
+
.bg-red-100 {
|
|
4166
|
+
--tw-bg-opacity: 1;
|
|
4167
|
+
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4146
4170
|
.bg-secondary {
|
|
4147
4171
|
--tw-bg-opacity: 1;
|
|
4148
4172
|
background-color: color-mix(in srgb, var(--state-color-secondary-default) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -5592,6 +5616,11 @@ input[type=number] {
|
|
|
5592
5616
|
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
5593
5617
|
}
|
|
5594
5618
|
|
|
5619
|
+
.text-grey2-500 {
|
|
5620
|
+
--tw-text-opacity: 1;
|
|
5621
|
+
color: color-mix(in srgb, var(--grey2-grey2-500) calc(100% * var(--tw-text-opacity)), transparent);
|
|
5622
|
+
}
|
|
5623
|
+
|
|
5595
5624
|
.text-info {
|
|
5596
5625
|
--tw-text-opacity: 1;
|
|
5597
5626
|
color: color-mix(in srgb, var(--state-color-info-default) calc(100% * var(--tw-text-opacity)), transparent);
|
|
@@ -5626,6 +5655,11 @@ input[type=number] {
|
|
|
5626
5655
|
color: color-mix(in srgb, var(--state-color-primary-default) calc(100% * var(--tw-text-opacity)), transparent);
|
|
5627
5656
|
}
|
|
5628
5657
|
|
|
5658
|
+
.text-red-500 {
|
|
5659
|
+
--tw-text-opacity: 1;
|
|
5660
|
+
color: rgb(239 68 68 / var(--tw-text-opacity));
|
|
5661
|
+
}
|
|
5662
|
+
|
|
5629
5663
|
.text-secondary {
|
|
5630
5664
|
--tw-text-opacity: 1;
|
|
5631
5665
|
color: color-mix(in srgb, var(--state-color-secondary-default) calc(100% * var(--tw-text-opacity)), transparent);
|
package/package.json
CHANGED
|
@@ -89,7 +89,7 @@ const Dropdown = forwardRef<HTMLInputElement, DropdownProps>(
|
|
|
89
89
|
) => {
|
|
90
90
|
const _id = id || `${label}-select`;
|
|
91
91
|
|
|
92
|
-
const [isFocused, setIsFocused] = useState(
|
|
92
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
93
93
|
const [selectedOption, setSelectedOption] = useState<
|
|
94
94
|
Options | null | undefined
|
|
95
95
|
>(null);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { action } from "@storybook/addon-actions";
|
|
4
5
|
import { Markdown } from "@storybook/blocks";
|
|
5
6
|
import { Toast, ToastAction } from "./Toast";
|
|
6
7
|
import { Toaster } from "./Toaster";
|
|
@@ -142,3 +143,52 @@ export const WithAction = {
|
|
|
142
143
|
);
|
|
143
144
|
},
|
|
144
145
|
} satisfies StoryObj;
|
|
146
|
+
|
|
147
|
+
export const Custom = {
|
|
148
|
+
args: {
|
|
149
|
+
onClose: action("Close Naja (*0_0*) "),
|
|
150
|
+
},
|
|
151
|
+
render: (args) => {
|
|
152
|
+
const props: typeof args = {
|
|
153
|
+
...args,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const { toast } = useToast();
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div className="flex flex-row gap-4 w-full">
|
|
160
|
+
<Toaster
|
|
161
|
+
viewportClassName="bg-red-100 -mt-[30px]"
|
|
162
|
+
titleClassName="text-red-500"
|
|
163
|
+
descriptionClassName="text-grey2-500"
|
|
164
|
+
contentClassName="bg-pink-100"
|
|
165
|
+
iconWrapperClassName="border-info border-2"
|
|
166
|
+
actionWrapperClassName="bg-green-500"
|
|
167
|
+
duration={3000} // default timeout
|
|
168
|
+
/>
|
|
169
|
+
<Button
|
|
170
|
+
onClick={() => {
|
|
171
|
+
toast({
|
|
172
|
+
title: "Uh oh! Something went wrong.",
|
|
173
|
+
description: "There was a problem with your request.",
|
|
174
|
+
action: (
|
|
175
|
+
<ToastAction
|
|
176
|
+
altText="Try again"
|
|
177
|
+
onClick={() => alert("My action")}
|
|
178
|
+
>
|
|
179
|
+
Try again
|
|
180
|
+
</ToastAction>
|
|
181
|
+
),
|
|
182
|
+
duration: 1000,
|
|
183
|
+
onClose: props.onClose,
|
|
184
|
+
});
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
Show Toast
|
|
188
|
+
</Button>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
} satisfies StoryObj<{
|
|
193
|
+
onClose?: () => void;
|
|
194
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useEffect } from "react";
|
|
4
4
|
import {
|
|
5
5
|
Toast,
|
|
6
6
|
ToastClose,
|
|
@@ -13,6 +13,7 @@ import { useToast } from "./useToast";
|
|
|
13
13
|
import Icon from "../Icon/Icon";
|
|
14
14
|
import { toastContentVariants, toastIconVariants } from "./Toast.styles";
|
|
15
15
|
import { cn } from "@/utils/cn";
|
|
16
|
+
import { ToastProviderProps } from "@radix-ui/react-toast";
|
|
16
17
|
|
|
17
18
|
type ToasterProps = {
|
|
18
19
|
viewportClassName?: string;
|
|
@@ -30,11 +31,12 @@ export function Toaster({
|
|
|
30
31
|
contentClassName,
|
|
31
32
|
iconWrapperClassName,
|
|
32
33
|
actionWrapperClassName,
|
|
33
|
-
|
|
34
|
+
...toastProviderProps
|
|
35
|
+
}: ToasterProps & ToastProviderProps) {
|
|
34
36
|
const { toasts, position } = useToast();
|
|
35
37
|
|
|
36
38
|
return (
|
|
37
|
-
<ToastProvider>
|
|
39
|
+
<ToastProvider {...toastProviderProps}>
|
|
38
40
|
{toasts.map(function ({
|
|
39
41
|
id,
|
|
40
42
|
title,
|
|
@@ -13,6 +13,7 @@ type ToasterToast = ToastProps & {
|
|
|
13
13
|
description?: React.ReactNode;
|
|
14
14
|
action?: ToastActionElement;
|
|
15
15
|
contentMode?: "vertical" | "horizontal";
|
|
16
|
+
onClose?: () => void;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
type ToasterPosition =
|
|
@@ -81,7 +82,7 @@ const addToRemoveQueue = (toastId: string) => {
|
|
|
81
82
|
type: "REMOVE_TOAST",
|
|
82
83
|
toastId: toastId,
|
|
83
84
|
});
|
|
84
|
-
}, TOAST_REMOVE_DELAY);
|
|
85
|
+
}, TOAST_REMOVE_DELAY);
|
|
85
86
|
|
|
86
87
|
toastTimeouts.set(toastId, timeout);
|
|
87
88
|
};
|
|
@@ -176,7 +177,10 @@ function toast({ ...props }: Toast) {
|
|
|
176
177
|
id,
|
|
177
178
|
open: true,
|
|
178
179
|
onOpenChange: (open) => {
|
|
179
|
-
if (!open)
|
|
180
|
+
if (!open) {
|
|
181
|
+
dismiss();
|
|
182
|
+
props?.onClose?.();
|
|
183
|
+
}
|
|
180
184
|
},
|
|
181
185
|
},
|
|
182
186
|
});
|