next-recomponents 2.0.10 → 2.0.12

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.
@@ -0,0 +1,88 @@
1
+ import Button from "../button";
2
+ import { PopupActions } from "./actions";
3
+ import { COLOR_CONFIG } from "./color";
4
+ import { PopupIcon } from "./icon";
5
+ import { PromptInput } from "./input";
6
+ import { PopupOverlayProps } from "./types";
7
+
8
+ export function PopupOverlay({
9
+ popup,
10
+ onClose,
11
+ onInputChange,
12
+ }: PopupOverlayProps) {
13
+ const c = COLOR_CONFIG[popup.color];
14
+ const resolvedMessage =
15
+ typeof popup.message === "function" ? popup.message() : popup.message;
16
+ return (
17
+ <div
18
+ className={"fixed inset-0 flex items-center justify-center z-[1000] "}
19
+ style={{ background: "rgba(15,23,42,0.45)", backdropFilter: "blur(2px)" }}
20
+ onClick={(e) => {
21
+ if (e.target === e.currentTarget) {
22
+ onClose(false);
23
+ popup.onCancel?.();
24
+ }
25
+ }}
26
+ >
27
+ <style>{`
28
+ @keyframes fadeInScale {
29
+ from { opacity: 0; transform: scale(0.93) translateY(8px); }
30
+ to { opacity: 1; transform: scale(1) translateY(0); }
31
+ }
32
+ `}</style>
33
+
34
+ <div
35
+ className={`bg-gradient-to-br ${c.bg} border ${c.border} ${popup.full == true ? " w-full h-screen m-20 " : " max-w-sm "} rounded-2xl shadow-2xl mx-4`}
36
+ style={{ animation: "fadeInScale 0.18s ease-out", overflow: "auto" }}
37
+ >
38
+ {/* Header */}
39
+ <div className="flex flex-col items-center gap-3 px-8 pt-8 pb-5 text-center ">
40
+ {popup?.icons == true && (
41
+ <PopupIcon
42
+ label={c.label}
43
+ iconBg={c.iconBg}
44
+ iconText={c.iconText}
45
+ />
46
+ )}
47
+ {
48
+ <div className="w-full flex justify-end">
49
+ <Button color="danger" onClick={(e) => onClose(false)}>
50
+ X
51
+ </Button>
52
+ </div>
53
+ }
54
+ <div
55
+ className={"text-gray-800 text-[15px] font-medium leading-snug "}
56
+ >
57
+ {resolvedMessage}
58
+ </div>
59
+ </div>
60
+
61
+ {/* Prompt input */}
62
+ {popup.type === "prompt" && (
63
+ <PromptInput
64
+ value={popup.inputValue}
65
+ border={c.border}
66
+ focusRing={c.focusRing}
67
+ onChange={onInputChange}
68
+ onEnter={() => onClose(true, popup.inputValue)}
69
+ />
70
+ )}
71
+
72
+ {/* Divider */}
73
+ <div className={`border-t ${c.border} mt-4`} />
74
+
75
+ {/* Actions */}
76
+ {popup.type !== "modal" && (
77
+ <PopupActions
78
+ type={popup.type}
79
+ confirm={c.confirm}
80
+ focusRing={c.focusRing}
81
+ onConfirm={() => onClose(true, popup.inputValue)}
82
+ onCancel={() => onClose(false)}
83
+ />
84
+ )}
85
+ </div>
86
+ </div>
87
+ );
88
+ }
@@ -0,0 +1,56 @@
1
+ // ─── Types ────────────────────────────────────────────────────────────────────
2
+
3
+ import { ReactNode } from "react";
4
+ export interface PopupOverlayProps {
5
+ popup: PopupState;
6
+ onClose: (confirmed: boolean, value?: string) => void;
7
+ onInputChange: (value: string) => void;
8
+ }
9
+
10
+ export interface PromptInputProps {
11
+ value: string;
12
+ border: string;
13
+ focusRing: string;
14
+ onChange: (value: string) => void;
15
+ onEnter: () => void;
16
+ }
17
+
18
+ export interface PopupActionsProps {
19
+ type: PopupType;
20
+ confirm: string;
21
+ focusRing: string;
22
+ onConfirm: () => void;
23
+ onCancel: () => void;
24
+ }
25
+ export type PopupColor =
26
+ | "white"
27
+ | "primary"
28
+ | "secondary"
29
+ | "info"
30
+ | "danger"
31
+ | "warning"
32
+ | "success";
33
+
34
+ export type PopupType = "alert" | "modal" | "confirm" | "prompt";
35
+
36
+ export interface PopupState {
37
+ type: PopupType;
38
+ message: string | ReactNode | (() => string | ReactNode);
39
+ visible: boolean;
40
+ inputValue: string;
41
+ color: PopupColor;
42
+ onConfirm?: (value?: string) => void;
43
+ onCancel?: () => void;
44
+ icons?: boolean;
45
+ full?: boolean;
46
+ }
47
+
48
+ export interface ColorTokens {
49
+ bg: string;
50
+ iconBg: string;
51
+ iconText: string;
52
+ border: string;
53
+ confirm: string;
54
+ focusRing: string;
55
+ label: string;
56
+ }