@pure-ds/core 0.4.24 → 0.4.26

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/src/js/pds.d.ts CHANGED
@@ -154,6 +154,68 @@ export class PDS extends EventTarget {
154
154
  static validateDesign: (designConfig: any, options?: { minContrast?: number }) => { ok: boolean; issues: Array<{ path: string; message: string; ratio: number; min: number; context?: string }> };
155
155
  static validateDesigns: (designs: Array<any> | Record<string, any>, options?: { minContrast?: number }) => { ok: boolean; results: Array<{ name?: string; ok: boolean; issues: Array<{ path: string; message: string; ratio: number; min: number; context?: string }> }> };
156
156
 
157
+ /**
158
+ * Display a toast notification.
159
+ *
160
+ * Automatically ensures the pds-toaster component exists and is loaded before displaying.
161
+ *
162
+ * @param message - The message to display
163
+ * @param options - Toast configuration
164
+ * @param options.type - Toast type/severity ("information" | "success" | "warning" | "error")
165
+ * @param options.duration - Duration in milliseconds (auto-calculated if not provided)
166
+ * @param options.closable - Whether toast can be manually closed (default: true)
167
+ * @param options.persistent - If true, toast won't auto-dismiss (default: false)
168
+ * @returns Toast ID (can be used to dismiss programmatically)
169
+ *
170
+ * @example
171
+ * await PDS.toast('Changes saved!', { type: 'success' });
172
+ *
173
+ * @example
174
+ * await PDS.toast('Error occurred', { type: 'error', persistent: true });
175
+ */
176
+ static toast(
177
+ message: string,
178
+ options?: {
179
+ type?: 'information' | 'success' | 'warning' | 'error';
180
+ duration?: number;
181
+ closable?: boolean;
182
+ persistent?: boolean;
183
+ }
184
+ ): Promise<string>;
185
+
186
+ /**
187
+ * Display a success toast (convenience method).
188
+ *
189
+ * @param message - The success message
190
+ * @param options - Additional toast options (type is preset to 'success')
191
+ * @returns Toast ID
192
+ *
193
+ * @example
194
+ * await PDS.toast.success('Profile updated!');
195
+ */
196
+ static toast: {
197
+ (message: string, options?: { type?: 'information' | 'success' | 'warning' | 'error'; duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
198
+ success(message: string, options?: { duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
199
+ error(message: string, options?: { duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
200
+ warning(message: string, options?: { duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
201
+ info(message: string, options?: { duration?: number; closable?: boolean; persistent?: boolean }): Promise<string>;
202
+ };
203
+
204
+ /**
205
+ * Display a modal dialog for user input or confirmation.
206
+ *
207
+ * @param message - The message or prompt to display
208
+ * @param options - Dialog configuration
209
+ * @returns User's response (string for prompt, boolean for confirm, true for alert)
210
+ *
211
+ * @example
212
+ * const confirmed = await PDS.ask('Delete this item?', { type: 'confirm' });
213
+ *
214
+ * @example
215
+ * const name = await PDS.ask('Enter your name:', { type: 'prompt' });
216
+ */
217
+ static ask(message: string, options?: any): Promise<any>;
218
+
157
219
  /**
158
220
  * Current configuration after PDS.start() completes - read-only, frozen after initialization.
159
221
  * Contains the complete configuration used to initialize PDS, including mode, design, preset, and theme.
package/src/js/pds.js CHANGED
@@ -56,6 +56,7 @@ import { findComponentForElement } from "./pds-core/pds-ontology.js";
56
56
  import { presets, defaultLog } from "./pds-core/pds-config.js";
57
57
  import { enums } from "./pds-core/pds-enums.js";
58
58
  import { ask } from "./common/ask.js";
59
+ import { toast } from "./common/toast.js";
59
60
  import { PDSQuery } from "./pds-core/pds-query.js";
60
61
  import * as common from "./common/common.js";
61
62
  import { defaultPDSEnhancers } from "./pds-core/pds-enhancers.js";
@@ -87,6 +88,7 @@ PDS.isLiveMode = () => registry.isLive;
87
88
  PDS.enums = enums;
88
89
 
89
90
  PDS.ask = ask;
91
+ PDS.toast = toast;
90
92
 
91
93
  // Expose common utilities (deepMerge, isObject, etc.)
92
94
  PDS.common = common;