@pelatform/ui 1.5.9 → 2.0.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.
Files changed (104) hide show
  1. package/css/source.css +20 -0
  2. package/css/theme.css +1 -2
  3. package/dist/animation.d.ts +4 -379
  4. package/dist/animation.js +2 -1752
  5. package/dist/aria.d.ts +1 -31
  6. package/dist/aria.js +2 -139
  7. package/dist/base.d.ts +1 -651
  8. package/dist/base.js +2 -5559
  9. package/dist/chunk-UEVIEY7W.js +51 -0
  10. package/dist/{components.cjs → chunk-VZEE3GOC.js} +81 -2344
  11. package/dist/components.d.ts +224 -181
  12. package/dist/components.js +364 -765
  13. package/dist/default.d.ts +1 -1322
  14. package/dist/default.js +2 -8931
  15. package/dist/hooks.d.ts +4 -1087
  16. package/dist/hooks.js +5 -662
  17. package/dist/index.d.ts +58 -308
  18. package/dist/index.js +5 -226
  19. package/package.json +29 -109
  20. package/dist/animation.cjs +0 -1752
  21. package/dist/animation.d.cts +0 -379
  22. package/dist/aria.cjs +0 -139
  23. package/dist/aria.d.cts +0 -31
  24. package/dist/badge-BtI4BMea.d.cts +0 -33
  25. package/dist/badge-BtI4BMea.d.ts +0 -33
  26. package/dist/base.cjs +0 -5559
  27. package/dist/base.d.cts +0 -651
  28. package/dist/chunk-3N75YA6Q.cjs +0 -60
  29. package/dist/chunk-7472NIIL.cjs +0 -40
  30. package/dist/chunk-BXUKTDPN.cjs +0 -576
  31. package/dist/chunk-CD2BCCQU.js +0 -180
  32. package/dist/chunk-CJXIPSTG.cjs +0 -10
  33. package/dist/chunk-CTHRAJQZ.js +0 -1522
  34. package/dist/chunk-D373YKDA.js +0 -196
  35. package/dist/chunk-EZW5GNS4.js +0 -6
  36. package/dist/chunk-HILACSFA.cjs +0 -1522
  37. package/dist/chunk-HR3R6KKM.js +0 -40
  38. package/dist/chunk-HW52LCWN.js +0 -22
  39. package/dist/chunk-I46SELBA.cjs +0 -22
  40. package/dist/chunk-J4JGE3U5.cjs +0 -180
  41. package/dist/chunk-RQHJBTEU.js +0 -10
  42. package/dist/chunk-SK6SSJHC.js +0 -9
  43. package/dist/chunk-T74DBLYY.js +0 -60
  44. package/dist/chunk-TB6DU23O.js +0 -576
  45. package/dist/chunk-UP53DCYH.cjs +0 -6
  46. package/dist/chunk-ZBO5IAMA.cjs +0 -196
  47. package/dist/chunk-ZDR3OZ7Z.cjs +0 -9
  48. package/dist/colors-CUDWvz1g.d.cts +0 -42
  49. package/dist/colors-CUDWvz1g.d.ts +0 -42
  50. package/dist/components-CidsRcc3.d.cts +0 -46
  51. package/dist/components-CidsRcc3.d.ts +0 -46
  52. package/dist/components.d.cts +0 -2944
  53. package/dist/default.cjs +0 -8931
  54. package/dist/default.d.cts +0 -1322
  55. package/dist/hooks.cjs +0 -666
  56. package/dist/hooks.d.cts +0 -1176
  57. package/dist/index.cjs +0 -230
  58. package/dist/index.d.cts +0 -318
  59. package/dist/input-AwYIskrX.d.cts +0 -22
  60. package/dist/input-AwYIskrX.d.ts +0 -22
  61. package/dist/menu-GmSRfRGB.d.cts +0 -43
  62. package/dist/menu-GmSRfRGB.d.ts +0 -43
  63. package/dist/metafile-cjs.json +0 -1
  64. package/dist/metafile-esm.json +0 -1
  65. package/dist/re-export/cva.cjs +0 -6
  66. package/dist/re-export/cva.d.cts +0 -10
  67. package/dist/re-export/cva.d.ts +0 -10
  68. package/dist/re-export/cva.js +0 -6
  69. package/dist/re-export/motion.cjs +0 -2
  70. package/dist/re-export/motion.d.cts +0 -1
  71. package/dist/re-export/motion.d.ts +0 -1
  72. package/dist/re-export/motion.js +0 -2
  73. package/dist/re-export/next-themes.cjs +0 -2
  74. package/dist/re-export/next-themes.d.cts +0 -1
  75. package/dist/re-export/next-themes.d.ts +0 -1
  76. package/dist/re-export/next-themes.js +0 -2
  77. package/dist/re-export/react-day-picker.cjs +0 -2
  78. package/dist/re-export/react-day-picker.d.cts +0 -1
  79. package/dist/re-export/react-day-picker.d.ts +0 -1
  80. package/dist/re-export/react-day-picker.js +0 -2
  81. package/dist/re-export/react-hook-form.cjs +0 -2
  82. package/dist/re-export/react-hook-form.d.cts +0 -1
  83. package/dist/re-export/react-hook-form.d.ts +0 -1
  84. package/dist/re-export/react-hook-form.js +0 -2
  85. package/dist/re-export/resolver.cjs +0 -2
  86. package/dist/re-export/resolver.d.cts +0 -1
  87. package/dist/re-export/resolver.d.ts +0 -1
  88. package/dist/re-export/resolver.js +0 -2
  89. package/dist/re-export/sonner.cjs +0 -2
  90. package/dist/re-export/sonner.d.cts +0 -1
  91. package/dist/re-export/sonner.d.ts +0 -1
  92. package/dist/re-export/sonner.js +0 -2
  93. package/dist/re-export/tanstack-query.cjs +0 -2
  94. package/dist/re-export/tanstack-query.d.cts +0 -1
  95. package/dist/re-export/tanstack-query.d.ts +0 -1
  96. package/dist/re-export/tanstack-query.js +0 -2
  97. package/dist/re-export/tanstack-table.cjs +0 -2
  98. package/dist/re-export/tanstack-table.d.cts +0 -1
  99. package/dist/re-export/tanstack-table.d.ts +0 -1
  100. package/dist/re-export/tanstack-table.js +0 -2
  101. package/dist/re-export/zod.cjs +0 -2
  102. package/dist/re-export/zod.d.cts +0 -1
  103. package/dist/re-export/zod.d.ts +0 -1
  104. package/dist/re-export/zod.js +0 -2
