@ordinatio/ui 1.1.0

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,639 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { Component, ReactNode, ErrorInfo, ComponentType, CSSProperties, RefObject } from 'react';
4
+
5
+ interface ErrorBoundaryProps {
6
+ children: ReactNode;
7
+ /** Custom fallback UI to render on error */
8
+ fallback?: ReactNode;
9
+ /** Called when an error is caught */
10
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
11
+ /** Error code to use (default: RENDER_100) */
12
+ errorCode?: string;
13
+ /** Custom title for error display */
14
+ title?: string;
15
+ /** Custom message for error display */
16
+ message?: string;
17
+ /** Text shown below error ref (default: "Copy this code and give it to Claude for instant diagnosis.") */
18
+ refHint?: string;
19
+ /** Action buttons to render below the error. Receives reset callback. */
20
+ renderActions?: (reset: () => void) => ReactNode;
21
+ }
22
+ interface ErrorBoundaryState {
23
+ hasError: boolean;
24
+ error: Error | null;
25
+ errorRef: string | null;
26
+ errorCode: string | null;
27
+ componentStack: string | null;
28
+ }
29
+ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
30
+ constructor(props: ErrorBoundaryProps);
31
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
32
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
33
+ handleReset: () => void;
34
+ render(): ReactNode;
35
+ }
36
+ /**
37
+ * HOC for wrapping components with an error boundary.
38
+ */
39
+ declare function withErrorBoundary<P extends object>(WrappedComponent: ComponentType<P>, boundaryProps?: Omit<ErrorBoundaryProps, 'children'>): (props: P) => react_jsx_runtime.JSX.Element;
40
+
41
+ interface EmailBodyRendererProps {
42
+ /** Raw HTML body of the email */
43
+ bodyHtml?: string | null;
44
+ /** Plain text fallback */
45
+ bodyText?: string | null;
46
+ /** Snippet fallback when no body content */
47
+ snippet?: string;
48
+ /** Minimum height for the iframe (default: '200px') */
49
+ minHeight?: string;
50
+ /** Extra CSS injected into the iframe <head> */
51
+ iframeStyles?: string;
52
+ /** Container className (for Tailwind consumers) */
53
+ className?: string;
54
+ /** Container inline styles */
55
+ style?: CSSProperties;
56
+ /**
57
+ * Optional HTML sanitizer for legacy emails stored before
58
+ * sanitize-html was wired into content-service.ts. If omitted,
59
+ * the renderer falls back to basic regex stripping when it
60
+ * detects dangerous tags.
61
+ */
62
+ sanitize?: (html: string) => string;
63
+ /**
64
+ * Image privacy policy. Defaults to 'block'.
65
+ * - 'block': replace proxied images with placeholders (most private)
66
+ * - 'proxy': load images through the server-side proxy (private but visible)
67
+ */
68
+ imagePolicy?: 'block' | 'proxy';
69
+ /** Callback when user clicks "Show images" in the privacy banner. */
70
+ onShowImages?: () => void;
71
+ /** Sender domain for the "Always show from X" button. */
72
+ senderDomain?: string;
73
+ /** Callback when user clicks "Always show from X". */
74
+ onTrustSender?: (domain: string) => void;
75
+ }
76
+ /**
77
+ * Renders email HTML in an isolated iframe.
78
+ *
79
+ * - CSP meta tag blocks all external resource loading (browser-enforced)
80
+ * - Preserves `<style>` blocks (iframe + CSP isolate CSS)
81
+ * - Sets `<base target="_blank">` so all links open in new tabs
82
+ * - Auto-resizes iframe height to fit content via ResizeObserver
83
+ * - Sandboxed: `allow-same-origin allow-popups allow-popups-to-escape-sandbox`
84
+ * - Falls back to `<pre>` for plain text, or snippet text
85
+ */
86
+ declare function EmailBodyRenderer({ bodyHtml, bodyText, snippet, minHeight, iframeStyles, className, style, sanitize, imagePolicy, onShowImages, senderDomain, onTrustSender, }: EmailBodyRendererProps): react_jsx_runtime.JSX.Element | null;
87
+
88
+ interface ThreadMessage {
89
+ id: string;
90
+ fromEmail: string;
91
+ fromName?: string | null;
92
+ emailDate: string;
93
+ snippet?: string | null;
94
+ bodyHtml?: string | null;
95
+ bodyText?: string | null;
96
+ }
97
+ interface EmailThreadViewProps<T extends ThreadMessage = ThreadMessage> {
98
+ /** Array of messages in the thread, ordered oldest to newest */
99
+ messages: T[];
100
+ /** Which message IDs start expanded (default: last message) */
101
+ initialExpanded?: string[];
102
+ /** Custom renderer for an expanded message body */
103
+ renderMessage?: (message: T, isExpanded: boolean) => ReactNode;
104
+ /** Container className */
105
+ className?: string;
106
+ /** Container inline styles */
107
+ style?: CSSProperties;
108
+ }
109
+ /**
110
+ * Gmail-style email thread view with expand/collapse.
111
+ *
112
+ * - Auto-expands the latest message
113
+ * - Click header to toggle expand/collapse
114
+ * - Shows sender avatar, name, snippet preview, and date
115
+ * - Renders message body via EmailBodyRenderer or custom renderMessage
116
+ */
117
+ declare function EmailThreadView<T extends ThreadMessage = ThreadMessage>({ messages, initialExpanded, renderMessage, className, style, }: EmailThreadViewProps<T>): react_jsx_runtime.JSX.Element | null;
118
+
119
+ interface KeyboardShortcut {
120
+ /** Key to listen for (e.g., 'r', 'e', 'Escape'). Case-insensitive. */
121
+ key: string;
122
+ /** Handler function */
123
+ handler: () => void;
124
+ /** Require modifier keys (default: none) */
125
+ modifiers?: {
126
+ meta?: boolean;
127
+ ctrl?: boolean;
128
+ alt?: boolean;
129
+ shift?: boolean;
130
+ };
131
+ }
132
+ interface UseKeyboardShortcutsOptions {
133
+ /** Shortcuts to register */
134
+ shortcuts: KeyboardShortcut[];
135
+ /** Whether shortcuts are active (default: true) */
136
+ enabled?: boolean;
137
+ /** Tags to ignore (default: INPUT, TEXTAREA, SELECT) */
138
+ ignoreTags?: string[];
139
+ }
140
+ /**
141
+ * Register keyboard shortcuts that respect form inputs.
142
+ *
143
+ * @example
144
+ * useKeyboardShortcuts({
145
+ * shortcuts: [
146
+ * { key: 'r', handler: () => handleReply() },
147
+ * { key: 'e', handler: () => handleArchive() },
148
+ * { key: 'Escape', handler: () => closeModal() },
149
+ * { key: 'k', handler: () => openSearch(), modifiers: { meta: true } },
150
+ * ],
151
+ * });
152
+ */
153
+ declare function useKeyboardShortcuts({ shortcuts, enabled, ignoreTags, }: UseKeyboardShortcutsOptions): void;
154
+
155
+ interface ShortcutDefinition {
156
+ /** Key to listen for (lowercase, single char or special: 'Escape', 'Enter') */
157
+ key: string;
158
+ /** Modifier keys required */
159
+ modifiers?: {
160
+ meta?: boolean;
161
+ ctrl?: boolean;
162
+ alt?: boolean;
163
+ shift?: boolean;
164
+ };
165
+ /** Human-readable action name for the cheat sheet */
166
+ action: string;
167
+ /** One-line description shown in the cheat sheet */
168
+ description: string;
169
+ /** Display string for the keyboard hint badge (e.g. "E", "⌘↵", "⌘⇧M") */
170
+ display: string;
171
+ }
172
+ interface ShortcutContext {
173
+ name: string;
174
+ label: string;
175
+ shortcuts: Record<string, ShortcutDefinition>;
176
+ }
177
+ declare const GLOBAL_SHORTCUTS: ShortcutContext;
178
+ declare const CLIENT_PROFILE_SHORTCUTS: ShortcutContext;
179
+ declare const INBOX_SHORTCUTS: ShortcutContext;
180
+ declare const FORM_SHORTCUTS: ShortcutContext;
181
+ declare const ALL_SHORTCUT_CONTEXTS: ShortcutContext[];
182
+ /**
183
+ * Look up a shortcut by context + action name.
184
+ * Returns the definition or undefined if not found.
185
+ */
186
+ declare function getShortcut(context: ShortcutContext, action: string): ShortcutDefinition | undefined;
187
+
188
+ type ActionHandlers = Record<string, (() => void) | undefined>;
189
+ /**
190
+ * Register keyboard shortcuts for a specific context using
191
+ * Ordinatio defaults. Pass handlers for the actions you support;
192
+ * undefined handlers are silently skipped.
193
+ *
194
+ * Automatically suppresses shortcuts when:
195
+ * - User is typing in a form input (via useKeyboardShortcuts)
196
+ * - Any overlay/dialog/modal is active in the DOM
197
+ * - `enabled` is explicitly false
198
+ *
199
+ * @param context — Ordinatio shortcut context (e.g. CLIENT_PROFILE_SHORTCUTS)
200
+ * @param handlers — Map of action name → callback
201
+ * @param enabled — Manual override (default: true)
202
+ *
203
+ * @returns The active ShortcutDefinition entries for UI display
204
+ */
205
+ declare function useContextShortcuts(context: ShortcutContext, handlers: ActionHandlers, enabled?: boolean): ShortcutDefinition[];
206
+
207
+ interface KeyboardShortcutsPanelProps {
208
+ contexts?: ShortcutContext[];
209
+ }
210
+ declare function KeyboardShortcutsPanel({ contexts, }: KeyboardShortcutsPanelProps): react_jsx_runtime.JSX.Element | null;
211
+
212
+ interface UseAutoSaveOptions<T> {
213
+ /** Current data to auto-save */
214
+ data: T;
215
+ /** Async function that persists the data */
216
+ onSave: (data: T) => Promise<void>;
217
+ /** Debounce delay in ms (default: 5000) */
218
+ delay?: number;
219
+ /** Whether auto-save is active (default: true) */
220
+ enabled?: boolean;
221
+ }
222
+ interface UseAutoSaveResult {
223
+ /** When the last successful save occurred */
224
+ lastSavedAt: Date | null;
225
+ /** Whether a save is in progress */
226
+ isSaving: boolean;
227
+ /** Error message from the last failed save */
228
+ saveError: string | null;
229
+ }
230
+ /**
231
+ * Auto-save data with debounce and duplicate detection.
232
+ *
233
+ * Tracks data changes via JSON comparison — won't re-save
234
+ * identical data. Exposes timestamps, saving state, and errors
235
+ * for "Draft saved at HH:MM" UI feedback.
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const { lastSavedAt, isSaving } = useAutoSave({
240
+ * data: { subject, body, toEmail },
241
+ * onSave: async (data) => {
242
+ * await fetch('/api/drafts', {
243
+ * method: 'PATCH',
244
+ * body: JSON.stringify(data),
245
+ * });
246
+ * },
247
+ * delay: 5000,
248
+ * });
249
+ * ```
250
+ */
251
+ declare function useAutoSave<T>({ data, onSave, delay, enabled, }: UseAutoSaveOptions<T>): UseAutoSaveResult;
252
+
253
+ interface UsePollingOptions<T> {
254
+ /** Async function that fetches the latest data */
255
+ fetcher: () => Promise<T>;
256
+ /** Polling interval in ms (default: 30000 — 30 seconds) */
257
+ interval?: number;
258
+ /** Whether polling is active (default: true) */
259
+ enabled?: boolean;
260
+ /** Called when fetch fails (optional — failures are swallowed by default) */
261
+ onError?: (error: unknown) => void;
262
+ }
263
+ interface UsePollingResult<T> {
264
+ /** Latest data from the fetcher */
265
+ data: T | null;
266
+ /** Whether the initial load is in progress */
267
+ isLoading: boolean;
268
+ /** Whether a background refresh is in progress */
269
+ isRefreshing: boolean;
270
+ /** Error from the last fetch attempt */
271
+ error: string | null;
272
+ /** Manually trigger a refresh */
273
+ refresh: () => Promise<void>;
274
+ }
275
+ /**
276
+ * Poll an async data source at a fixed interval.
277
+ *
278
+ * Performs an immediate fetch on mount, then polls at the
279
+ * configured interval. Each poll fully replaces the data
280
+ * (not appends) to prevent stale accumulation.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const { data, isLoading, refresh } = usePolling({
285
+ * fetcher: () => fetch('/api/timeline').then(r => r.json()),
286
+ * interval: 30_000,
287
+ * });
288
+ * ```
289
+ */
290
+ declare function usePolling<T>({ fetcher, interval, enabled, onError, }: UsePollingOptions<T>): UsePollingResult<T>;
291
+
292
+ interface UseServerSearchOptions<T> {
293
+ /** Async function that fetches results for a search query */
294
+ fetcher: (query: string) => Promise<T[]>;
295
+ /** Debounce delay in ms (default: 150) */
296
+ debounce?: number;
297
+ /** Minimum characters before searching (default: 1) */
298
+ minChars?: number;
299
+ /** Whether search is active (default: true) */
300
+ enabled?: boolean;
301
+ }
302
+ interface UseServerSearchResult<T> {
303
+ /** Current search query */
304
+ query: string;
305
+ /** Set the search query */
306
+ setQuery: (query: string) => void;
307
+ /** Search results from the server */
308
+ results: T[];
309
+ /** Whether a search is in progress */
310
+ isSearching: boolean;
311
+ /** Whether the dropdown/results should be visible */
312
+ isOpen: boolean;
313
+ /** Set dropdown visibility */
314
+ setIsOpen: (open: boolean) => void;
315
+ /** Clear the search */
316
+ clear: () => void;
317
+ }
318
+ /**
319
+ * Server-side search with debounce and loading state.
320
+ *
321
+ * Sends the query to the server after the debounce delay,
322
+ * skips queries shorter than minChars, and manages open/close
323
+ * state for dropdown display.
324
+ *
325
+ * @example
326
+ * ```typescript
327
+ * const { query, setQuery, results, isSearching, isOpen } = useServerSearch({
328
+ * fetcher: async (q) => {
329
+ * const res = await fetch(`/api/fabrics?search=${encodeURIComponent(q)}&limit=10`);
330
+ * const data = await res.json();
331
+ * return data.fabrics;
332
+ * },
333
+ * debounce: 150,
334
+ * minChars: 1,
335
+ * });
336
+ * ```
337
+ */
338
+ declare function useServerSearch<T>({ fetcher, debounce, minChars, enabled, }: UseServerSearchOptions<T>): UseServerSearchResult<T>;
339
+
340
+ /**
341
+ * Keeps keyboard shortcuts working across iframe boundaries.
342
+ *
343
+ * **Primary:** Attaches keydown listeners to same-origin iframe
344
+ * documents and re-dispatches events on the parent window.
345
+ *
346
+ * **Safety net:** Reclaims focus from iframes when the user returns
347
+ * to the page (tab switch, alt-tab, window focus).
348
+ *
349
+ * The container element must have `tabIndex={-1}` to be focusable.
350
+ *
351
+ * ⚠️ **`EmailBodyRenderer` now handles keyboard forwarding internally.**
352
+ * This hook is only needed for raw `<iframe>` elements that do NOT use
353
+ * `EmailBodyRenderer`. Using both on the same iframe causes duplicate
354
+ * `forwardKeydown` listeners, making each shortcut fire twice.
355
+ *
356
+ * @param containerRef - Ref to the container div (must have tabIndex={-1})
357
+ * @param enabled - Whether the hook is active (default: true)
358
+ * @param iframeSelector - CSS selector for iframes to monitor (default: 'iframe')
359
+ */
360
+ declare function useIframeFocusReclaim(containerRef: RefObject<HTMLDivElement | null>, enabled?: boolean, iframeSelector?: string): void;
361
+
362
+ interface CachedFetchOptions {
363
+ /** fetch RequestInit options */
364
+ fetchOptions?: RequestInit;
365
+ /** How long data is considered fresh (ms). Default: 30000 */
366
+ staleTime?: number;
367
+ /** How long data is kept before eviction (ms). Default: 300000 */
368
+ maxAge?: number;
369
+ }
370
+ /**
371
+ * Fetch with stale-while-revalidate caching.
372
+ *
373
+ * Returns cached data immediately if available, then revalidates
374
+ * in the background. The `onData` callback may fire twice:
375
+ * once with cached data, once with fresh data.
376
+ *
377
+ * @param url - API endpoint
378
+ * @param options - cache and fetch options
379
+ * @param onData - called with data (may be called twice: cache then fresh)
380
+ */
381
+ declare function cachedFetch<T>(url: string, options?: CachedFetchOptions, onData?: (data: T, fromCache: boolean) => void): Promise<T>;
382
+ /**
383
+ * Invalidate a specific cache entry (e.g., after mutation).
384
+ */
385
+ declare function invalidateCache(url: string, method?: string): void;
386
+ /**
387
+ * Prefetch a URL into the cache (fire-and-forget).
388
+ */
389
+ declare function prefetch(url: string): void;
390
+ /**
391
+ * Clear the entire cache.
392
+ */
393
+ declare function clearCache(): void;
394
+
395
+ interface UsePreferencesOptions<T> {
396
+ /** API endpoint to fetch/update preferences (e.g., '/api/user/preferences') */
397
+ endpoint: string;
398
+ /** Default preferences when not logged in or on first load */
399
+ defaults?: T;
400
+ }
401
+ interface UsePreferencesResult<T> {
402
+ /** Current preferences (null during initial load) */
403
+ preferences: T | null;
404
+ /** Whether the initial load is in progress */
405
+ loading: boolean;
406
+ /** Error message from fetch or update */
407
+ error: string | null;
408
+ /** Update preferences — PATCH to endpoint, updates local state */
409
+ updatePreferences: (updates: Partial<T>) => Promise<void>;
410
+ /** Re-fetch preferences from the server */
411
+ refetch: () => Promise<void>;
412
+ }
413
+ /**
414
+ * Generic hook for user preferences with fetch-on-mount and PATCH updates.
415
+ *
416
+ * Follows the "instant local, async server" pattern: local state updates
417
+ * immediately while the server call runs in the background.
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * const { preferences, updatePreferences } = usePreferences<{
422
+ * replyLayout: 'MODAL' | 'SPLIT_HORIZONTAL';
423
+ * theme: 'light' | 'dark';
424
+ * }>({ endpoint: '/api/user/preferences' });
425
+ *
426
+ * // Instant update + background sync
427
+ * await updatePreferences({ replyLayout: 'SPLIT_HORIZONTAL' });
428
+ * ```
429
+ */
430
+ declare function usePreferences<T extends Record<string, unknown>>({ endpoint, defaults, }: UsePreferencesOptions<T>): UsePreferencesResult<T>;
431
+
432
+ /**
433
+ * Format a date into a human-friendly group label.
434
+ * Returns "Today", "Yesterday", or "MMM D, YYYY".
435
+ *
436
+ * @example
437
+ * formatDateGroup(new Date()) // → "Today"
438
+ * formatDateGroup('2026-04-07T12:00:00Z') // → "Apr 7, 2026"
439
+ */
440
+ declare function formatDateGroup(timestamp: Date | string): string;
441
+ /**
442
+ * Group an array of items by date label using formatDateGroup.
443
+ * Returns a Map preserving insertion order (most recent first if input is sorted).
444
+ *
445
+ * @param items - Array of items to group
446
+ * @param getTimestamp - Extractor function to get the date from each item
447
+ *
448
+ * @example
449
+ * const groups = groupByDate(entries, (e) => e.timestamp);
450
+ * // Map { "Today" => [...], "Yesterday" => [...], "Apr 6, 2026" => [...] }
451
+ */
452
+ declare function groupByDate<T>(items: T[], getTimestamp: (item: T) => Date | string): Map<string, T[]>;
453
+ /**
454
+ * Truncate text to a maximum length, adding "..." if truncated.
455
+ * Safe for null/undefined — returns empty string.
456
+ *
457
+ * @param text - Text to truncate
458
+ * @param limit - Maximum characters (default: 180)
459
+ *
460
+ * @example
461
+ * truncatePreview("A very long note...", 50)
462
+ * // → "A very long note..." (truncated at 50 chars)
463
+ */
464
+ declare function truncatePreview(text: string | null | undefined, limit?: number): string;
465
+ /**
466
+ * Strip HTML tags from a string. Useful for generating
467
+ * plain-text previews from rich text content.
468
+ *
469
+ * @example
470
+ * stripHtml('<p>Hello <b>world</b></p>') // → "Hello world"
471
+ */
472
+ declare function stripHtml(html: string): string;
473
+
474
+ /**
475
+ * Email compose mode — reply pre-fills the recipient,
476
+ * forward starts with an empty To field.
477
+ */
478
+ type ComposeMode = 'reply' | 'forward';
479
+ /**
480
+ * Reply layout modes for email detail pages.
481
+ * Controls how the compose panel is rendered.
482
+ */
483
+ type ReplyLayout = 'MODAL' | 'SPLIT_HORIZONTAL' | 'SPLIT_VERTICAL' | 'POPOUT';
484
+ /**
485
+ * All available reply layout options with labels for dropdowns.
486
+ */
487
+ declare const REPLY_LAYOUT_OPTIONS: {
488
+ value: ReplyLayout;
489
+ label: string;
490
+ }[];
491
+ /**
492
+ * Check if the layout renders the compose panel inline (not in a dialog).
493
+ */
494
+ declare function isInlineLayout(layout: ReplyLayout): boolean;
495
+ /**
496
+ * Check if the layout renders the compose panel in a dialog/modal.
497
+ */
498
+ declare function isModalLayout(layout: ReplyLayout): boolean;
499
+ interface SchedulePreset {
500
+ label: string;
501
+ date: Date;
502
+ }
503
+ /**
504
+ * Get the next occurrence of a weekday (Mon=1 ... Sun=0) at a given hour.
505
+ * If today matches but the hour has passed, returns next week.
506
+ */
507
+ declare function getNextWeekday(dayOfWeek: number, hour: number): Date;
508
+ /** Tomorrow at 9:00 AM local time. */
509
+ declare function getTomorrowMorning(): Date;
510
+ /** Next Monday at 9:00 AM local time. */
511
+ declare function getNextMondayMorning(): Date;
512
+ /**
513
+ * Quick schedule presets for "Send Later" UIs.
514
+ * Returns relative options (1h, 2h, tomorrow 9am, etc.).
515
+ *
516
+ * @example
517
+ * const options = getQuickScheduleOptions();
518
+ * // [{ label: "In 1 hour", date: Date }, ...]
519
+ */
520
+ declare function getQuickScheduleOptions(): SchedulePreset[];
521
+ /**
522
+ * Validate that a scheduled date is in the future.
523
+ */
524
+ declare function isValidScheduleDate(date: Date): boolean;
525
+ /**
526
+ * Parse a custom schedule from separate date and time strings.
527
+ * Returns null if invalid or in the past.
528
+ *
529
+ * @param dateStr - Date in YYYY-MM-DD format
530
+ * @param timeStr - Time in HH:MM format (default: "09:00")
531
+ */
532
+ declare function parseCustomSchedule(dateStr: string, timeStr?: string): Date | null;
533
+
534
+ /**
535
+ * Check if a file is a PDF by MIME type or file extension.
536
+ * Handles Gmail's `application/octet-stream` by checking `.pdf` extension.
537
+ */
538
+ declare function isPdf(mimeType: string, name?: string): boolean;
539
+ /**
540
+ * Check if a file is a spreadsheet (XLSX, XLS, CSV) by MIME type or extension.
541
+ */
542
+ declare function isSpreadsheet(mimeType: string, name?: string): boolean;
543
+ /**
544
+ * Check if a file is a Word document by MIME type or extension.
545
+ */
546
+ declare function isDocument(mimeType: string, name?: string): boolean;
547
+ /**
548
+ * Check if a file is an image by MIME type.
549
+ */
550
+ declare function isImage(mimeType: string): boolean;
551
+ /**
552
+ * Check if a file is audio by MIME type.
553
+ */
554
+ declare function isAudio(mimeType: string): boolean;
555
+ /**
556
+ * Check if a file is video by MIME type.
557
+ */
558
+ declare function isVideo(mimeType: string): boolean;
559
+ /**
560
+ * Check if a file can be viewed inline in a browser (images, audio, video).
561
+ */
562
+ declare function canViewInline(mimeType: string): boolean;
563
+ /**
564
+ * Check if a file should open in a new browser tab (PDFs, spreadsheets).
565
+ */
566
+ declare function opensInNewTab(mimeType: string, name?: string): boolean;
567
+ /**
568
+ * Get the correct MIME type for a file, using extension as fallback.
569
+ * Useful when the provider returns `application/octet-stream`.
570
+ *
571
+ * @example
572
+ * resolveContentType('application/octet-stream', 'invoice.pdf')
573
+ * // → 'application/pdf'
574
+ */
575
+ declare function resolveContentType(mimeType: string, name?: string): string;
576
+ /**
577
+ * Format file size in human-readable units.
578
+ *
579
+ * @example
580
+ * formatFileSize(1536) // → "1.5 KB"
581
+ * formatFileSize(0) // → "0 B"
582
+ */
583
+ declare function formatFileSize(bytes: number): string;
584
+
585
+ /**
586
+ * Format a phone number for display.
587
+ * "2489783240" → "(248) 978-3240"
588
+ * "12489783240" → "(248) 978-3240" (strips leading 1)
589
+ * Already formatted or non-standard → returned as-is.
590
+ */
591
+ declare function formatPhone(phone: string | null | undefined): string;
592
+ /**
593
+ * Format phone as you type. Adds formatting while
594
+ * preserving cursor usability in input fields.
595
+ */
596
+ declare function formatPhoneInput(value: string): string;
597
+ /**
598
+ * Strip formatting from phone number for storage.
599
+ * "(248) 978-3240" → "2489783240"
600
+ */
601
+ declare function stripPhone(phone: string): string;
602
+
603
+ interface RenderErrorResult {
604
+ code: string;
605
+ ref: string;
606
+ timestamp: string;
607
+ module: string;
608
+ context: Record<string, unknown>;
609
+ }
610
+ /**
611
+ * Generate a render error with unique timestamped ref.
612
+ * Format: CODE-YYYYMMDDTHHMMSS (e.g., RENDER_100-20260407T162100)
613
+ */
614
+ declare function renderError(code: string, context?: Record<string, unknown>): RenderErrorResult;
615
+ /**
616
+ * Render Error Registry
617
+ *
618
+ * RENDER_100 — Generic component rendering failure
619
+ * RENDER_101 — Page failed to render (route-level crash)
620
+ * RENDER_102 — Data display component crashed (likely null/undefined data)
621
+ * RENDER_103 — Form component crashed
622
+ * RENDER_104 — List/table component crashed
623
+ * RENDER_105 — Modal/dialog component crashed
624
+ */
625
+ declare const RENDER_ERRORS: Record<string, {
626
+ code: string;
627
+ severity: 'error' | 'warning';
628
+ description: string;
629
+ diagnosis: string[];
630
+ }>;
631
+
632
+ type IconComponent = React.ComponentType<{
633
+ className?: string;
634
+ }>;
635
+ declare const ACTIVITY_ICONS: Record<string, IconComponent>;
636
+ /** Return the icon component for a given icon name, or Activity as fallback. */
637
+ declare function resolveActivityIcon(name: string): IconComponent;
638
+
639
+ export { ACTIVITY_ICONS, ALL_SHORTCUT_CONTEXTS, CLIENT_PROFILE_SHORTCUTS, type CachedFetchOptions, type ComposeMode, EmailBodyRenderer, type EmailBodyRendererProps, EmailThreadView, type EmailThreadViewProps, ErrorBoundary, type ErrorBoundaryProps, FORM_SHORTCUTS, GLOBAL_SHORTCUTS, INBOX_SHORTCUTS, type KeyboardShortcut, KeyboardShortcutsPanel, RENDER_ERRORS, REPLY_LAYOUT_OPTIONS, type RenderErrorResult, type ReplyLayout, type SchedulePreset, type ShortcutContext, type ShortcutDefinition, type ThreadMessage, type UseAutoSaveOptions, type UseAutoSaveResult, type UseKeyboardShortcutsOptions, type UsePollingOptions, type UsePollingResult, type UsePreferencesOptions, type UsePreferencesResult, type UseServerSearchOptions, type UseServerSearchResult, cachedFetch, canViewInline, clearCache, formatDateGroup, formatFileSize, formatPhone, formatPhoneInput, getNextMondayMorning, getNextWeekday, getQuickScheduleOptions, getShortcut, getTomorrowMorning, groupByDate, invalidateCache, isAudio, isDocument, isImage, isInlineLayout, isModalLayout, isPdf, isSpreadsheet, isValidScheduleDate, isVideo, opensInNewTab, parseCustomSchedule, prefetch, renderError, resolveActivityIcon, resolveContentType, stripHtml, stripPhone, truncatePreview, useAutoSave, useContextShortcuts, useIframeFocusReclaim, useKeyboardShortcuts, usePolling, usePreferences, useServerSearch, withErrorBoundary };