@kumix/ui 0.3.0 → 0.3.1
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 +14 -1
- package/dist/components/custom/confirm-dialog.d.ts +16 -0
- package/dist/components/custom/confirm-dialog.d.ts.map +1 -0
- package/dist/components/custom/confirm-dialog.js +93 -0
- package/dist/components/custom/confirm-dialog.js.map +1 -0
- package/dist/components/custom/toast.d.ts +20 -0
- package/dist/components/custom/toast.d.ts.map +1 -0
- package/dist/components/custom/toast.js +73 -0
- package/dist/components/custom/toast.js.map +1 -0
- package/dist/components/motion/action-swap.js +1 -1
- package/dist/components/motion/animated-badge.js +2 -2
- package/dist/components/motion/animated-number.js +1 -1
- package/dist/components/motion/animated-sidebar.js +2 -2
- package/dist/components/motion/animated-toast-stack.js +4 -4
- package/dist/components/motion/animated-toast-stack.js.map +1 -1
- package/dist/components/motion/attachment-upload.d.ts +47 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -0
- package/dist/components/motion/attachment-upload.js +737 -0
- package/dist/components/motion/attachment-upload.js.map +1 -0
- package/dist/components/motion/availability-scheduler/copy-menu.d.ts +10 -0
- package/dist/components/motion/availability-scheduler/copy-menu.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/copy-menu.js +3 -0
- package/dist/components/motion/availability-scheduler/day-row.d.ts +15 -0
- package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/day-row.js +181 -0
- package/dist/components/motion/availability-scheduler/day-row.js.map +1 -0
- package/dist/components/motion/availability-scheduler/icon-button.d.ts +15 -0
- package/dist/components/motion/availability-scheduler/icon-button.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/icon-button.js +24 -0
- package/dist/components/motion/availability-scheduler/icon-button.js.map +1 -0
- package/dist/components/motion/availability-scheduler/index.d.ts +14 -0
- package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/index.js +59 -0
- package/dist/components/motion/availability-scheduler/index.js.map +1 -0
- package/dist/components/motion/availability-scheduler/time-select.d.ts +10 -0
- package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -0
- package/dist/components/motion/availability-scheduler/time-select.js +26 -0
- package/dist/components/motion/availability-scheduler/time-select.js.map +1 -0
- package/dist/components/motion/bloom-menu.d.ts +17 -0
- package/dist/components/motion/bloom-menu.d.ts.map +1 -0
- package/dist/components/motion/bloom-menu.js +170 -0
- package/dist/components/motion/bloom-menu.js.map +1 -0
- package/dist/components/motion/bottom-sheet.js +1 -1
- package/dist/components/motion/bounce-sidebar.js +1 -1
- package/dist/components/motion/bouncy-accordion.js +2 -2
- package/dist/components/motion/button/base.js +1 -1
- package/dist/components/motion/button/index.d.ts +4 -0
- package/dist/components/motion/button/index.js +5 -0
- package/dist/components/motion/button/magnetic.js +1 -1
- package/dist/components/motion/button/stateful.js +2 -2
- package/dist/components/motion/center-morph-modal.js +2 -2
- package/dist/components/motion/checkbox.js +1 -1
- package/dist/components/motion/chromatic-text-reveal.js +1 -1
- package/dist/components/motion/command-palette.d.ts +26 -0
- package/dist/components/motion/command-palette.d.ts.map +1 -0
- package/dist/components/motion/command-palette.js +246 -0
- package/dist/components/motion/command-palette.js.map +1 -0
- package/dist/components/motion/context-menu.js +2 -2
- package/dist/components/motion/cylinder-carousel.js +1 -1
- package/dist/components/motion/dock.js +1 -1
- package/dist/components/motion/drawer.js +1 -1
- package/dist/components/motion/dynamic-island.d.ts +22 -0
- package/dist/components/motion/dynamic-island.d.ts.map +1 -0
- package/dist/components/motion/dynamic-island.js +143 -0
- package/dist/components/motion/dynamic-island.js.map +1 -0
- package/dist/components/motion/expandable-action-bar.d.ts +52 -0
- package/dist/components/motion/expandable-action-bar.d.ts.map +1 -0
- package/dist/components/motion/expandable-action-bar.js +191 -0
- package/dist/components/motion/expandable-action-bar.js.map +1 -0
- package/dist/components/motion/expandable-tabs.d.ts +33 -0
- package/dist/components/motion/expandable-tabs.d.ts.map +1 -0
- package/dist/components/motion/expandable-tabs.js +291 -0
- package/dist/components/motion/expandable-tabs.js.map +1 -0
- package/dist/components/motion/feedback-widget.d.ts +18 -0
- package/dist/components/motion/feedback-widget.d.ts.map +1 -0
- package/dist/components/motion/feedback-widget.js +413 -0
- package/dist/components/motion/feedback-widget.js.map +1 -0
- package/dist/components/motion/file-upload.d.ts +48 -0
- package/dist/components/motion/file-upload.d.ts.map +1 -0
- package/dist/components/motion/file-upload.js +382 -0
- package/dist/components/motion/file-upload.js.map +1 -0
- package/dist/components/motion/hold-action-button.js +1 -1
- package/dist/components/motion/infinite-masonry.d.ts +31 -0
- package/dist/components/motion/infinite-masonry.d.ts.map +1 -0
- package/dist/components/motion/infinite-masonry.js +223 -0
- package/dist/components/motion/infinite-masonry.js.map +1 -0
- package/dist/components/motion/input.js +1 -1
- package/dist/components/motion/loader.js +1 -1
- package/dist/components/motion/magnetic.js +1 -1
- package/dist/components/motion/morphing-modal.js +1 -1
- package/dist/components/motion/not-found/glitch.d.ts +6 -0
- package/dist/components/motion/not-found/glitch.d.ts.map +1 -0
- package/dist/components/motion/not-found/glitch.js +90 -0
- package/dist/components/motion/not-found/glitch.js.map +1 -0
- package/dist/components/motion/not-found/magnetic.d.ts +6 -0
- package/dist/components/motion/not-found/magnetic.d.ts.map +1 -0
- package/dist/components/motion/not-found/magnetic.js +47 -0
- package/dist/components/motion/not-found/magnetic.js.map +1 -0
- package/dist/components/motion/not-found/shared.d.ts +32 -0
- package/dist/components/motion/not-found/shared.d.ts.map +1 -0
- package/dist/components/motion/not-found/shared.js +52 -0
- package/dist/components/motion/not-found/shared.js.map +1 -0
- package/dist/components/motion/not-found/spotlight.d.ts +6 -0
- package/dist/components/motion/not-found/spotlight.d.ts.map +1 -0
- package/dist/components/motion/not-found/spotlight.js +70 -0
- package/dist/components/motion/not-found/spotlight.js.map +1 -0
- package/dist/components/motion/not-found/stacked.d.ts +6 -0
- package/dist/components/motion/not-found/stacked.d.ts.map +1 -0
- package/dist/components/motion/not-found/stacked.js +95 -0
- package/dist/components/motion/not-found/stacked.js.map +1 -0
- package/dist/components/motion/not-found/terminal.d.ts +6 -0
- package/dist/components/motion/not-found/terminal.d.ts.map +1 -0
- package/dist/components/motion/not-found/terminal.js +90 -0
- package/dist/components/motion/not-found/terminal.js.map +1 -0
- package/dist/components/motion/notification-stack.d.ts +35 -0
- package/dist/components/motion/notification-stack.d.ts.map +1 -0
- package/dist/components/motion/notification-stack.js +187 -0
- package/dist/components/motion/notification-stack.js.map +1 -0
- package/dist/components/motion/number-ticker.js +1 -1
- package/dist/components/motion/otp-input.d.ts +32 -0
- package/dist/components/motion/otp-input.d.ts.map +1 -0
- package/dist/components/motion/otp-input.js +272 -0
- package/dist/components/motion/otp-input.js.map +1 -0
- package/dist/components/motion/overflow-actions.d.ts +39 -0
- package/dist/components/motion/overflow-actions.d.ts.map +1 -0
- package/dist/components/motion/overflow-actions.js +220 -0
- package/dist/components/motion/overflow-actions.js.map +1 -0
- package/dist/components/motion/parallax.js +1 -1
- package/dist/components/motion/popover-morph.js +2 -2
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.js +1 -1
- package/dist/components/motion/preview-rail.js +1 -1
- package/dist/components/motion/pull-to-refresh.js +2 -2
- package/dist/components/motion/pull-to-refresh.js.map +1 -1
- package/dist/components/motion/radio.js +1 -1
- package/dist/components/motion/range-slider-bubble.js +1 -1
- package/dist/components/motion/range-slider-fluid.js +1 -1
- package/dist/components/motion/range-slider-ruler.js +2 -2
- package/dist/components/motion/range-slider-ruler.js.map +1 -1
- package/dist/components/motion/range-slider-wave.js +1 -1
- package/dist/components/motion/range-slider.js +1 -1
- package/dist/components/motion/scroll-progress.js +1 -1
- package/dist/components/motion/scroll-reveal.js +1 -1
- package/dist/components/motion/select-morph.js +2 -2
- package/dist/components/motion/select.js +2 -2
- package/dist/components/motion/shader-background.js +1 -1
- package/dist/components/motion/shared-layout-bg.js +2 -2
- package/dist/components/motion/shared-layout-bg.js.map +1 -1
- package/dist/components/motion/slide-action-button.js +1 -1
- package/dist/components/motion/smooth-scroll.js +1 -1
- package/dist/components/motion/swipeable-list.d.ts +60 -0
- package/dist/components/motion/swipeable-list.d.ts.map +1 -0
- package/dist/components/motion/swipeable-list.js +254 -0
- package/dist/components/motion/swipeable-list.js.map +1 -0
- package/dist/components/motion/switch.js +1 -1
- package/dist/components/motion/table/index.js +1 -1
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +2 -2
- package/dist/components/motion/table/table-menu.js +1 -1
- package/dist/components/motion/tabs.js +1 -1
- package/dist/components/motion/text-reveal.js +1 -1
- package/dist/components/motion/text-shimmer.js +1 -1
- package/dist/components/motion/text-shimmer.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +2 -2
- package/dist/components/motion/tilt-card.js +1 -1
- package/dist/components/motion/tooltip.js +1 -1
- package/dist/components/motion/wheel-picker.js +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +2 -2
- package/dist/components/reui/data-grid/data-grid-column-header.js +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +1 -1
- package/dist/components/reui/date-selector.js +2 -2
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/filters.js +2 -2
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-view.js +2 -2
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +2 -2
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.d.ts +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.js +2 -2
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/sonner.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/copy-menu-BJ-MXnkN.js +201 -0
- package/dist/copy-menu-BJ-MXnkN.js.map +1 -0
- package/dist/types-smkWN_7x.d.ts +20 -0
- package/dist/types-smkWN_7x.d.ts.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ React UI kit for Kumix products. Built on **Base UI**, **Tailwind CSS**, **class
|
|
|
9
9
|
| `src/components/ui/*` | [shadcn/ui](https://ui.shadcn.com/) (base-nova style) | [ui.shadcn.com/docs/components](https://ui.shadcn.com/docs/components) |
|
|
10
10
|
| `src/components/reui/*` | [ReUI](https://reui.io/) registry (`@reui/*`) | [reui.io/docs](https://reui.io/docs) · [components](https://reui.io/components) |
|
|
11
11
|
| `src/components/motion/*` | [beUI](https://beui.dev/) registry (`@beui/*`, Motion-based) | [beui.dev/components/motion](https://beui.dev/components/motion) |
|
|
12
|
+
| `src/components/custom/*` | Hand-written Kumix-specific components | — |
|
|
12
13
|
| `src/hooks/*` | Package helpers (+ ReUI `use-file-upload`, beUI helpers) | — |
|
|
13
14
|
| `src/lib/*` | Shared utilities (beUI `ease`, `tick-sound`) | — |
|
|
14
15
|
| `src/style.css` · `src/theme.css` | Tailwind entry + design tokens | — |
|
|
@@ -71,6 +72,9 @@ import { DataGrid } from "@kumix/ui/reui/data-grid/data-grid";
|
|
|
71
72
|
import { TiltCard } from "@kumix/ui/motion/tilt-card";
|
|
72
73
|
import { MorphingModal } from "@kumix/ui/motion/morphing-modal";
|
|
73
74
|
|
|
75
|
+
// custom
|
|
76
|
+
import { ConfirmDialog } from "@kumix/ui/custom/confirm-dialog";
|
|
77
|
+
|
|
74
78
|
// hooks
|
|
75
79
|
import { useIsMobile } from "@kumix/ui/hooks/use-mobile";
|
|
76
80
|
import { useFileUpload } from "@kumix/ui/hooks/use-file-upload";
|
|
@@ -92,6 +96,7 @@ Mapped from source:
|
|
|
92
96
|
| `src/components/reui/data-grid/data-grid.tsx` | `@kumix/ui/reui/data-grid/data-grid` |
|
|
93
97
|
| `src/components/motion/tilt-card.tsx` | `@kumix/ui/motion/tilt-card` |
|
|
94
98
|
| `src/components/motion/morphing-modal.tsx` | `@kumix/ui/motion/morphing-modal` |
|
|
99
|
+
| `src/components/custom/confirm-dialog.tsx` | `@kumix/ui/custom/confirm-dialog` |
|
|
95
100
|
| `src/hooks/use-mobile.ts` | `@kumix/ui/hooks/use-mobile` |
|
|
96
101
|
| `src/lib/ease.ts` | `@kumix/ui/lib/ease` |
|
|
97
102
|
| `src/style.css` | `@kumix/ui/css` |
|
|
@@ -125,7 +130,15 @@ Extended patterns. Preview: [reui.io](https://reui.io/docs).
|
|
|
125
130
|
|
|
126
131
|
Animated components built with [Motion](https://motion.dev). Preview: [beui.dev](https://beui.dev/components/motion). Bundled — `motion`, `lenis`, `@paper-design/shaders-react` are included, no extra installs needed.
|
|
127
132
|
|
|
128
|
-
`action-swap` · `animated-badge` · `animated-number` · `animated-sidebar` · `animated-toast-stack` · `bottom-sheet` · `bounce-sidebar` · `bouncy-accordion` · `button/*` (base, stateful, magnetic) · `center-morph-modal` · `checkbox` · `chromatic-text-reveal` · `context-menu` · `cylinder-carousel` · `dock` · `drawer` · `hold-action-button` · `input` · `loader` · `
|
|
133
|
+
`action-swap` · `animated-badge` · `animated-number` · `animated-sidebar` · `animated-toast-stack` · `attachment-upload` · `availability-scheduler/*` (copy-menu, day-row, time-select) · `bloom-menu` · `bottom-sheet` · `bounce-sidebar` · `bouncy-accordion` · `button/*` (base, stateful, magnetic) · `center-morph-modal` · `checkbox` · `chromatic-text-reveal` · `command-palette` · `context-menu` · `cylinder-carousel` · `dock` · `drawer` · `dynamic-island` · `expandable-action-bar` · `expandable-tabs` · `feedback-widget` · `file-upload` · `hold-action-button` · `infinite-masonry` · `input` · `loader` · `magnetic` · `marquee` · `morphing-modal` · `not-found/*` (glitch, magnetic, spotlight, stacked, terminal) · `notification-stack` · `number-ticker` · `otp-input` · `overflow-actions` · `parallax` · `popover` · `popover-morph` · `preview-rail` · `pull-to-refresh` · `radio` · `range-slider` (5 variants) · `scroll-progress` · `scroll-reveal` · `scroll-to` · `select` · `select-morph` · `shader-background` · `shared-layout-bg` · `slide-action-button` · `smooth-scroll` · `swipeable-list` · `switch` · `table/*` (virtualized, editable, async) · `tabs` · `text-cascade` · `text-reveal` · `text-shimmer` · `theme-toggle` · `tilt-card` · `tooltip` · `wheel-picker`
|
|
134
|
+
|
|
135
|
+
### Custom (`components/custom`)
|
|
136
|
+
|
|
137
|
+
Hand-written Kumix-specific composite components (not from any registry).
|
|
138
|
+
|
|
139
|
+
`confirm-dialog` — `ConfirmDialog` (destructive alert dialog with loading state) + `ConfirmSignOut` (centered sign-out variant).
|
|
140
|
+
|
|
141
|
+
`toast` — Global toast system: `ToastContainer` (mount once) + `showToast` / `toastSuccess` / `toastError` / `toastInfo` / `toastLoading` (call anywhere). Wraps `motion/animated-toast-stack`.
|
|
129
142
|
|
|
130
143
|
### Hooks
|
|
131
144
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/components/custom/confirm-dialog.d.ts
|
|
2
|
+
interface ConfirmDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
onConfirm?: () => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
confirmText?: string;
|
|
9
|
+
cancelText?: string;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function ConfirmDialog({ open, onOpenChange, onConfirm, title, description, confirmText, cancelText, loading }: ConfirmDialogProps): import("react").JSX.Element;
|
|
13
|
+
declare function ConfirmSignOut({ open, onOpenChange, onConfirm, title, description, confirmText, cancelText, loading }: ConfirmDialogProps): import("react").JSX.Element;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ConfirmDialog, ConfirmSignOut };
|
|
16
|
+
//# sourceMappingURL=confirm-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-dialog.d.ts","names":[],"sources":["../../../src/components/custom/confirm-dialog.tsx"],"mappings":";UAgBU;EACR;EACA,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;iBAGc,gBACd,MACA,cACA,WACA,OACA,aACA,aACA,YACA,WACC,qCAAkB,IAAA;iBAwCL,iBACd,MACA,cACA,WACA,OACA,aACA,aACA,YACA,WACC,qCAAkB,IAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogMedia, AlertDialogTitle } from "../ui/alert-dialog.js";
|
|
3
|
+
import { Spinner } from "../ui/spinner.js";
|
|
4
|
+
import { CircleAlertIcon, ShieldQuestionMarkIcon } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/custom/confirm-dialog.tsx
|
|
7
|
+
function ConfirmDialog({ open, onOpenChange, onConfirm, title, description, confirmText, cancelText, loading = false }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(AlertDialog, {
|
|
9
|
+
open,
|
|
10
|
+
onOpenChange: (next) => {
|
|
11
|
+
if (loading && !next) return;
|
|
12
|
+
onOpenChange(next);
|
|
13
|
+
},
|
|
14
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, { children: [/* @__PURE__ */ jsxs("div", {
|
|
15
|
+
className: "flex items-start gap-3 py-1",
|
|
16
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
17
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-full bg-destructive/10 dark:bg-destructive/10",
|
|
18
|
+
children: /* @__PURE__ */ jsx(CircleAlertIcon, { className: "size-5 text-destructive" })
|
|
19
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "flex flex-col justify-center gap-1",
|
|
21
|
+
children: [/* @__PURE__ */ jsx(AlertDialogTitle, {
|
|
22
|
+
className: "font-semibold text-sm",
|
|
23
|
+
children: title
|
|
24
|
+
}), /* @__PURE__ */ jsx(AlertDialogDescription, {
|
|
25
|
+
className: "text-muted-foreground text-sm",
|
|
26
|
+
children: description
|
|
27
|
+
})]
|
|
28
|
+
})]
|
|
29
|
+
}), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
30
|
+
disabled: loading,
|
|
31
|
+
children: cancelText
|
|
32
|
+
}), /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
33
|
+
variant: "destructive",
|
|
34
|
+
disabled: loading,
|
|
35
|
+
onClick: (event) => {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
if (!loading) onConfirm?.();
|
|
38
|
+
},
|
|
39
|
+
children: [loading ? /* @__PURE__ */ jsx(Spinner, {}) : null, confirmText]
|
|
40
|
+
})] })] })
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function ConfirmSignOut({ open, onOpenChange, onConfirm, title = "Are you sure?", description = "You can always log in later to your account.", confirmText = "Yes, Logout", cancelText = "No", loading = false }) {
|
|
44
|
+
return /* @__PURE__ */ jsx(AlertDialog, {
|
|
45
|
+
open,
|
|
46
|
+
onOpenChange: (next) => {
|
|
47
|
+
if (loading && !next) return;
|
|
48
|
+
onOpenChange(next);
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ jsxs(AlertDialogContent, {
|
|
51
|
+
size: "sm",
|
|
52
|
+
className: "gap-0 overflow-hidden p-0 sm:max-w-sm",
|
|
53
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: "flex flex-col items-center justify-center gap-2 p-8",
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ jsx(AlertDialogMedia, {
|
|
57
|
+
className: "size-12 rounded-full bg-violet-50 text-violet-500 dark:bg-violet-950 dark:text-violet-400",
|
|
58
|
+
children: /* @__PURE__ */ jsx(ShieldQuestionMarkIcon, { className: "size-6" })
|
|
59
|
+
}),
|
|
60
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, {
|
|
61
|
+
className: "text-center font-semibold text-base",
|
|
62
|
+
children: title
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, {
|
|
65
|
+
className: "p-0 text-center font-medium text-sm",
|
|
66
|
+
children: description
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}), /* @__PURE__ */ jsxs(AlertDialogFooter, {
|
|
70
|
+
className: "grid flex-none grid-cols-2 gap-0 divide-x border-t pt-0",
|
|
71
|
+
children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
72
|
+
variant: "ghost",
|
|
73
|
+
className: "h-12 flex-1 rounded-none border-0 border-border border-r p-0",
|
|
74
|
+
disabled: loading,
|
|
75
|
+
children: cancelText
|
|
76
|
+
}), /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
77
|
+
variant: "ghost",
|
|
78
|
+
disabled: loading,
|
|
79
|
+
onClick: (event) => {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
if (!loading) onConfirm?.();
|
|
82
|
+
},
|
|
83
|
+
className: "h-12 flex-1 rounded-none border-0 p-0",
|
|
84
|
+
children: [loading ? /* @__PURE__ */ jsx(Spinner, {}) : null, confirmText]
|
|
85
|
+
})]
|
|
86
|
+
})]
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { ConfirmDialog, ConfirmSignOut };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=confirm-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-dialog.js","names":[],"sources":["../../../src/components/custom/confirm-dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport { CircleAlertIcon, ShieldQuestionMarkIcon } from \"lucide-react\";\n\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogMedia,\n AlertDialogTitle,\n} from \"../ui/alert-dialog\";\nimport { Spinner } from \"../ui/spinner\";\n\ninterface ConfirmDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onConfirm?: () => void;\n title?: string;\n description?: string;\n confirmText?: string;\n cancelText?: string;\n loading?: boolean;\n}\n\nexport function ConfirmDialog({\n open,\n onOpenChange,\n onConfirm,\n title,\n description,\n confirmText,\n cancelText,\n loading = false,\n}: ConfirmDialogProps) {\n return (\n <AlertDialog\n open={open}\n onOpenChange={(next) => {\n if (loading && !next) return;\n onOpenChange(next);\n }}\n >\n <AlertDialogContent>\n <div className=\"flex items-start gap-3 py-1\">\n <div className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-destructive/10 dark:bg-destructive/10\">\n <CircleAlertIcon className=\"size-5 text-destructive\" />\n </div>\n <div className=\"flex flex-col justify-center gap-1\">\n <AlertDialogTitle className=\"font-semibold text-sm\">{title}</AlertDialogTitle>\n <AlertDialogDescription className=\"text-muted-foreground text-sm\">\n {description}\n </AlertDialogDescription>\n </div>\n </div>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={loading}>{cancelText}</AlertDialogCancel>\n <AlertDialogAction\n variant=\"destructive\"\n disabled={loading}\n onClick={(event) => {\n event.preventDefault();\n if (!loading) onConfirm?.();\n }}\n >\n {loading ? <Spinner /> : null}\n {confirmText}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n\nexport function ConfirmSignOut({\n open,\n onOpenChange,\n onConfirm,\n title = \"Are you sure?\",\n description = \"You can always log in later to your account.\",\n confirmText = \"Yes, Logout\",\n cancelText = \"No\",\n loading = false,\n}: ConfirmDialogProps) {\n return (\n <AlertDialog\n open={open}\n onOpenChange={(next) => {\n if (loading && !next) return;\n onOpenChange(next);\n }}\n >\n <AlertDialogContent size=\"sm\" className=\"gap-0 overflow-hidden p-0 sm:max-w-sm\">\n <div className=\"flex flex-col items-center justify-center gap-2 p-8\">\n <AlertDialogMedia className=\"size-12 rounded-full bg-violet-50 text-violet-500 dark:bg-violet-950 dark:text-violet-400\">\n <ShieldQuestionMarkIcon className=\"size-6\" />\n </AlertDialogMedia>\n <AlertDialogTitle className=\"text-center font-semibold text-base\">\n {title}\n </AlertDialogTitle>\n <AlertDialogDescription className=\"p-0 text-center font-medium text-sm\">\n {description}\n </AlertDialogDescription>\n </div>\n <AlertDialogFooter className=\"grid flex-none grid-cols-2 gap-0 divide-x border-t pt-0\">\n <AlertDialogCancel\n variant=\"ghost\"\n className=\"h-12 flex-1 rounded-none border-0 border-border border-r p-0\"\n disabled={loading}\n >\n {cancelText}\n </AlertDialogCancel>\n <AlertDialogAction\n variant=\"ghost\"\n disabled={loading}\n onClick={(event) => {\n event.preventDefault();\n if (!loading) onConfirm?.();\n }}\n className=\"h-12 flex-1 rounded-none border-0 p-0\"\n >\n {loading ? <Spinner /> : null}\n {confirmText}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,cAAc,EAC5B,MACA,cACA,WACA,OACA,aACA,aACA,YACA,UAAU,SACW;CACrB,OACE,oBAAC,aAAD;EACQ;EACN,eAAe,SAAS;GACtB,IAAI,WAAW,CAAC,MAAM;GACtB,aAAa,IAAI;EACnB;EAEA,UAAA,qBAAC,oBAAD,EAAA,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,iBAAD,EAAiB,WAAU,0BAA2B,CAAA;GACnD,CAAA,GACL,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,oBAAC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C,SAAS,YAAY;KAC5B;KACA,WAAU;KAPZ,UAAA,CASG,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI,MACxB,WACgB;IACF,CAAA,CAAA;GACD,CAAA,CAAA;;CACT,CAAA;AAEjB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AnimatedToastStackProps, ToastInput } from "../motion/animated-toast-stack.js";
|
|
2
|
+
//#region src/components/custom/toast.d.ts
|
|
3
|
+
interface ToastOptions {
|
|
4
|
+
message?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
declare function showToast(input: ToastInput): string;
|
|
10
|
+
declare function toastSuccess({ message, description, duration, id }?: ToastOptions): string;
|
|
11
|
+
declare function toastError({ message, description, duration, id }?: ToastOptions): string;
|
|
12
|
+
declare function toastInfo({ message, description, duration, id }?: ToastOptions): string;
|
|
13
|
+
declare function toastLoading({ message, description, duration, id }?: ToastOptions): string;
|
|
14
|
+
declare function ToastContainer({ position, maxVisible, defaultDuration, limit, ...props }: Omit<AnimatedToastStackProps, "toasts" | "onDismiss"> & {
|
|
15
|
+
defaultDuration?: number;
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ToastContainer, showToast, toastError, toastInfo, toastLoading, toastSuccess };
|
|
20
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","names":[],"sources":["../../../src/components/custom/toast.tsx"],"mappings":";;UAWU;EACR;EACA;EACA;EACA;;iBAKc,UAAU,OAAO;iBAUjB,eACd,SACA,aACA,UACA,OACC;iBAIa,aACd,SACA,aACA,UACA,OACC;iBAIa,YACd,SACA,aACA,UACA,OACC;iBAIa,eACd,SACA,aACA,UACA,OACC;iBAIa,iBACd,UACA,YACA,iBACA,UACG,SACF,KAAK;EACN;EACA;oBACD,IAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AnimatedToastStack, useAnimatedToastStack } from "../motion/animated-toast-stack.js";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/custom/toast.tsx
|
|
6
|
+
let _show = null;
|
|
7
|
+
function showToast(input) {
|
|
8
|
+
if (!_show) {
|
|
9
|
+
if (typeof console !== "undefined") console.warn("[@kumix/ui] ToastContainer not mounted — toast dropped:", input.title);
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return _show(input);
|
|
13
|
+
}
|
|
14
|
+
function toastSuccess({ message = "Success", description, duration, id } = {}) {
|
|
15
|
+
return showToast({
|
|
16
|
+
status: "success",
|
|
17
|
+
title: message,
|
|
18
|
+
description,
|
|
19
|
+
duration,
|
|
20
|
+
id
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function toastError({ message = "An error occurred", description, duration, id } = {}) {
|
|
24
|
+
return showToast({
|
|
25
|
+
status: "error",
|
|
26
|
+
title: message,
|
|
27
|
+
description,
|
|
28
|
+
duration,
|
|
29
|
+
id
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function toastInfo({ message = "Info", description, duration, id } = {}) {
|
|
33
|
+
return showToast({
|
|
34
|
+
status: "info",
|
|
35
|
+
title: message,
|
|
36
|
+
description,
|
|
37
|
+
duration,
|
|
38
|
+
id
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function toastLoading({ message = "Loading...", description, duration = 0, id } = {}) {
|
|
42
|
+
return showToast({
|
|
43
|
+
status: "loading",
|
|
44
|
+
title: message,
|
|
45
|
+
description,
|
|
46
|
+
duration,
|
|
47
|
+
id
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function ToastContainer({ position = "top-center", maxVisible = 4, defaultDuration = 4e3, limit = 5, ...props }) {
|
|
51
|
+
const { toasts, showToast: show, dismissToast } = useAnimatedToastStack({
|
|
52
|
+
defaultDuration,
|
|
53
|
+
limit
|
|
54
|
+
});
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
_show = show;
|
|
57
|
+
return () => {
|
|
58
|
+
_show = null;
|
|
59
|
+
};
|
|
60
|
+
}, [show]);
|
|
61
|
+
return /* @__PURE__ */ jsx(AnimatedToastStack, {
|
|
62
|
+
toasts,
|
|
63
|
+
onDismiss: dismissToast,
|
|
64
|
+
position,
|
|
65
|
+
placement: "fixed",
|
|
66
|
+
maxVisible,
|
|
67
|
+
...props
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { ToastContainer, showToast, toastError, toastInfo, toastLoading, toastSuccess };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.js","names":[],"sources":["../../../src/components/custom/toast.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\n\nimport {\n AnimatedToastStack,\n type AnimatedToastStackProps,\n type ToastInput,\n useAnimatedToastStack,\n} from \"../motion/animated-toast-stack\";\n\ninterface ToastOptions {\n message?: string;\n description?: string;\n duration?: number;\n id?: string;\n}\n\nlet _show: ((input: ToastInput) => string) | null = null;\n\nexport function showToast(input: ToastInput): string {\n if (!_show) {\n if (typeof console !== \"undefined\") {\n console.warn(\"[@kumix/ui] ToastContainer not mounted — toast dropped:\", input.title);\n }\n return \"\";\n }\n return _show(input);\n}\n\nexport function toastSuccess({\n message = \"Success\",\n description,\n duration,\n id,\n}: ToastOptions = {}): string {\n return showToast({ status: \"success\", title: message, description, duration, id });\n}\n\nexport function toastError({\n message = \"An error occurred\",\n description,\n duration,\n id,\n}: ToastOptions = {}): string {\n return showToast({ status: \"error\", title: message, description, duration, id });\n}\n\nexport function toastInfo({\n message = \"Info\",\n description,\n duration,\n id,\n}: ToastOptions = {}): string {\n return showToast({ status: \"info\", title: message, description, duration, id });\n}\n\nexport function toastLoading({\n message = \"Loading...\",\n description,\n duration = 0,\n id,\n}: ToastOptions = {}): string {\n return showToast({ status: \"loading\", title: message, description, duration, id });\n}\n\nexport function ToastContainer({\n position = \"top-center\",\n maxVisible = 4,\n defaultDuration = 4000,\n limit = 5,\n ...props\n}: Omit<AnimatedToastStackProps, \"toasts\" | \"onDismiss\"> & {\n defaultDuration?: number;\n limit?: number;\n}) {\n const {\n toasts,\n showToast: show,\n dismissToast,\n } = useAnimatedToastStack({\n defaultDuration,\n limit,\n });\n\n useEffect(() => {\n _show = show;\n return () => {\n _show = null;\n };\n }, [show]);\n\n return (\n <AnimatedToastStack\n toasts={toasts}\n onDismiss={dismissToast}\n position={position}\n placement=\"fixed\"\n maxVisible={maxVisible}\n {...props}\n />\n );\n}\n"],"mappings":";;;;;AAkBA,IAAI,QAAgD;AAEpD,SAAgB,UAAU,OAA2B;CACnD,IAAI,CAAC,OAAO;EACV,IAAI,OAAO,YAAY,aACrB,QAAQ,KAAK,2DAA2D,MAAM,KAAK;EAErF,OAAO;CACT;CACA,OAAO,MAAM,KAAK;AACpB;AAEA,SAAgB,aAAa,EAC3B,UAAU,WACV,aACA,UACA,OACgB,CAAC,GAAW;CAC5B,OAAO,UAAU;EAAE,QAAQ;EAAW,OAAO;EAAS;EAAa;EAAU;CAAG,CAAC;AACnF;AAEA,SAAgB,WAAW,EACzB,UAAU,qBACV,aACA,UACA,OACgB,CAAC,GAAW;CAC5B,OAAO,UAAU;EAAE,QAAQ;EAAS,OAAO;EAAS;EAAa;EAAU;CAAG,CAAC;AACjF;AAEA,SAAgB,UAAU,EACxB,UAAU,QACV,aACA,UACA,OACgB,CAAC,GAAW;CAC5B,OAAO,UAAU;EAAE,QAAQ;EAAQ,OAAO;EAAS;EAAa;EAAU;CAAG,CAAC;AAChF;AAEA,SAAgB,aAAa,EAC3B,UAAU,cACV,aACA,WAAW,GACX,OACgB,CAAC,GAAW;CAC5B,OAAO,UAAU;EAAE,QAAQ;EAAW,OAAO;EAAS;EAAa;EAAU;CAAG,CAAC;AACnF;AAEA,SAAgB,eAAe,EAC7B,WAAW,cACX,aAAa,GACb,kBAAkB,KAClB,QAAQ,GACR,GAAG,SAIF;CACD,MAAM,EACJ,QACA,WAAW,MACX,iBACE,sBAAsB;EACxB;EACA;CACF,CAAC;CAED,gBAAgB;EACd,QAAQ;EACR,aAAa;GACX,QAAQ;EACV;CACF,GAAG,CAAC,IAAI,CAAC;CAET,OACE,oBAAC,oBAAD;EACU;EACR,WAAW;EACD;EACV,WAAU;EACE;EACZ,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { EASE_OUT, EASE_OUT_CSS, SPRING_PRESS, SPRING_SWAP } from "../../lib/ease.js";
|
|
3
3
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
6
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/action-swap.tsx
|
|
8
8
|
const BLUR_TRANSITION = {
|
|
9
9
|
duration: .2,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { cn } from "@kumix/utils";
|
|
4
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
4
|
import { AlertTriangle, Check, Circle, Info, LoaderCircle, X } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/animated-badge.tsx
|
|
8
8
|
const STATUS_CLASS = {
|
|
9
9
|
neutral: "border-border bg-card text-muted-foreground",
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
-
import { animate, useInView, useReducedMotion } from "motion/react";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { animate, useInView, useReducedMotion } from "motion/react";
|
|
7
7
|
//#region src/components/motion/animated-number.tsx
|
|
8
8
|
function AnimatedNumber({ value, duration = 1.2, format = (n) => Math.round(n).toLocaleString(), className, startOnView = true }) {
|
|
9
9
|
const ref = useRef(null);
|
|
@@ -3,9 +3,9 @@ import { EASE_DRAWER, EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from "../../lib/ea
|
|
|
3
3
|
import { SharedLayoutBg } from "./shared-layout-bg.js";
|
|
4
4
|
import { createContext, createElement, forwardRef, useCallback, useContext, useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { cn } from "@kumix/utils";
|
|
6
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
7
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
6
|
import { ChevronRight } from "lucide-react";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
//#region src/components/motion/animated-sidebar.tsx
|
|
11
11
|
const MOBILE_QUERY = "(max-width: 767px)";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { EASE_OUT } from "../../lib/ease.js";
|
|
3
3
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { cn } from "@kumix/utils";
|
|
5
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
5
|
import { AlertCircle, Bell, Check, Info, LoaderCircle, X } from "lucide-react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
//#region src/components/motion/animated-toast-stack.tsx
|
|
10
10
|
const STACK_SPRING = {
|
|
@@ -212,11 +212,11 @@ const ToastItem = memo(function ToastItem({ toast, index, onDismiss, classNames,
|
|
|
212
212
|
children: /* @__PURE__ */ jsx("div", {
|
|
213
213
|
className: cn("relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl", classNames?.surface),
|
|
214
214
|
children: renderToast ? renderToast(toast) : /* @__PURE__ */ jsxs("div", {
|
|
215
|
-
className: "flex items-
|
|
215
|
+
className: "flex items-center gap-3",
|
|
216
216
|
children: [
|
|
217
217
|
/* @__PURE__ */ jsx(motion.span, {
|
|
218
218
|
layout: true,
|
|
219
|
-
className: cn("
|
|
219
|
+
className: cn("inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full", STATUS_CLASS[status], classNames?.iconWrap),
|
|
220
220
|
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
221
221
|
mode: "popLayout",
|
|
222
222
|
initial: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animated-toast-stack.js","names":[],"sources":["../../../src/components/motion/animated-toast-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { AlertCircle, Bell, Check, Info, LoaderCircle, type LucideIcon, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type ToastStatus = \"neutral\" | \"info\" | \"loading\" | \"success\" | \"error\";\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type AnimatedToastAction = {\n label: ReactNode;\n onClick: (toast: AnimatedToast) => void;\n};\n\nexport type AnimatedToast = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n status?: ToastStatus;\n icon?: ReactNode;\n action?: AnimatedToastAction;\n duration?: number;\n dismissible?: boolean;\n createdAt?: number;\n};\n\nexport type ToastInput = Omit<AnimatedToast, \"id\" | \"createdAt\"> & {\n id?: string;\n};\n\nexport type ToastClassNames = {\n root?: string;\n item?: string;\n surface?: string;\n iconWrap?: string;\n content?: string;\n title?: string;\n description?: string;\n action?: string;\n close?: string;\n progress?: string;\n};\n\nexport interface AnimatedToastStackProps {\n toasts: AnimatedToast[];\n onDismiss?: (id: string) => void;\n position?: ToastPosition;\n placement?: \"static\" | \"fixed\" | \"absolute\";\n fixed?: boolean;\n portal?: boolean;\n portalRoot?: Element | null;\n maxVisible?: number;\n className?: string;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}\n\nexport interface UseAnimatedToastStackOptions {\n initialToasts?: ToastInput[];\n defaultDuration?: number;\n limit?: number;\n}\n\nconst STACK_SPRING: Transition = {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n mass: 0.75,\n};\n\nconst CONTENT_TRANSITION = {\n duration: 0.28,\n ease: EASE_OUT,\n} as const;\n\nconst STATUS_ICON: Record<ToastStatus, LucideIcon> = {\n neutral: Bell,\n info: Info,\n loading: LoaderCircle,\n success: Check,\n error: AlertCircle,\n};\n\nconst STATUS_CLASS: Record<ToastStatus, string> = {\n neutral: \"text-muted-foreground bg-primary/[0.05]\",\n info: \"text-primary bg-primary/10\",\n loading: \"text-primary bg-primary/10\",\n success: \"text-emerald-600 bg-emerald-500/10 dark:text-emerald-400\",\n error: \"text-destructive bg-destructive/10\",\n};\n\nconst POSITION_CLASS: Record<ToastPosition, string> = {\n \"top-left\": \"left-4 top-4\",\n \"top-center\": \"left-1/2 top-4 -translate-x-1/2\",\n \"top-right\": \"right-4 top-4\",\n \"bottom-left\": \"bottom-6 left-4\",\n \"bottom-center\": \"bottom-6 left-1/2 -translate-x-1/2\",\n \"bottom-right\": \"bottom-6 right-4\",\n};\n\nlet idSeed = 0;\n\nfunction createToast(input: ToastInput, defaultDuration: number): AnimatedToast {\n return {\n duration: defaultDuration,\n dismissible: true,\n ...input,\n id: input.id ?? `toast-${Date.now()}-${idSeed++}`,\n createdAt: Date.now(),\n };\n}\n\nexport function useAnimatedToastStack({\n initialToasts = [],\n defaultDuration = 4200,\n limit,\n}: UseAnimatedToastStackOptions = {}) {\n const toastTimers = useRef<Map<string, { timer: number; signature: string }>>(new Map());\n const [toasts, setToasts] = useState<AnimatedToast[]>(() =>\n initialToasts.map((toast) => createToast(toast, defaultDuration)),\n );\n\n const dismissToast = useCallback((id: string) => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const clearToasts = useCallback(() => {\n setToasts([]);\n }, []);\n\n const showToast = useCallback(\n (input: ToastInput) => {\n const toast = createToast(input, defaultDuration);\n setToasts((current) => {\n const next = [...current, toast];\n return typeof limit === \"number\" ? next.slice(-limit) : next;\n });\n return toast.id;\n },\n [defaultDuration, limit],\n );\n\n const updateToast = useCallback((id: string, patch: Partial<ToastInput>) => {\n setToasts((current) =>\n current.map((toast) =>\n toast.id === id\n ? {\n ...toast,\n ...patch,\n id,\n createdAt: patch.duration === undefined ? toast.createdAt : Date.now(),\n }\n : toast,\n ),\n );\n }, []);\n\n useEffect(() => {\n const activeIds = new Set(toasts.map((toast) => toast.id));\n\n toastTimers.current.forEach((entry, id) => {\n if (!activeIds.has(id)) {\n window.clearTimeout(entry.timer);\n toastTimers.current.delete(id);\n }\n });\n\n toasts.forEach((toast) => {\n const duration = toast.duration ?? defaultDuration;\n const existing = toastTimers.current.get(toast.id);\n\n if (duration <= 0) {\n if (existing) {\n window.clearTimeout(existing.timer);\n toastTimers.current.delete(toast.id);\n }\n return;\n }\n\n const createdAt = toast.createdAt ?? Date.now();\n const signature = `${createdAt}:${duration}`;\n\n if (existing?.signature === signature) {\n return;\n }\n\n if (existing) {\n window.clearTimeout(existing.timer);\n }\n\n const elapsed = Date.now() - createdAt;\n const remaining = Math.max(duration - elapsed, 0);\n const timer = window.setTimeout(() => {\n toastTimers.current.delete(toast.id);\n dismissToast(toast.id);\n }, remaining);\n\n toastTimers.current.set(toast.id, { timer, signature });\n });\n }, [defaultDuration, dismissToast, toasts]);\n\n useEffect(() => {\n const timers = toastTimers.current;\n\n return () => {\n timers.forEach((entry) => {\n window.clearTimeout(entry.timer);\n });\n timers.clear();\n };\n }, []);\n\n return useMemo(\n () => ({\n toasts,\n showToast,\n updateToast,\n dismissToast,\n clearToasts,\n setToasts,\n }),\n [clearToasts, dismissToast, showToast, toasts, updateToast],\n );\n}\n\nexport function AnimatedToastStack({\n toasts,\n onDismiss,\n position = \"bottom-right\",\n placement,\n fixed = false,\n portal,\n portalRoot,\n maxVisible = 4,\n className,\n classNames,\n icons,\n renderToast,\n}: AnimatedToastStackProps) {\n const [portalTarget, setPortalTarget] = useState<Element | null>(null);\n const visibleToasts = toasts.slice(-maxVisible);\n const isBottom = position.startsWith(\"bottom\");\n const resolvedPlacement = placement ?? (fixed ? \"fixed\" : \"static\");\n const shouldPortal = portal ?? resolvedPlacement === \"fixed\";\n\n useEffect(() => {\n setPortalTarget(shouldPortal ? (portalRoot ?? document.body) : null);\n }, [portalRoot, shouldPortal]);\n\n const stack = (\n <ol\n aria-live=\"polite\"\n aria-atomic=\"false\"\n className={cn(\n \"pointer-events-none flex w-[calc(100vw-2rem)] max-w-sm gap-2\",\n isBottom ? \"flex-col-reverse\" : \"flex-col\",\n resolvedPlacement === \"fixed\" && \"fixed z-90\",\n resolvedPlacement === \"absolute\" && \"absolute z-20\",\n resolvedPlacement !== \"static\" && POSITION_CLASS[position],\n classNames?.root,\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visibleToasts.map((toast, index) => (\n <ToastItem\n key={toast.id}\n toast={toast}\n index={index}\n onDismiss={onDismiss}\n classNames={classNames}\n icons={icons}\n renderToast={renderToast}\n />\n ))}\n </AnimatePresence>\n </ol>\n );\n\n if (shouldPortal && !portalTarget) {\n return null;\n }\n\n if (shouldPortal && portalTarget) {\n return createPortal(stack, portalTarget);\n }\n\n return stack;\n}\n\nconst ToastItem = memo(function ToastItem({\n toast,\n index,\n onDismiss,\n classNames,\n icons,\n renderToast,\n}: {\n toast: AnimatedToast;\n index: number;\n onDismiss?: (id: string) => void;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const status = toast.status ?? \"neutral\";\n const Icon = STATUS_ICON[status];\n const iconNode = icons?.[status] ?? toast.icon ?? <Icon className=\"h-3.5 w-3.5\" />;\n const canDismiss = toast.dismissible !== false && Boolean(onDismiss);\n\n return (\n <motion.li\n layout\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 22, scale: 0.96, filter: \"blur(10px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n x: 32,\n scale: 0.96,\n filter: \"blur(8px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n }\n }\n transition={STACK_SPRING}\n drag={canDismiss && !reduce ? \"x\" : false}\n dragConstraints={{ left: 0, right: 0 }}\n dragElastic={0.18}\n onDragEnd={(_, info) => {\n if (!canDismiss || !onDismiss) return;\n if (Math.abs(info.offset.x) > 72 || Math.abs(info.velocity.x) > 520) {\n onDismiss(toast.id);\n }\n }}\n className={cn(\"pointer-events-auto relative will-change-transform\", classNames?.item)}\n style={{ zIndex: 20 - index }}\n >\n <div\n className={cn(\n \"relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl\",\n classNames?.surface,\n )}\n >\n {renderToast ? (\n renderToast(toast)\n ) : (\n <div className=\"flex items-start gap-3\">\n <motion.span\n layout\n className={cn(\n \"mt-0.5 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full\",\n STATUS_CLASS[status],\n classNames?.iconWrap,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={status}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 8, scale: 0.8, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }\n }\n exit={\n reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.9, filter: \"blur(6px)\" }\n }\n transition={CONTENT_TRANSITION}\n className=\"inline-flex\"\n >\n {status === \"loading\" ? (\n <span className=\"inline-flex animate-spin\">{iconNode}</span>\n ) : (\n iconNode\n )}\n </motion.span>\n </AnimatePresence>\n </motion.span>\n\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={`${toast.id}-${status}-${String(toast.title)}`}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(6px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -8, filter: \"blur(6px)\" }}\n transition={CONTENT_TRANSITION}\n >\n <p\n className={cn(\n \"truncate font-medium text-foreground text-sm leading-5\",\n classNames?.title,\n )}\n >\n {toast.title}\n </p>\n {toast.description ? (\n <p\n className={cn(\n \"mt-0.5 line-clamp-2 text-muted-foreground text-xs leading-4\",\n classNames?.description,\n )}\n >\n {toast.description}\n </p>\n ) : null}\n </motion.div>\n </AnimatePresence>\n\n {toast.action ? (\n <button\n type=\"button\"\n onClick={() => toast.action?.onClick(toast)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center rounded-full bg-primary/6 px-3 font-medium text-foreground text-xs transition-colors hover:bg-primary/10\",\n classNames?.action,\n )}\n >\n {toast.action.label}\n </button>\n ) : null}\n </div>\n\n {canDismiss ? (\n <button\n type=\"button\"\n onClick={() => onDismiss?.(toast.id)}\n aria-label=\"Dismiss toast\"\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-primary/6 hover:text-foreground\",\n classNames?.close,\n )}\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n </div>\n )}\n </div>\n </motion.li>\n );\n});\n"],"mappings":";;;;;;;;;AA0EA,MAAM,eAA2B;CAC/B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,qBAAqB;CACzB,UAAU;CACV,MAAM;AACR;AAEA,MAAM,cAA+C;CACnD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,eAA4C;CAChD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,iBAAgD;CACpD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,eAAe;CACf,iBAAiB;CACjB,gBAAgB;AAClB;AAEA,IAAI,SAAS;AAEb,SAAS,YAAY,OAAmB,iBAAwC;CAC9E,OAAO;EACL,UAAU;EACV,aAAa;EACb,GAAG;EACH,IAAI,MAAM,MAAM,SAAS,KAAK,IAAI,EAAE,GAAG;EACvC,WAAW,KAAK,IAAI;CACtB;AACF;AAEA,SAAgB,sBAAsB,EACpC,gBAAgB,CAAC,GACjB,kBAAkB,MAClB,UACgC,CAAC,GAAG;CACpC,MAAM,cAAc,uBAA0D,IAAI,IAAI,CAAC;CACvF,MAAM,CAAC,QAAQ,aAAa,eAC1B,cAAc,KAAK,UAAU,YAAY,OAAO,eAAe,CAAC,CAClE;CAEA,MAAM,eAAe,aAAa,OAAe;EAC/C,WAAW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KACd;SAEC,UAAA,MAAM;QACN,CAAA,GACF,MAAM,cACL,oBAAC,KAAD;SACE,WAAW,GACT,+DACA,YAAY,WACd;SAEC,UAAA,MAAM;QACN,CAAA,IACD,IACM;OAxBL,GAAA,GAAG,MAAM,GAAG,GAAG,OAAO,GAAG,OAAO,MAAM,KAAK,GAwBtC;MACG,CAAA,GAEhB,MAAM,SACL,oBAAC,UAAD;OACE,MAAK;OACL,eAAe,MAAM,QAAQ,QAAQ,KAAK;OAC1C,WAAW,GACT,8IACA,YAAY,MACd;OAEC,UAAA,MAAM,OAAO;MACR,CAAA,IACN,IACD;;KAEJ,aACC,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,YAAY,MAAM,EAAE;MACnC,cAAW;MACX,WAAW,GACT,0JACA,YAAY,KACd;MAEA,UAAA,oBAAC,GAAD,EAAG,WAAU,cAAe,CAAA;KACtB,CAAA,IACN;IACD;;EAEJ,CAAA;CACI,CAAA;AAEf,CAAC"}
|
|
1
|
+
{"version":3,"file":"animated-toast-stack.js","names":[],"sources":["../../../src/components/motion/animated-toast-stack.tsx"],"sourcesContent":["\"use client\";\n\nimport { memo, type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { AlertCircle, Bell, Check, Info, LoaderCircle, type LucideIcon, X } from \"lucide-react\";\nimport { AnimatePresence, motion, type Transition, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\nexport type ToastStatus = \"neutral\" | \"info\" | \"loading\" | \"success\" | \"error\";\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type AnimatedToastAction = {\n label: ReactNode;\n onClick: (toast: AnimatedToast) => void;\n};\n\nexport type AnimatedToast = {\n id: string;\n title: ReactNode;\n description?: ReactNode;\n status?: ToastStatus;\n icon?: ReactNode;\n action?: AnimatedToastAction;\n duration?: number;\n dismissible?: boolean;\n createdAt?: number;\n};\n\nexport type ToastInput = Omit<AnimatedToast, \"id\" | \"createdAt\"> & {\n id?: string;\n};\n\nexport type ToastClassNames = {\n root?: string;\n item?: string;\n surface?: string;\n iconWrap?: string;\n content?: string;\n title?: string;\n description?: string;\n action?: string;\n close?: string;\n progress?: string;\n};\n\nexport interface AnimatedToastStackProps {\n toasts: AnimatedToast[];\n onDismiss?: (id: string) => void;\n position?: ToastPosition;\n placement?: \"static\" | \"fixed\" | \"absolute\";\n fixed?: boolean;\n portal?: boolean;\n portalRoot?: Element | null;\n maxVisible?: number;\n className?: string;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}\n\nexport interface UseAnimatedToastStackOptions {\n initialToasts?: ToastInput[];\n defaultDuration?: number;\n limit?: number;\n}\n\nconst STACK_SPRING: Transition = {\n type: \"spring\",\n stiffness: 420,\n damping: 34,\n mass: 0.75,\n};\n\nconst CONTENT_TRANSITION = {\n duration: 0.28,\n ease: EASE_OUT,\n} as const;\n\nconst STATUS_ICON: Record<ToastStatus, LucideIcon> = {\n neutral: Bell,\n info: Info,\n loading: LoaderCircle,\n success: Check,\n error: AlertCircle,\n};\n\nconst STATUS_CLASS: Record<ToastStatus, string> = {\n neutral: \"text-muted-foreground bg-primary/[0.05]\",\n info: \"text-primary bg-primary/10\",\n loading: \"text-primary bg-primary/10\",\n success: \"text-emerald-600 bg-emerald-500/10 dark:text-emerald-400\",\n error: \"text-destructive bg-destructive/10\",\n};\n\nconst POSITION_CLASS: Record<ToastPosition, string> = {\n \"top-left\": \"left-4 top-4\",\n \"top-center\": \"left-1/2 top-4 -translate-x-1/2\",\n \"top-right\": \"right-4 top-4\",\n \"bottom-left\": \"bottom-6 left-4\",\n \"bottom-center\": \"bottom-6 left-1/2 -translate-x-1/2\",\n \"bottom-right\": \"bottom-6 right-4\",\n};\n\nlet idSeed = 0;\n\nfunction createToast(input: ToastInput, defaultDuration: number): AnimatedToast {\n return {\n duration: defaultDuration,\n dismissible: true,\n ...input,\n id: input.id ?? `toast-${Date.now()}-${idSeed++}`,\n createdAt: Date.now(),\n };\n}\n\nexport function useAnimatedToastStack({\n initialToasts = [],\n defaultDuration = 4200,\n limit,\n}: UseAnimatedToastStackOptions = {}) {\n const toastTimers = useRef<Map<string, { timer: number; signature: string }>>(new Map());\n const [toasts, setToasts] = useState<AnimatedToast[]>(() =>\n initialToasts.map((toast) => createToast(toast, defaultDuration)),\n );\n\n const dismissToast = useCallback((id: string) => {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }, []);\n\n const clearToasts = useCallback(() => {\n setToasts([]);\n }, []);\n\n const showToast = useCallback(\n (input: ToastInput) => {\n const toast = createToast(input, defaultDuration);\n setToasts((current) => {\n const next = [...current, toast];\n return typeof limit === \"number\" ? next.slice(-limit) : next;\n });\n return toast.id;\n },\n [defaultDuration, limit],\n );\n\n const updateToast = useCallback((id: string, patch: Partial<ToastInput>) => {\n setToasts((current) =>\n current.map((toast) =>\n toast.id === id\n ? {\n ...toast,\n ...patch,\n id,\n createdAt: patch.duration === undefined ? toast.createdAt : Date.now(),\n }\n : toast,\n ),\n );\n }, []);\n\n useEffect(() => {\n const activeIds = new Set(toasts.map((toast) => toast.id));\n\n toastTimers.current.forEach((entry, id) => {\n if (!activeIds.has(id)) {\n window.clearTimeout(entry.timer);\n toastTimers.current.delete(id);\n }\n });\n\n toasts.forEach((toast) => {\n const duration = toast.duration ?? defaultDuration;\n const existing = toastTimers.current.get(toast.id);\n\n if (duration <= 0) {\n if (existing) {\n window.clearTimeout(existing.timer);\n toastTimers.current.delete(toast.id);\n }\n return;\n }\n\n const createdAt = toast.createdAt ?? Date.now();\n const signature = `${createdAt}:${duration}`;\n\n if (existing?.signature === signature) {\n return;\n }\n\n if (existing) {\n window.clearTimeout(existing.timer);\n }\n\n const elapsed = Date.now() - createdAt;\n const remaining = Math.max(duration - elapsed, 0);\n const timer = window.setTimeout(() => {\n toastTimers.current.delete(toast.id);\n dismissToast(toast.id);\n }, remaining);\n\n toastTimers.current.set(toast.id, { timer, signature });\n });\n }, [defaultDuration, dismissToast, toasts]);\n\n useEffect(() => {\n const timers = toastTimers.current;\n\n return () => {\n timers.forEach((entry) => {\n window.clearTimeout(entry.timer);\n });\n timers.clear();\n };\n }, []);\n\n return useMemo(\n () => ({\n toasts,\n showToast,\n updateToast,\n dismissToast,\n clearToasts,\n setToasts,\n }),\n [clearToasts, dismissToast, showToast, toasts, updateToast],\n );\n}\n\nexport function AnimatedToastStack({\n toasts,\n onDismiss,\n position = \"bottom-right\",\n placement,\n fixed = false,\n portal,\n portalRoot,\n maxVisible = 4,\n className,\n classNames,\n icons,\n renderToast,\n}: AnimatedToastStackProps) {\n const [portalTarget, setPortalTarget] = useState<Element | null>(null);\n const visibleToasts = toasts.slice(-maxVisible);\n const isBottom = position.startsWith(\"bottom\");\n const resolvedPlacement = placement ?? (fixed ? \"fixed\" : \"static\");\n const shouldPortal = portal ?? resolvedPlacement === \"fixed\";\n\n useEffect(() => {\n setPortalTarget(shouldPortal ? (portalRoot ?? document.body) : null);\n }, [portalRoot, shouldPortal]);\n\n const stack = (\n <ol\n aria-live=\"polite\"\n aria-atomic=\"false\"\n className={cn(\n \"pointer-events-none flex w-[calc(100vw-2rem)] max-w-sm gap-2\",\n isBottom ? \"flex-col-reverse\" : \"flex-col\",\n resolvedPlacement === \"fixed\" && \"fixed z-90\",\n resolvedPlacement === \"absolute\" && \"absolute z-20\",\n resolvedPlacement !== \"static\" && POSITION_CLASS[position],\n classNames?.root,\n className,\n )}\n >\n <AnimatePresence initial={false} mode=\"popLayout\">\n {visibleToasts.map((toast, index) => (\n <ToastItem\n key={toast.id}\n toast={toast}\n index={index}\n onDismiss={onDismiss}\n classNames={classNames}\n icons={icons}\n renderToast={renderToast}\n />\n ))}\n </AnimatePresence>\n </ol>\n );\n\n if (shouldPortal && !portalTarget) {\n return null;\n }\n\n if (shouldPortal && portalTarget) {\n return createPortal(stack, portalTarget);\n }\n\n return stack;\n}\n\nconst ToastItem = memo(function ToastItem({\n toast,\n index,\n onDismiss,\n classNames,\n icons,\n renderToast,\n}: {\n toast: AnimatedToast;\n index: number;\n onDismiss?: (id: string) => void;\n classNames?: ToastClassNames;\n icons?: Partial<Record<ToastStatus, ReactNode>>;\n renderToast?: (toast: AnimatedToast) => ReactNode;\n}) {\n const reduce = useReducedMotion();\n const status = toast.status ?? \"neutral\";\n const Icon = STATUS_ICON[status];\n const iconNode = icons?.[status] ?? toast.icon ?? <Icon className=\"h-3.5 w-3.5\" />;\n const canDismiss = toast.dismissible !== false && Boolean(onDismiss);\n\n return (\n <motion.li\n layout\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 22, scale: 0.96, filter: \"blur(10px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }}\n exit={\n reduce\n ? { opacity: 0 }\n : {\n opacity: 0,\n x: 32,\n scale: 0.96,\n filter: \"blur(8px)\",\n transition: { duration: 0.18, ease: EASE_OUT },\n }\n }\n transition={STACK_SPRING}\n drag={canDismiss && !reduce ? \"x\" : false}\n dragConstraints={{ left: 0, right: 0 }}\n dragElastic={0.18}\n onDragEnd={(_, info) => {\n if (!canDismiss || !onDismiss) return;\n if (Math.abs(info.offset.x) > 72 || Math.abs(info.velocity.x) > 520) {\n onDismiss(toast.id);\n }\n }}\n className={cn(\"pointer-events-auto relative will-change-transform\", classNames?.item)}\n style={{ zIndex: 20 - index }}\n >\n <div\n className={cn(\n \"relative overflow-hidden rounded-2xl border border-border bg-card/95 p-3 shadow-2xl backdrop-blur-xl\",\n classNames?.surface,\n )}\n >\n {renderToast ? (\n renderToast(toast)\n ) : (\n <div className=\"flex items-center gap-3\">\n <motion.span\n layout\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full\",\n STATUS_CLASS[status],\n classNames?.iconWrap,\n )}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.span\n key={status}\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, y: 8, scale: 0.8, filter: \"blur(6px)\" }\n }\n animate={\n reduce ? { opacity: 1 } : { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" }\n }\n exit={\n reduce ? { opacity: 0 } : { opacity: 0, y: -8, scale: 0.9, filter: \"blur(6px)\" }\n }\n transition={CONTENT_TRANSITION}\n className=\"inline-flex\"\n >\n {status === \"loading\" ? (\n <span className=\"inline-flex animate-spin\">{iconNode}</span>\n ) : (\n iconNode\n )}\n </motion.span>\n </AnimatePresence>\n </motion.span>\n\n <div className={cn(\"min-w-0 flex-1\", classNames?.content)}>\n <AnimatePresence mode=\"popLayout\" initial={false}>\n <motion.div\n key={`${toast.id}-${status}-${String(toast.title)}`}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 8, filter: \"blur(6px)\" }}\n animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, y: -8, filter: \"blur(6px)\" }}\n transition={CONTENT_TRANSITION}\n >\n <p\n className={cn(\n \"truncate font-medium text-foreground text-sm leading-5\",\n classNames?.title,\n )}\n >\n {toast.title}\n </p>\n {toast.description ? (\n <p\n className={cn(\n \"mt-0.5 line-clamp-2 text-muted-foreground text-xs leading-4\",\n classNames?.description,\n )}\n >\n {toast.description}\n </p>\n ) : null}\n </motion.div>\n </AnimatePresence>\n\n {toast.action ? (\n <button\n type=\"button\"\n onClick={() => toast.action?.onClick(toast)}\n className={cn(\n \"mt-2 inline-flex h-7 items-center rounded-full bg-primary/6 px-3 font-medium text-foreground text-xs transition-colors hover:bg-primary/10\",\n classNames?.action,\n )}\n >\n {toast.action.label}\n </button>\n ) : null}\n </div>\n\n {canDismiss ? (\n <button\n type=\"button\"\n onClick={() => onDismiss?.(toast.id)}\n aria-label=\"Dismiss toast\"\n className={cn(\n \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-primary/6 hover:text-foreground\",\n classNames?.close,\n )}\n >\n <X className=\"h-3.5 w-3.5\" />\n </button>\n ) : null}\n </div>\n )}\n </div>\n </motion.li>\n );\n});\n"],"mappings":";;;;;;;;;AA0EA,MAAM,eAA2B;CAC/B,MAAM;CACN,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,MAAM,qBAAqB;CACzB,UAAU;CACV,MAAM;AACR;AAEA,MAAM,cAA+C;CACnD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,eAA4C;CAChD,SAAS;CACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAEA,MAAM,iBAAgD;CACpD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,eAAe;CACf,iBAAiB;CACjB,gBAAgB;AAClB;AAEA,IAAI,SAAS;AAEb,SAAS,YAAY,OAAmB,iBAAwC;CAC9E,OAAO;EACL,UAAU;EACV,aAAa;EACb,GAAG;EACH,IAAI,MAAM,MAAM,SAAS,KAAK,IAAI,EAAE,GAAG;EACvC,WAAW,KAAK,IAAI;CACtB;AACF;AAEA,SAAgB,sBAAsB,EACpC,gBAAgB,CAAC,GACjB,kBAAkB,MAClB,UACgC,CAAC,GAAG;CACpC,MAAM,cAAc,uBAA0D,IAAI,IAAI,CAAC;CACvF,MAAM,CAAC,QAAQ,aAAa,eAC1B,cAAc,KAAK,UAAU,YAAY,OAAO,eAAe,CAAC,CAClE;CAEA,MAAM,eAAe,aAAa,OAAe;EAC/C,WAAW,YAAY,QAAQ,QAAQ,UAAU,MAAM,OAAO,EAAE,CAAC;CACnE,GAAG,CAAC,CAAC;CAEL,MAAM,cAAc,kBAAkB;EACpC,UAAU,CAAC,CAAC;CACd,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aACf,UAAsB;EACrB,MAAM,QAAQ,YAAY,OAAO,eAAe;EAChD,W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hB,MAAM,SACL,oBAAC,UAAD;OACE,MAAK;OACL,eAAe,MAAM,QAAQ,QAAQ,KAAK;OAC1C,WAAW,GACT,8IACA,YAAY,MACd;OAEC,UAAA,MAAM,OAAO;MACR,CAAA,IACN,IACD;;KAEJ,aACC,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,YAAY,MAAM,EAAE;MACnC,cAAW;MACX,WAAW,GACT,0JACA,YAAY,KACd;MAEA,UAAA,oBAAC,GAAD,EAAG,WAAU,cAAe,CAAA;KACtB,CAAA,IACN;IACD;;EAEJ,CAAA;CACI,CAAA;AAEf,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/components/motion/attachment-upload.d.ts
|
|
2
|
+
type AttachmentUploadKind = "file" | "link" | "image" | "audio";
|
|
3
|
+
type AttachmentRejectReason = "too-large" | "max-files";
|
|
4
|
+
type AttachmentUploadStatus = "idle" | "uploading" | "complete" | "failed";
|
|
5
|
+
type AttachmentUploadItem = {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
kind: AttachmentUploadKind;
|
|
9
|
+
size?: number;
|
|
10
|
+
href?: string;
|
|
11
|
+
previewUrl?: string;
|
|
12
|
+
currentTime?: number;
|
|
13
|
+
duration?: number;
|
|
14
|
+
status?: AttachmentUploadStatus;
|
|
15
|
+
error?: string;
|
|
16
|
+
file?: File;
|
|
17
|
+
};
|
|
18
|
+
type AttachmentUploadClassNames = {
|
|
19
|
+
dropzone?: string;
|
|
20
|
+
list?: string;
|
|
21
|
+
row?: string;
|
|
22
|
+
};
|
|
23
|
+
interface AttachmentUploadProps {
|
|
24
|
+
value?: AttachmentUploadItem[];
|
|
25
|
+
defaultValue?: AttachmentUploadItem[];
|
|
26
|
+
onValueChange?: (items: AttachmentUploadItem[]) => void;
|
|
27
|
+
onFilesAdded?: (items: AttachmentUploadItem[], files: File[]) => void;
|
|
28
|
+
onFilesRejected?: (files: File[], reason: AttachmentRejectReason) => void;
|
|
29
|
+
onRemove?: (item: AttachmentUploadItem) => void;
|
|
30
|
+
onRetry?: (item: AttachmentUploadItem) => void;
|
|
31
|
+
playingId?: string;
|
|
32
|
+
onAudioToggle?: (item: AttachmentUploadItem) => void;
|
|
33
|
+
accept?: string;
|
|
34
|
+
multiple?: boolean;
|
|
35
|
+
maxFiles?: number;
|
|
36
|
+
maxFileSize?: number;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
title?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
attachmentsLabel?: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
classNames?: AttachmentUploadClassNames;
|
|
43
|
+
}
|
|
44
|
+
declare function AttachmentUpload({ value, defaultValue, onValueChange, onFilesAdded, onFilesRejected, onRemove, onRetry, playingId, onAudioToggle, accept, multiple, maxFiles, maxFileSize, disabled, title, description, attachmentsLabel, className, classNames }: AttachmentUploadProps): import("react").JSX.Element;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { AttachmentRejectReason, AttachmentUpload, AttachmentUploadClassNames, AttachmentUploadItem, AttachmentUploadKind, AttachmentUploadProps, AttachmentUploadStatus };
|
|
47
|
+
//# sourceMappingURL=attachment-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-upload.d.ts","names":[],"sources":["../../../src/components/motion/attachment-upload.tsx"],"mappings":";KAyBY;KACA;KACA;KAEA;EACV;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA,OAAO;;KAGG;EACV;EACA;EACA;;UAGe;EACf,QAAQ;EACR,eAAe;EACf,iBAAiB,OAAO;EACxB,gBAAgB,OAAO,wBAAwB,OAAO;EACtD,mBAAmB,OAAO,QAAQ,QAAQ;EAC1C,YAAY,MAAM;EAClB,WAAW,MAAM;EACjB;EACA,iBAAiB,MAAM;EACvB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;;iBA4jBC,mBACd,OACA,cACA,eACA,cACA,iBACA,UACA,SACA,WACA,eACA,QACA,UACA,UACA,aACA,UACA,OACA,aACA,kBACA,WACA,cACC,wCAAqB,IAAA"}
|