package/dist/hooks.d.ts CHANGED
@@ -1,495 +1,5 @@
1
- import * as React from 'react';
2
- import React__default, { DragEvent, ChangeEvent, InputHTMLAttributes, RefObject } from 'react';
3
- import { M as MenuItem, a as MenuConfig } from './menu-GmSRfRGB.js';
4
- import { M as META_THEME_COLORS } from './colors-CUDWvz1g.js';
5
- import { Toast } from '@base-ui-components/react/toast';
6
-
7
- /**
8
- * Analytics tracking hook for React components
9
- * Provides utilities for tracking CRUD operations and user interactions
10
- * with Google Analytics integration
11
- */
12
- /**
13
- * Type definition for window with Google Analytics gtag function
14
- * This extends the Window interface to include the gtag function
15
- * that's injected by the Google Analytics script
16
- * This implementation matches the global declaration in analytics.ts
17
- */
18
- interface GtagWindow extends Window {
19
- gtag?: (command: 'event' | 'config' | 'set', targetId: string, config?: Record<string, string | number | boolean | object | null | undefined>) => void;
20
- }
21
- /**
22
- * Main application modules for analytics tracking
23
- * Comprehensive SaaS platform modules
24
- */
25
- type ModuleType = 'workspace' | 'user' | 'billing' | 'analytics' | 'integration' | 'content' | 'communication' | 'system' | 'security' | 'automation' | 'ecommerce';
26
- /**
27
- * Workspace module specific submodules
28
- * Core workspace management functionality
29
- */
30
- type WorkspaceSubModuleType = 'workspaces' | 'projects' | 'teams' | 'collaboration' | 'templates' | 'workflows' | 'dashboard' | 'kanban' | 'calendar' | 'files';
31
- /**
32
- * User module specific submodules
33
- * User management and authentication
34
- */
35
- type UserSubModuleType = 'users' | 'profiles' | 'roles' | 'permissions' | 'groups' | 'invitations' | 'authentication' | 'sessions' | 'preferences' | 'activity';
36
- /**
37
- * Billing module specific submodules
38
- * Subscription and payment management
39
- */
40
- type BillingSubModuleType = 'subscriptions' | 'plans' | 'invoices' | 'payments' | 'credits' | 'usage' | 'discounts' | 'taxes' | 'refunds' | 'billing_history';
41
- /**
42
- * Analytics module specific submodules
43
- * Data analytics and reporting
44
- */
45
- type AnalyticsSubModuleType = 'reports' | 'dashboards' | 'metrics' | 'events' | 'funnels' | 'cohorts' | 'segments' | 'exports' | 'real_time' | 'custom_reports';
46
- /**
47
- * Integration module specific submodules
48
- * Third-party integrations and APIs
49
- */
50
- type IntegrationSubModuleType = 'api_keys' | 'webhooks' | 'oauth' | 'connectors' | 'sync' | 'imports' | 'exports' | 'marketplace' | 'custom_integrations' | 'rate_limits';
51
- /**
52
- * Content module specific submodules
53
- * Content management and media
54
- */
55
- type ContentSubModuleType = 'documents' | 'media' | 'assets' | 'libraries' | 'versions' | 'comments' | 'reviews' | 'publishing' | 'cdn' | 'storage';
56
- /**
57
- * Communication module specific submodules
58
- * Messaging and notification systems
59
- */
60
- type CommunicationSubModuleType = 'notifications' | 'emails' | 'sms' | 'chat' | 'announcements' | 'broadcasts' | 'templates' | 'campaigns' | 'channels' | 'delivery';
61
- /**
62
- * System module specific submodules
63
- * System administration and maintenance
64
- */
65
- type SystemSubModuleType = 'settings' | 'configurations' | 'logs' | 'monitoring' | 'backups' | 'maintenance' | 'health_checks' | 'performance' | 'database' | 'cache';
66
- /**
67
- * Security module specific submodules
68
- * Security and compliance features
69
- */
70
- type SecuritySubModuleType = 'audit_logs' | 'access_control' | 'encryption' | 'compliance' | 'threats' | 'vulnerabilities' | 'certificates' | 'firewall' | 'monitoring' | 'incidents';
71
- /**
72
- * Automation module specific submodules
73
- * Workflow automation and triggers
74
- */
75
- type AutomationSubModuleType = 'workflows' | 'triggers' | 'actions' | 'conditions' | 'schedules' | 'pipelines' | 'bots' | 'scripts' | 'rules' | 'execution_logs';
76
- /**
77
- * E-commerce module specific submodules
78
- * Online store and transaction management
79
- */
80
- type EcommerceSubModuleType = 'products' | 'categories' | 'inventory' | 'orders' | 'customers' | 'payments' | 'shipping' | 'discounts' | 'reviews' | 'analytics';
81
- /**
82
- * Union type of all possible submodules
83
- * Combines all module-specific submodule types for comprehensive tracking
84
- */
85
- type SubModuleType = WorkspaceSubModuleType | UserSubModuleType | BillingSubModuleType | AnalyticsSubModuleType | IntegrationSubModuleType | ContentSubModuleType | CommunicationSubModuleType | SystemSubModuleType | SecuritySubModuleType | AutomationSubModuleType | EcommerceSubModuleType;
86
- /**
87
- * Hook for tracking analytics events in React components
88
- *
89
- * This hook provides methods for tracking CRUD operations
90
- * with proper typing and structure for Google Analytics.
91
- *
92
- * @returns Object containing tracking methods for different CRUD operations
93
- *
94
- * @example
95
- * ```tsx
96
- * // Workspace management tracking
97
- * function WorkspaceManagement() {
98
- * const { trackCreate, trackUpdate, trackDelete, trackView } = useAnalytics();
99
- *
100
- * const handleCreateWorkspace = async (workspaceData) => {
101
- * const workspace = await createWorkspace(workspaceData);
102
- * trackCreate('workspace', 'workspaces', 'workspace', workspace.id);
103
- * };
104
- *
105
- * const handleViewProject = (projectId) => {
106
- * trackView('workspace', 'projects', 'project', projectId);
107
- * };
108
- *
109
- * return <WorkspaceForm onSubmit={handleCreateWorkspace} />;
110
- * }
111
- *
112
- * // Billing and subscription tracking
113
- * function BillingDashboard() {
114
- * const { trackUpdate, trackView } = useAnalytics();
115
- *
116
- * const handleUpgradePlan = async (planId) => {
117
- * await upgradePlan(planId);
118
- * trackUpdate('billing', 'subscriptions', 'plan', planId);
119
- * };
120
- *
121
- * const handleViewInvoice = (invoiceId) => {
122
- * trackView('billing', 'invoices', 'invoice', invoiceId);
123
- * };
124
- *
125
- * return <BillingInterface onUpgrade={handleUpgradePlan} />;
126
- * }
127
- *
128
- * // User management tracking
129
- * function UserManagement() {
130
- * const { trackCreate, trackUpdate } = useAnalytics();
131
- *
132
- * const handleInviteUser = async (email, role) => {
133
- * const invitation = await inviteUser(email, role);
134
- * trackCreate('user', 'invitations', 'invitation', invitation.id);
135
- * };
136
- *
137
- * const handleUpdatePermissions = async (userId, permissions) => {
138
- * await updateUserPermissions(userId, permissions);
139
- * trackUpdate('user', 'permissions', 'permission', userId);
140
- * };
141
- *
142
- * return <UserInviteForm onInvite={handleInviteUser} />;
143
- * }
144
- *
145
- * // Integration and automation tracking
146
- * function IntegrationSettings() {
147
- * const { trackCreate, trackUpdate } = useAnalytics();
148
- *
149
- * const handleCreateWebhook = async (webhookData) => {
150
- * const webhook = await createWebhook(webhookData);
151
- * trackCreate('integration', 'webhooks', 'webhook', webhook.id);
152
- * };
153
- *
154
- * const handleUpdateWorkflow = async (workflowId, updates) => {
155
- * await updateWorkflow(workflowId, updates);
156
- * trackUpdate('automation', 'workflows', 'workflow', workflowId);
157
- * };
158
- *
159
- * return <IntegrationPanel onCreate={handleCreateWebhook} />;
160
- * }
161
- * ```
162
- */
163
- declare const useAnalytics: () => {
164
- trackCreate: (module: ModuleType, submodule: SubModuleType, itemType: string, itemId?: string) => void;
165
- trackUpdate: (module: ModuleType, submodule: SubModuleType, itemType: string, itemId: string) => void;
166
- trackDelete: (module: ModuleType, submodule: SubModuleType, itemType: string, itemId: string, isHardDelete?: boolean) => void;
167
- };
168
-
169
- /**
170
- * Body class management hook for React components
171
- * Dynamically adds and removes CSS classes from the document body element
172
- * Useful for global styling based on component state or route changes
173
- */
174
- /**
175
- * Hook to dynamically add and remove CSS classes from the document body
176
- *
177
- * This hook automatically manages the lifecycle of body classes:
178
- * - Adds classes when the component mounts
179
- * - Removes classes when the component unmounts
180
- * - Updates classes when the className prop changes
181
- *
182
- * @param className - Space-separated string of CSS class names to apply to body
183
- *
184
- * @example
185
- * ```tsx
186
- * // Single class
187
- * useBodyClasses('dark-theme');
188
- *
189
- * // Multiple classes
190
- * useBodyClasses('modal-open overflow-hidden');
191
- *
192
- * // Conditional classes
193
- * useBodyClasses(isModalOpen ? 'modal-open' : '');
194
- * ```
195
- */
196
- declare const useBodyClasses: (className: string) => void;
197
-
198
- /**
199
- * Clipboard copy functionality hook for React components
200
- * Provides a simple interface for copying text to clipboard with feedback
201
- * Includes automatic state management and timeout handling
202
- */
203
- /**
204
- * Configuration options for the copy to clipboard hook
205
- */
206
- interface UseCopyToClipboardOptions {
207
- /** Duration in milliseconds to show the copied state (default: 2000ms) */
208
- timeout?: number;
209
- /** Callback function executed after successful copy operation */
210
- onCopy?: () => void;
211
- }
212
- /**
213
- * Hook for copying text to clipboard with automatic state management
214
- *
215
- * Features:
216
- * - Automatic copied state management with timeout
217
- * - Browser compatibility checks
218
- * - Error handling for failed copy operations
219
- * - Optional callback for successful copies
220
- *
221
- * @param options - Configuration options for the hook
222
- * @returns Object containing copied state and copy function
223
- *
224
- * @example
225
- * ```tsx
226
- * const { copied, copy } = useCopyToClipboard({
227
- * timeout: 3000,
228
- * onCopy: () => toast.success('Copied to clipboard!')
229
- * });
230
- *
231
- * return (
232
- * <button onClick={() => copy('Hello World')}>
233
- * {copied ? 'Copied!' : 'Copy Text'}
234
- * </button>
235
- * );
236
- * ```
237
- */
238
- declare function useCopyToClipboard({ timeout, onCopy }?: UseCopyToClipboardOptions): {
239
- /** Whether text was recently copied (true for timeout duration) */
240
- copied: boolean;
241
- /** Function to copy text to clipboard */
242
- copy: (value: string) => void;
243
- };
244
-
245
- /**
246
- * File upload functionality hook for React components
247
- * Provides comprehensive file upload capabilities with drag & drop support
248
- * Includes validation, preview generation, and state management
249
- */
250
-
251
- /**
252
- * Metadata structure for uploaded files
253
- */
254
- type FileMetadata = {
255
- /** The name of the file */
256
- name: string;
257
- /** The size of the file in bytes */
258
- size: number;
259
- /** The MIME type of the file */
260
- type: string;
261
- /** The URL where the file can be accessed */
262
- url: string;
263
- /** Unique identifier for the file */
264
- id: string;
265
- };
266
- /**
267
- * File object with preview capabilities
268
- */
269
- type FileWithPreview = {
270
- /** The actual file object or metadata */
271
- file: File | FileMetadata;
272
- /** Unique identifier for the file */
273
- id: string;
274
- /** Optional preview URL for the file (typically for images) */
275
- preview?: string;
276
- };
277
- /**
278
- * Configuration options for the file upload hook
279
- */
280
- type FileUploadOptions = {
281
- /** Maximum number of files allowed (only used when multiple is true, defaults to Infinity) */
282
- maxFiles?: number;
283
- /** Maximum file size in bytes (defaults to Infinity) */
284
- maxSize?: number;
285
- /** Accepted file types (MIME types or extensions, defaults to '*') */
286
- accept?: string;
287
- /** Whether multiple files can be selected (defaults to false) */
288
- multiple?: boolean;
289
- /** Initial files to populate the upload state */
290
- initialFiles?: FileMetadata[];
291
- /** Callback function executed when files change */
292
- onFilesChange?: (files: FileWithPreview[]) => void;
293
- /** Callback function executed when new files are added */
294
- onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
295
- onError?: (errors: string[]) => void;
296
- };
297
- /**
298
- * Current state of the file upload component
299
- */
300
- type FileUploadState = {
301
- /** Array of files currently selected/uploaded */
302
- files: FileWithPreview[];
303
- /** Whether the user is currently dragging files over the drop zone */
304
- isDragging: boolean;
305
- /** Array of validation error messages */
306
- errors: string[];
307
- };
308
- /**
309
- * Actions available for file upload management
310
- */
311
- type FileUploadActions = {
312
- /** Add new files to the upload state */
313
- addFiles: (files: FileList | File[]) => void;
314
- /** Remove a specific file by its ID */
315
- removeFile: (id: string) => void;
316
- /** Clear all files from the upload state */
317
- clearFiles: () => void;
318
- /** Clear all error messages */
319
- clearErrors: () => void;
320
- /** Handle drag enter event for drop zone */
321
- handleDragEnter: (e: DragEvent<HTMLElement>) => void;
322
- /** Handle drag leave event for drop zone */
323
- handleDragLeave: (e: DragEvent<HTMLElement>) => void;
324
- /** Handle drag over event for drop zone */
325
- handleDragOver: (e: DragEvent<HTMLElement>) => void;
326
- /** Handle drop event for drop zone */
327
- handleDrop: (e: DragEvent<HTMLElement>) => void;
328
- /** Handle file input change event */
329
- handleFileChange: (e: ChangeEvent<HTMLInputElement>) => void;
330
- /** Programmatically open the file dialog */
331
- openFileDialog: () => void;
332
- /** Get props for the file input element */
333
- getInputProps: (props?: InputHTMLAttributes<HTMLInputElement>) => InputHTMLAttributes<HTMLInputElement> & {
334
- ref: React__default.Ref<HTMLInputElement>;
335
- };
336
- };
337
- /**
338
- * Hook for comprehensive file upload functionality with drag & drop support
339
- *
340
- * Features:
341
- * - Single and multiple file upload support
342
- * - Drag and drop functionality
343
- * - File validation (size, type, count)
344
- * - Preview generation for images
345
- * - Error handling and state management
346
- * - Duplicate file detection
347
- * - Memory cleanup for object URLs
348
- *
349
- * @param options - Configuration options for the file upload hook
350
- * @returns Tuple containing current state and available actions
351
- *
352
- * @example
353
- * ```tsx
354
- * const [state, actions] = useFileUpload({
355
- * maxFiles: 5,
356
- * maxSize: 10 * 1024 * 1024, // 10MB
357
- * accept: 'image/*',
358
- * multiple: true,
359
- * onFilesChange: (files) => console.log('Files changed:', files),
360
- * onFilesAdded: (newFiles) => console.log('New files added:', newFiles)
361
- * });
362
- *
363
- * return (
364
- * <div
365
- * onDragEnter={actions.handleDragEnter}
366
- * onDragLeave={actions.handleDragLeave}
367
- * onDragOver={actions.handleDragOver}
368
- * onDrop={actions.handleDrop}
369
- * >
370
- * <input {...actions.getInputProps()} />
371
- * <button onClick={actions.openFileDialog}>
372
- * Upload Files
373
- * </button>
374
- * {state.files.map(file => (
375
- * <div key={file.id}>
376
- * {file.file.name}
377
- * <button onClick={() => actions.removeFile(file.id)}>
378
- * Remove
379
- * </button>
380
- * </div>
381
- * ))}
382
- * </div>
383
- * );
384
- * ```
385
- */
386
- declare const useFileUpload: (options?: FileUploadOptions) => [FileUploadState, FileUploadActions];
387
- /**
388
- * Helper function to format bytes to human-readable format
389
- *
390
- * @param bytes - The number of bytes to format
391
- * @param decimals - Number of decimal places to show (default: 2)
392
- * @returns Formatted string with appropriate unit (e.g., "1.5 MB")
393
- *
394
- * @example
395
- * ```tsx
396
- * formatBytes(1024); // "1 KB"
397
- * formatBytes(1536, 1); // "1.5 KB"
398
- * formatBytes(1048576); // "1 MB"
399
- * ```
400
- */
401
- declare const formatBytes: (bytes: number, decimals?: number) => string;
402
-
403
- /**
404
- * Media query hook for responsive React components
405
- * Provides real-time tracking of CSS media query matches
406
- * with SSR-safe implementation and automatic cleanup
407
- */
408
- /**
409
- * Hook for tracking CSS media query matches in React components
410
- *
411
- * Features:
412
- * - Real-time updates when media query state changes
413
- * - SSR-safe implementation
414
- * - Automatic event listener cleanup
415
- * - Supports all standard CSS media queries
416
- *
417
- * @param query - CSS media query string (e.g., '(min-width: 768px)')
418
- * @returns Boolean indicating whether the media query currently matches
419
- *
420
- * @example
421
- * ```tsx
422
- * // Basic responsive behavior
423
- * const isMobile = useMediaQuery('(max-width: 768px)');
424
- * const isTablet = useMediaQuery('(min-width: 769px) and (max-width: 1024px)');
425
- * const isDesktop = useMediaQuery('(min-width: 1025px)');
426
- *
427
- * // Dark mode preference
428
- * const prefersDark = useMediaQuery('(prefers-color-scheme: dark)');
429
- *
430
- * // Reduced motion preference
431
- * const prefersReducedMotion = useMediaQuery('(prefers-reduced-motion: reduce)');
432
- *
433
- * return (
434
- * <div>
435
- * {isMobile && <MobileLayout />}
436
- * {isTablet && <TabletLayout />}
437
- * {isDesktop && <DesktopLayout />}
438
- * </div>
439
- * );
440
- * ```
441
- */
442
- declare const useMediaQuery: (query: string) => boolean;
443
-
444
- /**
445
- * Menu navigation utilities hook for dashboard layouts
446
- * Provides comprehensive menu state management and navigation helpers
447
- * Handles active states, breadcrumbs, and hierarchical menu structures
448
- */
449
-
450
- /** Return type interface for useMenu hook */
451
- interface UseMenuReturn {
452
- /** Check if a specific path is currently active */
453
- isActive: (path: string | undefined) => boolean;
454
- /** Check if any child menu item is currently active */
455
- hasActiveChild: (children: MenuItem[] | undefined) => boolean;
456
- /** Check if a menu item (including its children) is currently active */
457
- isItemActive: (item: MenuItem) => boolean;
458
- /** Get the currently active menu item from the menu configuration */
459
- getCurrentItem: (items: MenuConfig) => MenuItem | undefined;
460
- /** Generate breadcrumb trail for the current active path */
461
- getBreadcrumb: (items: MenuConfig) => MenuItem[];
462
- /** Get child menu items at a specific level for the current active path */
463
- getChildren: (items: MenuConfig, level: number) => MenuConfig | null;
464
- }
465
- /**
466
- * Hook for managing menu navigation state and utilities
467
- *
468
- * This hook provides comprehensive menu management functionality including:
469
- * - Active state detection for menu items and paths
470
- * - Hierarchical menu navigation support
471
- * - Breadcrumb generation for current navigation path
472
- * - Child menu extraction at specific levels
473
- * - Support for nested menu structures
474
- *
475
- * @param pathname - Current pathname from router or location
476
- * @returns Object containing menu utility functions
477
- *
478
- * @example
479
- * ```tsx
480
- * const { isActive, getBreadcrumb, getCurrentItem } = useMenu(pathname);
481
- *
482
- * // Check if path is active
483
- * const isHomeActive = isActive('/dashboard');
484
- *
485
- * // Get breadcrumb for current path
486
- * const breadcrumb = getBreadcrumb(menuItems);
487
- *
488
- * // Get current active menu item
489
- * const currentItem = getCurrentItem(menuItems);
490
- * ```
491
- */
492
- declare const useMenu: (pathname: string) => UseMenuReturn;
1
+ export * from '@pelatform/ui.hook';
2
+ import { META_THEME_COLORS } from '@pelatform/ui.core';
493
3
 
