1- import React from "react" ;
21import {
32 AlertCircle ,
43 CheckCircle ,
54 Info ,
65 Loader2 ,
76 XCircle ,
87} from "lucide-react-native" ;
8+ import React from "react" ;
99import { DialogConfig , DialogPriority } from "./dialog-types" ;
1010
11+ /**
12+ * Pre-configured dialog templates for common use cases
13+ * @description Ready-to-use dialog configurations with appropriate icons, priorities, and behaviors
14+ * @example
15+ * ```tsx
16+ * const { showError, showSuccess } = useDialog();
17+ *
18+ * // Use error template
19+ * showError(DialogTemplates.error("Failed to save file"));
20+ *
21+ * // Use success template with custom title
22+ * showSuccess(DialogTemplates.success("File uploaded successfully", {
23+ * title: "Upload Complete"
24+ * }));
25+ * ```
26+ */
1127export const DialogTemplates = {
28+ /**
29+ * Error dialog template with high priority and red X icon
30+ * @param {string } message - Error message to display
31+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
32+ * @returns {DialogConfig } Complete error dialog configuration
33+ * @example
34+ * ```tsx
35+ * showError(DialogTemplates.error("Network connection failed"));
36+ * ```
37+ */
1238 error : ( message : string , options ?: Partial < DialogConfig > ) : DialogConfig => ( {
1339 type : "error" ,
1440 priority : DialogPriority . HIGH ,
@@ -20,6 +46,16 @@ export const DialogTemplates = {
2046 timestamp : Date . now ( ) ,
2147 } ) ,
2248
49+ /**
50+ * Success dialog template with green checkmark and auto-hide
51+ * @param {string } message - Success message to display
52+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
53+ * @returns {DialogConfig } Complete success dialog configuration
54+ * @example
55+ * ```tsx
56+ * showSuccess(DialogTemplates.success("File uploaded successfully!"));
57+ * ```
58+ */
2359 success : (
2460 message : string ,
2561 options ?: Partial < DialogConfig > ,
@@ -35,6 +71,16 @@ export const DialogTemplates = {
3571 timestamp : Date . now ( ) ,
3672 } ) ,
3773
74+ /**
75+ * Info dialog template with blue info icon and low priority
76+ * @param {string } message - Information message to display
77+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
78+ * @returns {DialogConfig } Complete info dialog configuration
79+ * @example
80+ * ```tsx
81+ * showInfo(DialogTemplates.info("New features available"));
82+ * ```
83+ */
3884 info : ( message : string , options ?: Partial < DialogConfig > ) : DialogConfig => ( {
3985 type : "info" ,
4086 priority : DialogPriority . LOW ,
@@ -47,6 +93,16 @@ export const DialogTemplates = {
4793 timestamp : Date . now ( ) ,
4894 } ) ,
4995
96+ /**
97+ * Warning dialog template with amber warning icon
98+ * @param {string } message - Warning message to display
99+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
100+ * @returns {DialogConfig } Complete warning dialog configuration
101+ * @example
102+ * ```tsx
103+ * showAlert(DialogTemplates.warning("Battery is low"));
104+ * ```
105+ */
50106 warning : (
51107 message : string ,
52108 options ?: Partial < DialogConfig > ,
@@ -61,6 +117,16 @@ export const DialogTemplates = {
61117 timestamp : Date . now ( ) ,
62118 } ) ,
63119
120+ /**
121+ * Loading dialog template with spinner and persistent priority
122+ * @param {string } message - Loading message to display
123+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
124+ * @returns {DialogConfig } Complete loading dialog configuration
125+ * @example
126+ * ```tsx
127+ * const controller = showPersistent(DialogTemplates.loading("Processing data..."));
128+ * ```
129+ */
64130 loading : (
65131 message : string ,
66132 options ?: Partial < DialogConfig > ,
@@ -75,6 +141,16 @@ export const DialogTemplates = {
75141 timestamp : Date . now ( ) ,
76142 } ) ,
77143
144+ /**
145+ * Critical error dialog template with highest priority and cannot be dismissed
146+ * @param {string } message - Critical error message to display
147+ * @param {Partial<DialogConfig> } options - Additional configuration overrides
148+ * @returns {DialogConfig } Complete critical error dialog configuration
149+ * @example
150+ * ```tsx
151+ * showDialog(DialogTemplates.critical("System failure - app must restart"));
152+ * ```
153+ */
78154 critical : (
79155 message : string ,
80156 options ?: Partial < DialogConfig > ,
0 commit comments