tw-react-components 0.0.178 → 0.0.182
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 +186 -3
- 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', }) => {
|
|
@@ -1680,12 +1773,20 @@ const Dialog = Object.assign($Dialog, {
|
|
|
1680
1773
|
});
|
|
1681
1774
|
|
|
1682
1775
|
const ConfirmDialog = ({ open, title, children, yesLabel, noLabel, onConfirm, onClose, dataTestId = 'confirm-dialog', }) => {
|
|
1776
|
+
const { toast } = useToast();
|
|
1683
1777
|
const [loading, setLoading] = useState(false);
|
|
1684
1778
|
const handleConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1685
1779
|
setLoading(true);
|
|
1686
1780
|
try {
|
|
1687
1781
|
yield onConfirm();
|
|
1688
1782
|
}
|
|
1783
|
+
catch (error) {
|
|
1784
|
+
toast({
|
|
1785
|
+
variant: 'destructive',
|
|
1786
|
+
title: 'Error',
|
|
1787
|
+
description: error instanceof Error ? error.message : 'Something went wrong',
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1689
1790
|
finally {
|
|
1690
1791
|
setLoading(false);
|
|
1691
1792
|
}
|
|
@@ -1754,7 +1855,20 @@ const Sheet = Object.assign(DialogPrimitive.Root, {
|
|
|
1754
1855
|
|
|
1755
1856
|
const FormDialog = ({ className, formClassName, open, title, form, children, submitLabel = 'Submit', cancelLabel = 'Cancel', extraAction, as: As = Sheet, onSubmit, onInvalid, onClose, dataTestId = 'form-dialog', }) => {
|
|
1756
1857
|
const id = useId();
|
|
1757
|
-
|
|
1858
|
+
const { toast } = useToast();
|
|
1859
|
+
const handleSubmit = (data, event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1860
|
+
try {
|
|
1861
|
+
yield onSubmit(data, event);
|
|
1862
|
+
}
|
|
1863
|
+
catch (error) {
|
|
1864
|
+
toast({
|
|
1865
|
+
variant: 'destructive',
|
|
1866
|
+
title: 'Error',
|
|
1867
|
+
description: error instanceof Error ? error.message : 'Something went wrong',
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
return (jsx(As, { open: open, onOpenChange: (value) => !value && onClose(), children: jsxs(As.Content, { className: className, dataTestId: `${dataTestId}-content`, children: [jsx(As.Header, { dataTestId: `${dataTestId}-header`, children: jsx(As.Title, { dataTestId: `${dataTestId}-title`, children: title }) }), jsx(FormProvider, Object.assign({}, form, { children: jsx("form", { id: `form-${id}`, className: cn('flex h-full w-full flex-col gap-2 overflow-auto', formClassName), onSubmit: form.handleSubmit(handleSubmit, onInvalid), "data-testid": `${dataTestId}-form`, children: children }) })), jsxs(As.Footer, { className: "w-full sm:justify-between", dataTestId: `${dataTestId}-footer`, children: [extraAction, jsxs(As.Footer, { className: "ml-auto", dataTestId: `${dataTestId}-actions`, children: [jsx(As.Close, { asChild: true, children: jsx(Button, { color: "red", dataTestId: `${dataTestId}-cancel-button`, disabled: form.formState.isSubmitting, children: cancelLabel }) }), jsx(Button, { color: "green", type: "submit", form: `form-${id}`, loading: form.formState.isSubmitting, dataTestId: `${dataTestId}-submit-button`, children: submitLabel })] })] })] }) }));
|
|
1758
1872
|
};
|
|
1759
1873
|
|
|
1760
1874
|
function ListSorter({ className, items, dataTestId = 'list-sorter', idResolver, renderer, onChange, }) {
|
|
@@ -1784,6 +1898,7 @@ function SortableItem({ item, index, dataTestId, renderer, }) {
|
|
|
1784
1898
|
}
|
|
1785
1899
|
|
|
1786
1900
|
function ListSorterDialog({ className, open, title, items, idResolver, renderer, cancelLabel, submitLabel, onSubmit, onClose, dataTestId = 'list-sorter-dialog', }) {
|
|
1901
|
+
const { toast } = useToast();
|
|
1787
1902
|
const [sortedItems, setSortedItems] = useState(structuredClone(items));
|
|
1788
1903
|
const [loading, setLoading] = useState(false);
|
|
1789
1904
|
useEffect(() => {
|
|
@@ -1796,6 +1911,13 @@ function ListSorterDialog({ className, open, title, items, idResolver, renderer,
|
|
|
1796
1911
|
try {
|
|
1797
1912
|
yield onSubmit(sortedItems);
|
|
1798
1913
|
}
|
|
1914
|
+
catch (error) {
|
|
1915
|
+
toast({
|
|
1916
|
+
variant: 'destructive',
|
|
1917
|
+
title: 'Error',
|
|
1918
|
+
description: error instanceof Error ? error.message : 'Something went wrong',
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1799
1921
|
finally {
|
|
1800
1922
|
setLoading(false);
|
|
1801
1923
|
}
|
|
@@ -2246,4 +2368,65 @@ const ThemeSelector = ({ className, dataTestId = 'theme-selector' }) => {
|
|
|
2246
2368
|
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
2369
|
};
|
|
2248
2370
|
|
|
2249
|
-
|
|
2371
|
+
const ToastProvider = ToastPrimitives.Provider;
|
|
2372
|
+
const ToastViewport = (_a) => {
|
|
2373
|
+
var { className, dataTestId = 'toast-viewport' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2374
|
+
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)));
|
|
2375
|
+
};
|
|
2376
|
+
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
|
|
2377
|
+
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', {
|
|
2378
|
+
variants: {
|
|
2379
|
+
variant: {
|
|
2380
|
+
default: 'border bg-background text-foreground',
|
|
2381
|
+
success: 'success group border-success bg-success text-success-foreground',
|
|
2382
|
+
destructive: 'destructive group border-destructive bg-destructive text-destructive-foreground',
|
|
2383
|
+
},
|
|
2384
|
+
},
|
|
2385
|
+
defaultVariants: {
|
|
2386
|
+
variant: 'default',
|
|
2387
|
+
},
|
|
2388
|
+
});
|
|
2389
|
+
const ToastRoot = (_a) => {
|
|
2390
|
+
var { className, variant, dataTestId = 'toast' } = _a, props = __rest(_a, ["className", "variant", "dataTestId"]);
|
|
2391
|
+
return (jsx(ToastPrimitives.Root, Object.assign({ className: cn(toastVariants({ variant }), className), "data-testid": dataTestId }, props)));
|
|
2392
|
+
};
|
|
2393
|
+
ToastRoot.displayName = ToastPrimitives.Root.displayName;
|
|
2394
|
+
const ToastAction = (_a) => {
|
|
2395
|
+
var { className, dataTestId = 'toast-action' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2396
|
+
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)));
|
|
2397
|
+
};
|
|
2398
|
+
ToastAction.displayName = ToastPrimitives.Action.displayName;
|
|
2399
|
+
const ToastClose = (_a) => {
|
|
2400
|
+
var { className, dataTestId = 'toast-close' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2401
|
+
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" }) })));
|
|
2402
|
+
};
|
|
2403
|
+
ToastClose.displayName = ToastPrimitives.Close.displayName;
|
|
2404
|
+
const ToastTitle = (_a) => {
|
|
2405
|
+
var { className, dataTestId = 'toast-title' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2406
|
+
return (jsx(ToastPrimitives.Title, Object.assign({ className: cn('font-semibold [&+div]:text-sm', className), "data-testid": dataTestId }, props)));
|
|
2407
|
+
};
|
|
2408
|
+
ToastTitle.displayName = ToastPrimitives.Title.displayName;
|
|
2409
|
+
const ToastDescription = (_a) => {
|
|
2410
|
+
var { className, dataTestId = 'toast-description' } = _a, props = __rest(_a, ["className", "dataTestId"]);
|
|
2411
|
+
return (jsx(ToastPrimitives.Description, Object.assign({ className: cn('opacity-90', className), "data-testid": dataTestId }, props)));
|
|
2412
|
+
};
|
|
2413
|
+
ToastDescription.displayName = ToastPrimitives.Description.displayName;
|
|
2414
|
+
const Toast = Object.assign({}, {
|
|
2415
|
+
Provider: ToastProvider,
|
|
2416
|
+
Viewport: ToastViewport,
|
|
2417
|
+
Root: ToastRoot,
|
|
2418
|
+
Title: ToastTitle,
|
|
2419
|
+
Description: ToastDescription,
|
|
2420
|
+
Close: ToastClose,
|
|
2421
|
+
Action: ToastAction,
|
|
2422
|
+
});
|
|
2423
|
+
|
|
2424
|
+
function Toaster() {
|
|
2425
|
+
const { toasts } = useToast();
|
|
2426
|
+
return (jsxs(Toast.Provider, { children: [toasts.map(function (_a) {
|
|
2427
|
+
var { id, title, description, action } = _a, props = __rest(_a, ["id", "title", "description", "action"]);
|
|
2428
|
+
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));
|
|
2429
|
+
}), jsx(Toast.Viewport, {})] }));
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
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.182",
|
|
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))',
|