494
4
  /**
495
5
  * Meta theme color management hook for React components
@@ -575,602 +85,9 @@ declare const useMenu: (pathname: string) => UseMenuReturn;
575
85
  */
576
86
  declare function useMetaColor(defaultColors?: typeof META_THEME_COLORS): {
577
87
  /** Current meta theme color based on resolved theme */
578
- metaColor: "#ffffff" | "#09090b";
88
+ metaColor: "#09090b" | "#ffffff";
579
89
  /** Function to manually set meta theme color */
580
90
  setMetaColor: (color: string) => void;
581
91
  };
582
92
 
583
- /**
584
- * Mobile device detection hook for React components
585
- * Provides real-time mobile/desktop state based on configurable viewport width breakpoint
586
- * Uses customizable mobile breakpoint with proper SSR handling and hydration safety
587
- */
588
- /**
589
- * Hook to detect if the current viewport is mobile-sized based on configurable breakpoint
590
- *
591
- * This hook provides real-time detection of mobile vs desktop viewports with a customizable
592
- * breakpoint threshold. It handles SSR properly by starting with undefined state and updating
593
- * on client-side hydration to prevent hydration mismatches.
594
- *
595
- * The hook uses both `matchMedia` API for efficient media query listening and `window.innerWidth`
596
- * for consistent viewport width detection across different browsers and devices.
597
- *
598
- * Features:
599
- * - Real-time viewport size tracking with media query listeners
600
- * - SSR-safe implementation preventing hydration mismatches
601
- * - Automatic event listener cleanup on unmount
602
- * - Configurable mobile breakpoint with sensible default (1024px)
603
- * - Performance optimized with proper dependency management
604
- * - TypeScript support with proper type definitions
605
- *
606
- * @param breakpoint - Custom breakpoint in pixels. Viewports smaller than this value are considered mobile. Defaults to 1024px if not provided.
607
- * @returns Boolean indicating if current viewport width is smaller than the specified breakpoint (mobile-sized)
608
- *
609
- * @example
610
- * ```tsx
611
- * // Basic usage with default breakpoint (1024px)
612
- * function ResponsiveComponent() {
613
- * const isMobile = useIsMobile();
614
- *
615
- * return (
616
- * <div>
617
- * {isMobile ? (
618
- * <MobileNavigation />
619
- * ) : (
620
- * <DesktopNavigation />
621
- * )}
622
- * </div>
623
- * );
624
- * }
625
- *
626
- * // Custom breakpoint for tablet detection
627
- * function TabletResponsiveComponent() {
628
- * const isMobile = useIsMobile(768); // Use 768px breakpoint
629
- * const isTablet = useIsMobile(1024); // Use 1024px for tablet detection
630
- *
631
- * return (
632
- * <div className={isMobile ? 'mobile-layout' : isTablet ? 'tablet-layout' : 'desktop-layout'}>
633
- * <Content />
634
- * </div>
635
- * );
636
- * }
637
- *
638
- * // Conditional rendering with custom breakpoint
639
- * function AdaptiveLayout() {
640
- * const isSmallScreen = useIsMobile(640); // Custom small screen breakpoint
641
- *
642
- * return (
643
- * <div className="container">
644
- * {isSmallScreen ? (
645
- * <div className="flex flex-col space-y-4">
646
- * <MobileHeader />
647
- * <MobileContent />
648
- * </div>
649
- * ) : (
650
- * <div className="grid grid-cols-12 gap-6">
651
- * <aside className="col-span-3">
652
- * <Sidebar />
653
- * </aside>
654
- * <main className="col-span-9">
655
- * <DesktopContent />
656
- * </main>
657
- * </div>
658
- * )}
659
- * </div>
660
- * );
661
- * }
662
- *
663
- * // Multiple breakpoints for different layouts
664
- * function MultiBreakpointLayout() {
665
- * const isMobile = useIsMobile(640); // Mobile: < 640px
666
- * const isTablet = useIsMobile(1024); // Tablet: < 1024px
667
- * const isDesktop = !isTablet; // Desktop: >= 1024px
668
- *
669
- * if (isMobile) {
670
- * return <MobileLayout />;
671
- * }
672
- *
673
- * if (isTablet) {
674
- * return <TabletLayout />;
675
- * }
676
- *
677
- * return <DesktopLayout />;
678
- * }
679
- * ```
680
- *
681
- * @since 1.0.0
682
- */
683
- declare function useIsMobile(breakpoint?: number): boolean;
684
-
685
- /**
686
- * Component mount state hook for React components
687
- * Provides a reliable way to detect when a component has mounted on the client
688
- * Essential for SSR applications to prevent hydration mismatches
689
- */
690
- /**
691
- * Hook to detect when a React component has mounted on the client side
692
- *
693
- * This hook is essential for SSR applications where you need to conditionally
694
- * render content only after the component has mounted on the client. It helps
695
- * prevent hydration mismatches between server and client rendering.
696
- *
697
- * Features:
698
- * - Starts with false during SSR
699
- * - Updates to true after client-side mount
700
- * - Prevents hydration mismatches
701
- * - Simple boolean state management
702
- *
703
- * @returns Boolean indicating whether the component has mounted
704
- *
705
- * @example
706
- * ```tsx
707
- * function ClientOnlyComponent() {
708
- * const mounted = useMounted();
709
- *
710
- * // Prevent rendering until mounted to avoid hydration issues
711
- * if (!mounted) {
712
- * return <div>Loading...</div>;
713
- * }
714
- *
715
- * return (
716
- * <div>
717
- * <BrowserOnlyFeature />
718
- * <LocalStorageComponent />
719
- * </div>
720
- * );
721
- * }
722
- *
723
- * // Conditional rendering based on mount state
724
- * function ThemeToggle() {
725
- * const mounted = useMounted();
726
- * const { theme, setTheme } = useTheme();
727
- *
728
- * // Avoid showing theme toggle until mounted
729
- * if (!mounted) return null;
730
- *
731
- * return (
732
- * <button onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}>
733
- * Toggle Theme
734
- * </button>
735
- * );
736
- * }
737
- * ```
738
- */
739
- declare function useMounted(): boolean;
740
-
741
- /**
742
- * DOM Mutation Observer hook for React components
743
- * Provides a React-friendly interface for observing DOM changes
744
- * with automatic cleanup and ref integration
745
- */
746
-
747
- /**
748
- * Hook to observe DOM mutations on a referenced element
749
- *
750
- * This hook provides a React-friendly way to use the MutationObserver API.
751
- * It automatically handles observer creation, cleanup, and ref management.
752
- * Useful for detecting DOM changes that occur outside of React's control.
753
- *
754
- * Features:
755
- * - Automatic observer lifecycle management
756
- * - Configurable observation options
757
- * - Ref-based element targeting
758
- * - Automatic cleanup on unmount
759
- *
760
- * @param ref - React ref pointing to the element to observe
761
- * @param callback - Function called when mutations are detected
762
- * @param options - MutationObserver configuration options
763
- *
764
- * @example
765
- * ```tsx
766
- * function DynamicContent() {
767
- * const contentRef = useRef<HTMLDivElement>(null);
768
- *
769
- * // Watch for any changes to the content div
770
- * useMutationObserver(
771
- * contentRef,
772
- * (mutations) => {
773
- * mutations.forEach((mutation) => {
774
- * console.log('DOM changed:', mutation.type);
775
- * });
776
- * }
777
- * );
778
- *
779
- * return <div ref={contentRef}>Dynamic content here</div>;
780
- * }
781
- *
782
- * // Watch only for attribute changes
783
- * function AttributeWatcher() {
784
- * const elementRef = useRef<HTMLElement>(null);
785
- *
786
- * useMutationObserver(
787
- * elementRef,
788
- * (mutations) => {
789
- * mutations.forEach((mutation) => {
790
- * if (mutation.type === 'attributes') {
791
- * console.log('Attribute changed:', mutation.attributeName);
792
- * }
793
- * });
794
- * },
795
- * { attributes: true, childList: false, subtree: false }
796
- * );
797
- *
798
- * return <div ref={elementRef}>Watched element</div>;
799
- * }
800
- * ```
801
- */
802
- declare const useMutationObserver: (ref: React.RefObject<HTMLElement | null>, callback: MutationCallback, options?: MutationObserverInit) => void;
803
-
804
- /**
805
- * Google reCAPTCHA v2 integration hook for React components
806
- * Provides a complete solution for implementing reCAPTCHA v2 with automatic
807
- * script loading, widget management, and token retrieval
808
- */
809
- /**
810
- * Hook for integrating Google reCAPTCHA v2 into React components
811
- *
812
- * This hook provides a complete solution for reCAPTCHA v2 integration including:
813
- * - Automatic script loading and initialization
814
- * - Widget rendering and management
815
- * - Token retrieval and validation
816
- * - Cleanup and reset functionality
817
- *
818
- * @param siteKey - Your Google reCAPTCHA site key
819
- * @returns Object containing ref, token getter, reset function, and initializer
820
- *
821
- * @example
822
- * ```tsx
823
- * function ContactForm() {
824
- * const { containerRef, getToken, resetCaptcha } = useRecaptchaV2('your-site-key');
825
- *
826
- * const handleSubmit = async (e) => {
827
- * e.preventDefault();
828
- *
829
- * try {
830
- * const token = getToken();
831
- * if (!token) {
832
- * alert('Please complete the reCAPTCHA');
833
- * return;
834
- * }
835
- *
836
- * // Submit form with token
837
- * await submitForm({ token, ...formData });
838
- * resetCaptcha(); // Reset after successful submission
839
- * } catch (error) {
840
- * console.error('Submission failed:', error);
841
- * }
842
- * };
843
- *
844
- * return (
845
- * <form onSubmit={handleSubmit}>
846
- * <input type="email" placeholder="Email" />
847
- * <div ref={containerRef}></div>
848
- * <button type="submit">Submit</button>
849
- * </form>
850
- * );
851
- * }
852
- * ```
853
- */
854
- declare function useRecaptchaV2(siteKey: string): {
855
- /** Ref to attach to the container div where reCAPTCHA will be rendered */
856
- containerRef: React.RefObject<HTMLDivElement | null>;
857
- /** Function to get the reCAPTCHA response token */
858
- getToken: () => string;
859
- /** Function to reset the reCAPTCHA widget */
860
- resetCaptcha: () => void;
861
- /** Function to manually initialize reCAPTCHA (usually not needed) */
862
- initializeRecaptcha: () => Promise<void>;
863
- };
864
-
865
- /**
866
- * Google Analytics linker parameter cleanup hook for React
867
- * Safely removes the GA `_gl` query parameter from the URL after GA initialization.
868
- */
869
- /**
870
- * Hook to remove the Google Analytics `_gl` query parameter from the current URL.
871
- *
872
- * GA's cross-domain linker temporarily appends `_gl` to URLs for attribution.
873
- * Removing it *too early* can break attribution, so this hook waits briefly
874
- * (≈2 seconds) to allow GA to read it, then strips the param using
875
- * `history.replaceState` without causing a page reload or React re-render.
876
- *
877
- * Behavior:
878
- * - Runs once on mount.
879
- * - If `_gl` is present, schedules its removal after ~2000ms.
880
- * - Uses `window.history.replaceState` to avoid navigation/re-render.
881
- *
882
- * @example
883
- * ```tsx
884
- * // app/layout.tsx or a top-level client component
885
- * import { useRemoveGAParams } from '@/hooks/use-remove-ga-params';
886
- *
887
- * export default function RootLayout({ children }: { children: React.ReactNode }) {
888
- * useRemoveGAParams();
889
- * return <>{children}</>;
890
- * }
891
- * ```
892
- */
893
- declare function useRemoveGAParams(): void;
894
-
895
- /**
896
- * Scroll position tracking hook for React components
897
- * Monitors scroll position of window or specific elements
898
- * with real-time updates and automatic cleanup
899
- */
900
-
901
- /**
902
- * Configuration options for the scroll position hook
903
- */
904
- interface UseScrollPositionProps {
905
- /** Optional ref to a specific scrollable element (defaults to document) */
906
- targetRef?: RefObject<HTMLElement | Document | undefined>;
907
- }
908
- /**
909
- * Hook to track scroll position of window or specific elements
910
- *
911
- * This hook provides real-time tracking of scroll position with support
912
- * for both window scrolling and element-specific scrolling. It automatically
913
- * handles event listener management and cleanup.
914
- *
915
- * Features:
916
- * - Real-time scroll position tracking
917
- * - Support for window and element scrolling
918
- * - Automatic event listener cleanup
919
- * - SSR-safe implementation
920
- * - Performance optimized
921
- *
922
- * @param options - Configuration options for the hook
923
- * @returns Current scroll position in pixels
924
- *
925
- * @example
926
- * ```tsx
927
- * // Track window scroll position
928
- * function ScrollIndicator() {
929
- * const scrollPosition = useScrollPosition();
930
- *
931
- * return (
932
- * <div className="scroll-indicator">
933
- * Scrolled: {scrollPosition}px
934
- * </div>
935
- * );
936
- * }
937
- *
938
- * // Track specific element scroll position
939
- * function ScrollableContent() {
940
- * const contentRef = useRef<HTMLDivElement>(null);
941
- * const scrollPosition = useScrollPosition({ targetRef: contentRef });
942
- *
943
- * return (
944
- * <div
945
- * ref={contentRef}
946
- * className="h-96 overflow-y-auto"
947
- * >
948
- * <div className="h-[1000px]">
949
- * <p>Scroll position: {scrollPosition}px</p>
950
- * <p>Long content here...</p>
951
- * </div>
952
- * </div>
953
- * );
954
- * }
955
- *
956
- * // Show/hide header based on scroll
957
- * function StickyHeader() {
958
- * const scrollPosition = useScrollPosition();
959
- * const isVisible = scrollPosition < 100;
960
- *
961
- * return (
962
- * <header className={`transition-transform ${
963
- * isVisible ? 'translate-y-0' : '-translate-y-full'
964
- * }`}>
965
- * Header content
966
- * </header>
967
- * );
968
- * }
969
- * ```
970
- */
971
- declare const useScrollPosition: ({ targetRef }?: UseScrollPositionProps) => number;
972
-
973
- /**
974
- * Dual slider input management hook for React components
975
- * Provides synchronized state management between range slider and number inputs
976
- * with validation and boundary enforcement
977
- */
978
-
979
- /**
980
- * Configuration options for the slider input hook
981
- */
982
- interface UseSliderInputProps {
983
- /** Minimum allowed value for the range */
984
- minValue: number;
985
- /** Maximum allowed value for the range */
986
- maxValue: number;
987
- /** Initial values for the range [min, max] */
988
- initialValue: [number, number];
989
- }
990
- /**
991
- * Hook for managing dual slider input with synchronized state
992
- *
993
- * This hook provides state management for components that need both
994
- * a range slider and corresponding number inputs. It handles synchronization
995
- * between the two input types, validation, and boundary enforcement.
996
- *
997
- * Features:
998
- * - Synchronized slider and input values
999
- * - Automatic validation and boundary enforcement
1000
- * - Prevents invalid range configurations (min > max)
1001
- * - Optimized with useCallback for performance
1002
- *
1003
- * @param props - Configuration options for the hook
1004
- * @returns Object containing state and handlers for slider and inputs
1005
- *
1006
- * @example
1007
- * ```tsx
1008
- * function PriceRangeFilter() {
1009
- * const {
1010
- * sliderValues,
1011
- * inputValues,
1012
- * handleSliderChange,
1013
- * handleInputChange,
1014
- * validateAndUpdateValue
1015
- * } = useSliderInput({
1016
- * minValue: 0,
1017
- * maxValue: 1000,
1018
- * initialValue: [100, 500]
1019
- * });
1020
- *
1021
- * return (
1022
- * <div className="price-range">
1023
- * <div className="inputs">
1024
- * <input
1025
- * type="number"
1026
- * value={inputValues[0]}
1027
- * onChange={(e) => handleInputChange(e, 0)}
1028
- * onBlur={() => validateAndUpdateValue(inputValues[0], 0)}
1029
- * placeholder="Min price"
1030
- * />
1031
- * <input
1032
- * type="number"
1033
- * value={inputValues[1]}
1034
- * onChange={(e) => handleInputChange(e, 1)}
1035
- * onBlur={() => validateAndUpdateValue(inputValues[1], 1)}
1036
- * placeholder="Max price"
1037
- * />
1038
- * </div>
1039
- *
1040
- * <Slider
1041
- * value={sliderValues}
1042
- * onValueChange={handleSliderChange}
1043
- * min={0}
1044
- * max={1000}
1045
- * step={10}
1046
- * />
1047
- * </div>
1048
- * );
1049
- * }
1050
- * ```
1051
- */
1052
- declare function useSliderInput({ minValue, maxValue, initialValue }: UseSliderInputProps): {
1053
- /** Function to manually set slider values */
1054
- setSliderValues: React.Dispatch<React.SetStateAction<[number, number]>>;
1055
- /** Function to manually set input values */
1056
- setInputValues: React.Dispatch<React.SetStateAction<[number, number]>>;
1057
- /** Current slider values [min, max] */
1058
- sliderValues: [number, number];
1059
- /** Current input values [min, max] */
1060
- inputValues: [number, number];
1061
- /** Handler for slider value changes */
1062
- handleSliderChange: (values: [number, number]) => void;
1063
- /** Handler for input field changes */
1064
- handleInputChange: (e: React.ChangeEvent<HTMLInputElement>, index: 0 | 1) => void;
1065
- /** Function to validate and update values from inputs */
1066
- validateAndUpdateValue: (value: number, index: 0 | 1) => void;
1067
- };
1068
-
1069
- /**
1070
- * Toast notification hook and manager for React components
1071
- * Provides a simple API to trigger and manage toast messages across the app
1072
- */
1073
-
1074
- /**
1075
- * Global toast manager instance
1076
- *
1077
- * Use this manager to imperatively show toasts from anywhere (including non-React code).
1078
- *
1079
- * @example
1080
- * ```tsx
1081
- * // Show a basic toast
1082
- * toastManager.show({ content: 'Saved successfully' });
1083
- *
1084
- * // With additional options (duration, type, etc., depending on the underlying library)
1085
- * toastManager.show({ content: 'Profile updated', duration: 3000 });
1086
- * ```
1087
- */
1088
- declare const toastManager: Toast.createToastManager.ToastManager;
1089
- /**
1090
- * React hook to access the toast manager within components
1091
- *
1092
- * Returns the current toast manager methods bound to React lifecycle.
1093
- * Prefer this inside React components for idiomatic usage, and use `toastManager`
1094
- * for usage outside the React tree.
1095
- *
1096
- * @example
1097
- * ```tsx
1098
- * export function SaveButton() {
1099
- * const toast = useToast();
1100
- * const onClick = () => toast.show({ content: 'Saved!' });
1101
- * return <button onClick={onClick}>Save</button>;
1102
- * }
1103
- * ```
1104
- */
1105
- declare const useToast: typeof Toast.useToastManager;
1106
-
1107
- /**
1108
- * Viewport dimensions tracking hook for React components
1109
- * Provides real-time viewport width and height with automatic updates
1110
- * on window resize events with SSR-safe implementation
1111
- */
1112
- /**
1113
- * Type definition for viewport dimensions
1114
- * Returns tuple of [height, width] in pixels
1115
- */
1116
- type ViewportDimensions = [number, number];
1117
- /**
1118
- * Hook to track viewport dimensions with real-time updates
1119
- *
1120
- * This hook provides the current viewport dimensions and automatically
1121
- * updates when the window is resized. It's useful for responsive layouts,
1122
- * conditional rendering based on screen size, and dynamic calculations.
1123
- *
1124
- * Features:
1125
- * - Real-time viewport dimension tracking
1126
- * - Automatic updates on window resize
1127
- * - Performance optimized with passive event listeners
1128
- * - SSR-safe implementation
1129
- * - Returns both height and width
1130
- *
1131
- * @returns Tuple containing [height, width] in pixels
1132
- *
1133
- * @example
1134
- * ```tsx
1135
- * // Basic usage
1136
- * function ResponsiveComponent() {
1137
- * const [height, width] = useViewport();
1138
- *
1139
- * return (
1140
- * <div>
1141
- * <p>Viewport: {width}x{height}</p>
1142
- * {width > 768 ? <DesktopLayout /> : <MobileLayout />}
1143
- * </div>
1144
- * );
1145
- * }
1146
- *
1147
- * // Destructured usage
1148
- * function ViewportInfo() {
1149
- * const [height, width] = useViewport();
1150
- * const aspectRatio = (width / height).toFixed(2);
1151
- *
1152
- * return (
1153
- * <div className="viewport-info">
1154
- * <p>Width: {width}px</p>
1155
- * <p>Height: {height}px</p>
1156
- * <p>Aspect Ratio: {aspectRatio}</p>
1157
- * </div>
1158
- * );
1159
- * }
1160
- *
1161
- * // Conditional rendering based on viewport
1162
- * function AdaptiveGrid() {
1163
- * const [, width] = useViewport();
1164
- * const columns = width > 1200 ? 4 : width > 768 ? 3 : width > 480 ? 2 : 1;
1165
- *
1166
- * return (
1167
- * <div className={`grid grid-cols-${columns} gap-4`}>
1168
- * {items.map(item => <GridItem key={item.id} {...item} />)}
1169
- * </div>
1170
- * );
1171
- * }
1172
- * ```
1173
- */
1174
- declare const useViewport: () => ViewportDimensions;
1175
-
1176
- export { type FileMetadata, type FileUploadActions, type FileUploadOptions, type FileUploadState, type FileWithPreview, type GtagWindow, formatBytes, toastManager, useAnalytics, useBodyClasses, useCopyToClipboard, useFileUpload, useIsMobile, useMediaQuery, useMenu, useMetaColor, useMounted, useMutationObserver, useRecaptchaV2, useRemoveGAParams, useScrollPosition, useSliderInput, useToast, useViewport };
93
+ export { useMetaColor };