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