tw-react-components 0.0.178 → 0.0.180
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/index.css +10 -4
- package/index.esm.js +156 -2
- package/package.json +1 -1
- package/src/components/Toast/index.d.ts +36 -0
- package/src/components/Toaster/index.d.ts +1 -0
- package/src/components/index.d.ts +2 -0
- package/src/hooks/index.d.ts +1 -0
- package/src/hooks/useToast.d.ts +44 -0
- package/tailwindcss-plugin.cjs +6 -2
package/index.css
CHANGED
|
@@ -26,8 +26,11 @@
|
|
|
26
26
|
--accent: 210 40% 96.1%;
|
|
27
27
|
--accent-foreground: 222.2 47.4% 11.2%;
|
|
28
28
|
|
|
29
|
-
--
|
|
30
|
-
--
|
|
29
|
+
--success: var(--color-green-500);
|
|
30
|
+
--success-foreground: var(--color-neutral-50);
|
|
31
|
+
|
|
32
|
+
--destructive: var(--color-red-500);
|
|
33
|
+
--destructive-foreground: var(--color-neutral-50);
|
|
31
34
|
|
|
32
35
|
--ring: 215 20.2% 65.1%;
|
|
33
36
|
|
|
@@ -68,8 +71,11 @@
|
|
|
68
71
|
--secondary: 222.2 47.4% 11.2%;
|
|
69
72
|
--secondary-foreground: 210 40% 98%;
|
|
70
73
|
|
|
71
|
-
--
|
|
72
|
-
--
|
|
74
|
+
--success: var(--color-green-600);
|
|
75
|
+
--success-foreground: var(--color-gray-100);
|
|
76
|
+
|
|
77
|
+
--destructive: var(--color-red-600);
|
|
78
|
+
--destructive-foreground: var(--color-gray-100);
|
|
73
79
|
|
|
74
80
|
--ring: 216 34% 17%;
|
|
75
81
|
|
package/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import dayjs from 'dayjs';
|
|
|
5
5
|
import 'dayjs/locale/en.js';
|
|
6
6
|
import advancedFormat from 'dayjs/plugin/advancedFormat.js';
|
|
7
7
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
8
|
-
import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon, PanelLeft, GripVertical, MoonIcon, SunIcon, MonitorIcon } from 'lucide-react';
|
|
8
|
+
import { HelpCircle, XIcon, AtSignIcon, EyeIcon, EyeOffIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronDownIcon, CalendarIcon, ClockIcon, CheckIcon, CircleIcon, CloudUploadIcon, ChevronsLeftIcon, ChevronsRightIcon, ChevronsDownUpIcon, ChevronsUpDownIcon, ArrowUpDownIcon, SortAscIcon, SortDescIcon, MinusIcon, PlusIcon, PanelLeft, GripVertical, MoonIcon, SunIcon, MonitorIcon, X } from 'lucide-react';
|
|
9
9
|
import { useMemo, useState, useEffect, useId, useCallback, useRef, createContext, useContext } from 'react';
|
|
10
10
|
import localeData from 'dayjs/plugin/localeData.js';
|
|
11
11
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
@@ -23,6 +23,7 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
|
23
23
|
import * as ResizablePrimitive from 'react-resizable-panels';
|
|
24
24
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
25
25
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
26
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
26
27
|
|
|
27
28
|
/******************************************************************************
|
|
28
29
|
Copyright (c) Microsoft Corporation.
|
|
@@ -786,6 +787,98 @@ function usePagination(currentIndex, totalPages) {
|
|
|
786
787
|
}, [currentIndex, totalPages]);
|
|
787
788
|
}
|
|
788
789
|
|
|
790
|
+
const TOAST_LIMIT = 1;
|
|
791
|
+
const TOAST_REMOVE_DELAY = 5000; // 5 seconds
|
|
792
|
+
let count = 0;
|
|
793
|
+
function genId() {
|
|
794
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
795
|
+
return count.toString();
|
|
796
|
+
}
|
|
797
|
+
const toastTimeouts = new Map();
|
|
798
|
+
const addToRemoveQueue = (toastId) => {
|
|
799
|
+
if (toastTimeouts.has(toastId)) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const timeout = setTimeout(() => {
|
|
803
|
+
toastTimeouts.delete(toastId);
|
|
804
|
+
dispatch({
|
|
805
|
+
type: 'REMOVE_TOAST',
|
|
806
|
+
toastId: toastId,
|
|
807
|
+
});
|
|
808
|
+
}, TOAST_REMOVE_DELAY);
|
|
809
|
+
toastTimeouts.set(toastId, timeout);
|
|
810
|
+
};
|
|
811
|
+
const reducer = (state, action) => {
|
|
812
|
+
switch (action.type) {
|
|
813
|
+
case 'ADD_TOAST':
|
|
814
|
+
return Object.assign(Object.assign({}, state), { toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT) });
|
|
815
|
+
case 'UPDATE_TOAST':
|
|
816
|
+
return Object.assign(Object.assign({}, state), { toasts: state.toasts.map((t) => (t.id === action.toast.id ? Object.assign(Object.assign({}, t), action.toast) : t)) });
|
|
817
|
+
case 'DISMISS_TOAST': {
|
|
818
|
+
const { toastId } = action;
|
|
819
|
+
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
820
|
+
// but I'll keep it here for simplicity
|
|
821
|
+
if (toastId) {
|
|
822
|
+
addToRemoveQueue(toastId);
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
state.toasts.forEach((toast) => {
|
|
826
|
+
addToRemoveQueue(toast.id);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
return Object.assign(Object.assign({}, state), { toasts: state.toasts.map((t) => t.id === toastId || toastId === undefined
|
|
830
|
+
? Object.assign(Object.assign({}, t), { open: false }) : t) });
|
|
831
|
+
}
|
|
832
|
+
case 'REMOVE_TOAST':
|
|
833
|
+
if (action.toastId === undefined) {
|
|
834
|
+
return Object.assign(Object.assign({}, state), { toasts: [] });
|
|
835
|
+
}
|
|
836
|
+
return Object.assign(Object.assign({}, state), { toasts: state.toasts.filter((t) => t.id !== action.toastId) });
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
const listeners = [];
|
|
840
|
+
let memoryState = { toasts: [] };
|
|
841
|
+
function dispatch(action) {
|
|
842
|
+
memoryState = reducer(memoryState, action);
|
|
843
|
+
listeners.forEach((listener) => {
|
|
844
|
+
listener(memoryState);
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
function toast(_a) {
|
|
848
|
+
var props = __rest(_a, []);
|
|
849
|
+
const id = genId();
|
|
850
|
+
const update = (props) => dispatch({
|
|
851
|
+
type: 'UPDATE_TOAST',
|
|
852
|
+
toast: Object.assign(Object.assign({}, props), { id }),
|
|
853
|
+
});
|
|
854
|
+
const dismiss = () => dispatch({ type: 'DISMISS_TOAST', toastId: id });
|
|
855
|
+
dispatch({
|
|
856
|
+
type: 'ADD_TOAST',
|
|
857
|
+
toast: Object.assign(Object.assign({}, props), { id, open: true, onOpenChange: (open) => {
|
|
858
|
+
if (!open)
|
|
859
|
+
dismiss();
|
|
860
|
+
} }),
|
|
861
|
+
});
|
|
862
|
+
return {
|
|
863
|
+
id: id,
|
|
864
|
+
dismiss,
|
|
865
|
+
update,
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function useToast() {
|
|
869
|
+
const [state, setState] = useState(memoryState);
|
|
870
|
+
useEffect(() => {
|
|
871
|
+
listeners.push(setState);
|
|
872
|
+
return () => {
|
|
873
|
+
const index = listeners.indexOf(setState);
|
|
874
|
+
if (index > -1) {
|
|
875
|
+
listeners.splice(index, 1);
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
}, [state]);
|
|
879
|
+
return Object.assign(Object.assign({}, state), { toast, dismiss: (toastId) => dispatch({ type: 'DISMISS_TOAST', toastId }) });
|
|
880
|
+
}
|
|
881
|
+
|
|
789
882
|
const Tooltip = ({ children, className, content, asChild, placement, dataTestId = 'tooltip', }) => (jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: jsxs(TooltipPrimitive.Root, { children: [jsx(TooltipPrimitive.Trigger, { asChild: asChild, "data-testid": `${dataTestId}-trigger`, children: children }), jsx(TooltipPrimitive.Portal, { children: jsx(TooltipPrimitive.Content, { className: cn('animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', 'z-[101] overflow-hidden rounded-md border bg-white px-3 py-1.5 text-sm shadow-md dark:border-slate-700 dark:bg-slate-800 dark:text-white', className), side: placement, sideOffset: 5, "data-testid": `${dataTestId}-content`, children: content }) })] }) }));
|
|
790
883
|
|
|
791
884
|
const Label = ({ children, className, description, required, hasErrors, htmlFor, dataTestId = 'label', }) => {
|
|
@@ -2246,4 +2339,65 @@ const ThemeSelector = ({ className, dataTestId = 'theme-selector' }) => {
|
|
|
2246
2339
|
return (jsxs(DropdownMenu, { children: [jsx(DropdownMenu.Trigger, { asChild: true, dataTestId: `${dataTestId}-trigger`, children: jsx(Button, { prefixIcon: resolvedTheme === 'dark' ? MoonIcon : SunIcon, className: className, variant: "text" }) }), jsxs(DropdownMenu.Content, { dataTestId: `${dataTestId}-content`, children: [jsxs(DropdownMenu.Item, { onClick: () => setTheme('light'), dataTestId: `${dataTestId}-light`, children: [jsx(DropdownMenu.Icon, { icon: SunIcon }), "Light"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('dark'), dataTestId: `${dataTestId}-dark`, children: [jsx(DropdownMenu.Icon, { icon: MoonIcon }), "Dark"] }), jsxs(DropdownMenu.Item, { onClick: () => setTheme('system'), dataTestId: `${dataTestId}-system`, children: [jsx(DropdownMenu.Icon, { icon: MonitorIcon }), "System"] })] })] }));
|
|
2247
2340
|
};
|
|
2248
2341
|
|
|
2249
|
-
|
|
2342
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
2343
|
+
const ToastViewport = (_a) => {
|
|
2344
|
+
var { className, dataTestId = 'toast-viewport' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2345
|
+
return (jsx(ToastPrimitives.Viewport, Object.assign({ className: cn('fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:top-auto sm:right-0 sm:bottom-0 sm:flex-col md:max-w-[420px]', className), "data-testid": dataTestId }, props)));
|
|
2346
|
+
};
|
|
2347
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
2348
|
+
const toastVariants = cva('group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full', {
|
|
2349
|
+
variants: {
|
|
2350
|
+
variant: {
|
|
2351
|
+
default: 'border bg-background text-foreground',
|
|
2352
|
+
success: 'success group border-success bg-success text-success-foreground',
|
|
2353
|
+
destructive: 'destructive group border-destructive bg-destructive text-destructive-foreground',
|
|
2354
|
+
},
|
|
2355
|
+
},
|
|
2356
|
+
defaultVariants: {
|
|
2357
|
+
variant: 'default',
|
|
2358
|
+
},
|
|
2359
|
+
});
|
|
2360
|
+
const ToastRoot = (_a) => {
|
|
2361
|
+
var { className, variant, dataTestId = 'toast' } = _a, props = __rest(_a, ["className", "variant", "dataTestId"]);
|
|
2362
|
+
return (jsx(ToastPrimitives.Root, Object.assign({ className: cn(toastVariants({ variant }), className), "data-testid": dataTestId }, props)));
|
|
2363
|
+
};
|
|
2364
|
+
ToastRoot.displayName = ToastPrimitives.Root.displayName;
|
|
2365
|
+
const ToastAction = (_a) => {
|
|
2366
|
+
var { className, dataTestId = 'toast-action' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2367
|
+
return (jsx(ToastPrimitives.Action, Object.assign({ className: cn('hover:bg-secondary focus:ring-ring inline-flex h-8 shrink-0 cursor-pointer items-center justify-center rounded-md border bg-transparent px-3 font-medium transition-colors focus:ring-1 focus:outline-none disabled:pointer-events-none disabled:opacity-50', 'group-[.success]:border-muted/40 group-[.success]:hover:border-success/30 group-[.success]:hover:bg-success group-[.success]:hover:text-success-foreground group-[.success]:focus:ring-success', 'group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive', className), "data-testid": dataTestId }, props)));
|
|
2368
|
+
};
|
|
2369
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
2370
|
+
const ToastClose = (_a) => {
|
|
2371
|
+
var { className, dataTestId = 'toast-close' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2372
|
+
return (jsx(ToastPrimitives.Close, Object.assign({ className: cn('text-foreground/50 hover:text-foreground absolute top-1 right-1 cursor-pointer rounded-md p-1 opacity-0 transition-opacity group-hover:opacity-100 focus:opacity-100 focus:ring-1 focus:outline-none', 'group-[.success]:text-green-300 group-[.success]:hover:text-green-50 group-[.success]:focus:ring-green-400 group-[.success]:focus:ring-offset-green-600', 'group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600', className), "toast-close": "", "data-testid": dataTestId }, props, { children: jsx(X, { className: "h-4 w-4" }) })));
|
|
2373
|
+
};
|
|
2374
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
2375
|
+
const ToastTitle = (_a) => {
|
|
2376
|
+
var { className, dataTestId = 'toast-title' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2377
|
+
return (jsx(ToastPrimitives.Title, Object.assign({ className: cn('font-semibold [&+div]:text-sm', className), "data-testid": dataTestId }, props)));
|
|
2378
|
+
};
|
|
2379
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
2380
|
+
const ToastDescription = (_a) => {
|
|
2381
|
+
var { className, dataTestId = 'toast-description' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2382
|
+
return (jsx(ToastPrimitives.Description, Object.assign({ className: cn('opacity-90', className), "data-testid": dataTestId }, props)));
|
|
2383
|
+
};
|
|
2384
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
2385
|
+
const Toast = Object.assign({}, {
|
|
2386
|
+
Provider: ToastProvider,
|
|
2387
|
+
Viewport: ToastViewport,
|
|
2388
|
+
Root: ToastRoot,
|
|
2389
|
+
Title: ToastTitle,
|
|
2390
|
+
Description: ToastDescription,
|
|
2391
|
+
Close: ToastClose,
|
|
2392
|
+
Action: ToastAction,
|
|
2393
|
+
});
|
|
2394
|
+
|
|
2395
|
+
function Toaster() {
|
|
2396
|
+
const { toasts } = useToast();
|
|
2397
|
+
return (jsxs(Toast.Provider, { children: [toasts.map(function (_a) {
|
|
2398
|
+
var { id, title, description, action } = _a, props = __rest(_a, ["id", "title", "description", "action"]);
|
|
2399
|
+
return (jsxs(Toast.Root, Object.assign({}, props, { children: [jsxs("div", { className: "grid gap-1", children: [title && jsx(Toast.Title, { children: title }), description && jsx(Toast.Description, { children: description })] }), action, jsx(Toast.Close, {})] }), id));
|
|
2400
|
+
}), jsx(Toast.Viewport, {})] }));
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
export { Badge, BasicInput, BasicInputExtension, Block, Button, Card, CheckboxInput, Collapsible, ConfirmDialog, DataTable, DateTimeInput, Dialog, DropdownMenu, EmailInput, FileInput, Flex, FormDialog, FormGroup, FormInputs, Hint, Label, Layout, LayoutContext, LayoutContextProvider, List, ListSorter, ListSorterDialog, Navbar, NumberInput, Pagination, PasswordInput, PdfViewerDialog, Popover, Resizable, SHOW_IDS_COOKIE_MAX_AGE, SHOW_IDS_COOKIE_NAME, SIDEBAR_COOKIE_MAX_AGE, SIDEBAR_COOKIE_NAME, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, SelectInput, Separator, Sheet, Sidebar, SidebarContext, SidebarContextProvider, Skeleton, Spinner, Switch, THEME_COOKIE_MAX_AGE, THEME_COOKIE_NAME, THEME_MEDIA_QUERY, Table, Tabs, TextInput, TextareaInput, ThemeSelector, Toast, Toaster, Tooltip, cn, compareDates, generalComparator, getDisplayDate, getValueFromCookie, isEmpty, reducer, resolveTargetObject, toast, useDays, useIsMobile, useLayoutContext, useLongPress, useMonths, useOnSwipe, useOutsideClick, usePagination, useSidebar, useToast };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tw-react-components",
|
|
3
3
|
"description": "A set of React components build with TailwindCSS to make a nice dashboard.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.180",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://bacali95.github.io/tw-react-components",
|
|
7
7
|
"type": "module",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as ToastPrimitives from '@radix-ui/react-toast';
|
|
2
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import type { ComponentProps, FC, ReactElement } from 'react';
|
|
4
|
+
export type ToastViewportProps = ComponentProps<typeof ToastPrimitives.Viewport> & {
|
|
5
|
+
dataTestId?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const toastVariants: (props?: ({
|
|
8
|
+
variant?: "default" | "success" | "destructive" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
10
|
+
export type ToastProps = ComponentProps<typeof ToastPrimitives.Root> & VariantProps<typeof toastVariants> & {
|
|
11
|
+
dataTestId?: string;
|
|
12
|
+
};
|
|
13
|
+
export type ToastActionProps = ComponentProps<typeof ToastPrimitives.Action> & {
|
|
14
|
+
dataTestId?: string;
|
|
15
|
+
};
|
|
16
|
+
declare const ToastAction: FC<ToastActionProps>;
|
|
17
|
+
export type ToastCloseProps = ComponentProps<typeof ToastPrimitives.Close> & {
|
|
18
|
+
dataTestId?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ToastTitleProps = ComponentProps<typeof ToastPrimitives.Title> & {
|
|
21
|
+
dataTestId?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ToastDescriptionProps = ComponentProps<typeof ToastPrimitives.Description> & {
|
|
24
|
+
dataTestId?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ToastActionElement = ReactElement<typeof ToastAction>;
|
|
27
|
+
export declare const Toast: {
|
|
28
|
+
Provider: FC<ToastPrimitives.ToastProviderProps>;
|
|
29
|
+
Viewport: FC<ToastViewportProps>;
|
|
30
|
+
Root: FC<ToastProps>;
|
|
31
|
+
Title: FC<ToastTitleProps>;
|
|
32
|
+
Description: FC<ToastDescriptionProps>;
|
|
33
|
+
Close: FC<ToastCloseProps>;
|
|
34
|
+
Action: FC<ToastActionProps>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Toaster(): import("react/jsx-runtime").JSX.Element;
|
package/src/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { ToastActionElement, ToastProps } from '../components';
|
|
3
|
+
export type ToasterToast = ToastProps & {
|
|
4
|
+
id: string;
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
action?: ToastActionElement;
|
|
8
|
+
};
|
|
9
|
+
declare const actionTypes: {
|
|
10
|
+
readonly ADD_TOAST: "ADD_TOAST";
|
|
11
|
+
readonly UPDATE_TOAST: "UPDATE_TOAST";
|
|
12
|
+
readonly DISMISS_TOAST: "DISMISS_TOAST";
|
|
13
|
+
readonly REMOVE_TOAST: "REMOVE_TOAST";
|
|
14
|
+
};
|
|
15
|
+
type ActionType = typeof actionTypes;
|
|
16
|
+
type Action = {
|
|
17
|
+
type: ActionType['ADD_TOAST'];
|
|
18
|
+
toast: ToasterToast;
|
|
19
|
+
} | {
|
|
20
|
+
type: ActionType['UPDATE_TOAST'];
|
|
21
|
+
toast: Partial<ToasterToast>;
|
|
22
|
+
} | {
|
|
23
|
+
type: ActionType['DISMISS_TOAST'];
|
|
24
|
+
toastId?: ToasterToast['id'];
|
|
25
|
+
} | {
|
|
26
|
+
type: ActionType['REMOVE_TOAST'];
|
|
27
|
+
toastId?: ToasterToast['id'];
|
|
28
|
+
};
|
|
29
|
+
interface State {
|
|
30
|
+
toasts: ToasterToast[];
|
|
31
|
+
}
|
|
32
|
+
export declare const reducer: (state: State, action: Action) => State;
|
|
33
|
+
type Toast = Omit<ToasterToast, 'id'>;
|
|
34
|
+
declare function toast({ ...props }: Toast): {
|
|
35
|
+
id: string;
|
|
36
|
+
dismiss: () => void;
|
|
37
|
+
update: (props: ToasterToast) => void;
|
|
38
|
+
};
|
|
39
|
+
declare function useToast(): {
|
|
40
|
+
toast: typeof toast;
|
|
41
|
+
dismiss: (toastId?: string) => void;
|
|
42
|
+
toasts: ToasterToast[];
|
|
43
|
+
};
|
|
44
|
+
export { useToast, toast };
|
package/tailwindcss-plugin.cjs
CHANGED
|
@@ -28,9 +28,13 @@ module.exports = plugin(
|
|
|
28
28
|
DEFAULT: 'hsl(var(--secondary))',
|
|
29
29
|
foreground: 'hsl(var(--secondary-foreground))',
|
|
30
30
|
},
|
|
31
|
+
success: {
|
|
32
|
+
DEFAULT: 'var(--success)',
|
|
33
|
+
foreground: 'var(--success-foreground)',
|
|
34
|
+
},
|
|
31
35
|
destructive: {
|
|
32
|
-
DEFAULT: '
|
|
33
|
-
foreground: '
|
|
36
|
+
DEFAULT: 'var(--destructive)',
|
|
37
|
+
foreground: 'var(--destructive-foreground)',
|
|
34
38
|
},
|
|
35
39
|
muted: {
|
|
36
40
|
DEFAULT: 'hsl(var(--muted))',
|