@digilogiclabs/saas-factory-ui 1.0.1 → 1.2.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.
package/README.md CHANGED
@@ -1,1004 +1,1072 @@
1
- # @digilogiclabs/saas-factory-ui
2
-
3
- A comprehensive cross-platform UI component library built for both **Next.js web applications** and **React Native/Expo mobile applications**. This package provides a complete set of accessible, mobile-optimized components with consistent design across platforms.
4
-
5
- ## 🌟 Features
6
-
7
- - 🎨 **Cross-Platform Design System**
8
- - Consistent components for web and mobile
9
- - Platform-optimized implementations
10
- - Shared design tokens and theming
11
- - 🌐 **Web Support**
12
- - Built with React, Tailwind CSS, Radix UI, and Framer Motion
13
- - Dark mode support
14
- - Responsive by default
15
- - 📱 **React Native Support**
16
- - Native mobile components with Expo compatibility
17
- - Platform-specific optimizations
18
- - Haptic feedback integration
19
- - ♿️ **Accessibility First**
20
- - WCAG 2.2 AA compliant components
21
- - Screen reader support
22
- - Keyboard navigation and touch alternatives
23
- - ⚡ **Performance Optimized**
24
- - Advanced mobile interactions with gesture recognition
25
- - Lazy loading and progressive image optimization
26
- - Virtual scrolling for large datasets
27
- - Network-aware content delivery
28
- - 🌐 **Offline Support**
29
- - Comprehensive caching strategies
30
- - Offline-first component architecture
31
- - Network detection and graceful degradation
32
- - 🎯 **Developer Experience**
33
- - Full TypeScript support
34
- - Tree-shakeable exports
35
- - Comprehensive documentation
36
- - Optimized bundle sizes
37
-
38
- ## 📦 Installation
39
-
40
- ```bash
41
- npm install @digilogiclabs/saas-factory-ui
42
- ```
43
-
44
- ## 🚀 Platform Requirements
45
-
46
- ### Web Applications
47
- - Node.js >=20.0.0
48
- - Next.js 15+ or React 19+
49
- - Tailwind CSS 3.4 or higher
50
- - TypeScript (recommended)
51
-
52
- ### React Native Applications
53
- - Node.js >=20.0.0
54
- - React Native 0.70 or higher
55
- - Expo SDK 49 or higher
56
- - React 19 or higher
57
-
58
- ## 🌐 Web Setup (Next.js)
59
-
60
- ### 1. Install Dependencies
61
-
62
- ```bash
63
- npm install @digilogiclabs/saas-factory-ui
64
- npm install -D tailwindcss postcss autoprefixer
65
- npx tailwindcss init -p
66
- ```
67
-
68
- ### 2. Configure Tailwind CSS
69
-
70
- Update your `tailwind.config.js` to include the component library:
71
-
72
- ```js
73
- // tailwind.config.js
74
- /** @type {import('tailwindcss').Config} */
75
- export default {
76
- content: [
77
- "./src/**/*.{js,ts,jsx,tsx}",
78
- "./app/**/*.{js,ts,jsx,tsx}",
79
- "./pages/**/*.{js,ts,jsx,tsx}",
80
- "./components/**/*.{js,ts,jsx,tsx}",
81
- // 🚨 IMPORTANT: Include the UI package
82
- "./node_modules/@digilogiclabs/saas-factory-ui/**/*.{js,ts,jsx,tsx}",
83
- ],
84
- theme: {
85
- extend: {},
86
- },
87
- plugins: [],
88
- }
89
- ```
90
-
91
- ### 3. Import Styles (REQUIRED)
92
-
93
- Add the CSS import to your root layout or app file:
94
-
95
- ```tsx
96
- // app/layout.tsx (Next.js 13+) or pages/_app.tsx (Next.js 12)
97
- import '@digilogiclabs/saas-factory-ui/styles.css';
98
- import './globals.css'; // Your app styles
99
- ```
100
-
101
- ### 4. Use Components
102
-
103
- ```tsx
104
- import {
105
- Button,
106
- Card,
107
- Container,
108
- PageTransition,
109
- SwipeableCard,
110
- LazyImage
111
- } from '@digilogiclabs/saas-factory-ui';
112
-
113
- export default function HomePage() {
114
- return (
115
- <PageTransition type="slide" direction="horizontal">
116
- <Container>
117
- <Card className="p-6">
118
- <h1 className="text-2xl font-bold mb-4">Welcome to Web</h1>
119
- <LazyImage
120
- src="/hero-image.jpg"
121
- alt="Hero image"
122
- className="w-full h-64 object-cover rounded-lg mb-4"
123
- placeholder="blur"
124
- webpSupport={true}
125
- />
126
- <Button variant="default" size="lg">
127
- Get Started
128
- </Button>
129
- </Card>
130
- </Container>
131
- </PageTransition>
132
- );
133
- }
134
- ```
135
-
136
- ## 📱 React Native Setup
137
-
138
- ### 1. Install Dependencies
139
-
140
- ```bash
141
- npm install @digilogiclabs/saas-factory-ui
142
- # Required for advanced features
143
- npm install @react-native-community/netinfo
144
- npm install @react-native-async-storage/async-storage
145
- npm install expo-haptics
146
- ```
147
-
148
- ### 2. Import Native Components
149
-
150
- ```tsx
151
- import {
152
- NativeButton,
153
- NativeContainer,
154
- NativeCard,
155
- NativePageTransition,
156
- NativeSwipeableCard,
157
- NativeLazyImage
158
- } from '@digilogiclabs/saas-factory-ui/native';
159
- import { Text } from 'react-native';
160
-
161
- export default function App() {
162
- return (
163
- <NativePageTransition type="slide" direction="horizontal">
164
- <NativeContainer style={{ flex: 1, padding: 20 }}>
165
- <NativeCard style={{ padding: 20 }}>
166
- <Text style={{ fontSize: 20, fontWeight: 'bold', marginBottom: 16 }}>
167
- Welcome to Mobile
168
- </Text>
169
- <NativeLazyImage
170
- source={{ uri: 'https://example.com/image.jpg' }}
171
- style={{ width: '100%', height: 200, borderRadius: 8, marginBottom: 16 }}
172
- placeholder="skeleton"
173
- />
174
- <NativeButton
175
- variant="default"
176
- size="lg"
177
- onPress={() => console.log('Pressed')}
178
- >
179
- Get Started
180
- </NativeButton>
181
- </NativeCard>
182
- </NativeContainer>
183
- </NativePageTransition>
184
- );
185
- }
186
- ```
187
-
188
- ## 📚 Available Components
189
-
190
- ### ✅ Core Components (v0.13.0)
191
-
192
- | Component | Web | Native | Description |
193
- |-----------|-----|--------|-------------|
194
- | **Layout & Structure** | | | |
195
- | `Container` | ✅ | ✅ | Responsive layout containers |
196
- | `Grid` | ✅ | ✅ | Flexible grid layouts |
197
- | `Section` | | | Semantic page sections |
198
- | `Card` | ✅ | ✅ | Content containers with elevation |
199
- | **Interactive Elements** | | | |
200
- | `Button` | | | Primary action buttons with variants |
201
- | `SwipeableCard` | || **NEW** Touch-friendly swipe gestures with haptic feedback |
202
- | **Advanced Mobile Interactions** | | | |
203
- | `PageTransition` | ✅ | ✅ | **NEW** Smooth page transitions with multiple animation types |
204
- | `PullToRefresh` | ✅ | ✅ | **NEW** Native pull-to-refresh functionality |
205
- | **Performance & Media** | | | |
206
- | `LazyImage` ||| **NEW** Intelligent lazy loading with WebP support |
207
- | `ProgressiveImage` | ✅ | ✅ | **NEW** Quality-aware progressive image loading |
208
- | `VirtualScrollList` | ✅ | ✅ | **NEW** Memory-efficient virtual scrolling |
209
- | **Network & Offline** | | | |
210
- | `NetworkAwareContent` | ✅ | ✅ | **NEW** Smart content delivery based on network conditions |
211
- | `OfflineWrapper` | ✅ | ✅ | **NEW** Comprehensive offline support with caching |
212
-
213
- ### 🌐 Web-Specific Components
214
-
215
- - `Alert` - Contextual feedback messages
216
- - `Avatar` - User profile pictures and initials
217
- - `Badge` - Status indicators and counts
218
- - `Checkbox` - Boolean input controls
219
- - `DataTable` - Sortable data tables with pagination support
220
- - `Dialog` - Modal dialogs and overlays
221
- - `DropdownMenu` - Contextual action menus
222
- - `Form` - Form validation and state management
223
- - `Input` - Text input fields with validation
224
- - `Label` - Accessible form labels
225
- - `Modal` - Simple modal wrapper component
226
- - `Pagination` - Data navigation with page controls
227
- - `Progress` - Progress indicators and loading bars
228
- - `Select` - Dropdown selection controls
229
- - `Skeleton` - Loading state placeholders
230
- - `Tabs` - Tabbed content navigation
231
- - `Toast` - Notification messages
232
- - `Tooltip` - Contextual help and information
233
- - `AudioPlayer` - Advanced audio playback with playlists
234
- - `VideoPlayer` - Feature-rich video player
235
- - `AudioUploader` - Audio file upload with preview
236
- - `FileUpload` - Drag-and-drop file uploads
237
- - `Waveform` - Audio waveform visualization
238
-
239
- ### 📱 Native-Specific Components
240
-
241
- - `SafeContainer` - Safe area aware container
242
- - `TouchableCard` - Pressable card component
243
-
244
- ## 🆕 NEW v0.21.0: Layout & Navigation System
245
-
246
- ### Complete Application Structure
247
- A comprehensive system providing everything needed for modern SaaS applications:
248
-
249
- #### 🏗️ App Shell Components
250
-
251
- | Component | Web | Native | Description |
252
- |-----------|-----|--------|-------------|
253
- | `AppShell` | ✅ | ✅ | Complete application layout orchestration |
254
- | `Header` | ✅ | ✅ | Top navigation with user menu and actions |
255
- | `Sidebar` | | - | Collapsible navigation sidebar (web) |
256
- | `Drawer` | - | ✅ | Slide-out navigation drawer (mobile) |
257
- | `Breadcrumbs` | | - | Hierarchical navigation breadcrumbs |
258
-
259
- #### 🧭 Navigation Components
260
-
261
- | Component | Web | Native | Description |
262
- |-----------|-----|--------|-------------|
263
- | `Tabs` | ✅ | | Feature-rich tabbed navigation |
264
- | `BottomTabBar` | - | ✅ | Mobile-optimized bottom tab navigation |
265
- | `Stepper` | ✅ | | Step-by-step process visualization |
266
- | `Pagination` | ✅ | ✅ | Data navigation with page controls |
267
- | `CommandPalette` | ✅ | - | Keyboard-driven command palette (Cmd+K) |
268
-
269
- #### 🎯 Tour & Onboarding
270
-
271
- | Component | Web | Native | Description |
272
- |-----------|-----|--------|-------------|
273
- | `Tour` | ✅ | ✅ | Interactive guided tours with spotlights |
274
- | `Onboarding` | ✅ | ✅ | Multi-step onboarding with progress tracking |
275
- | `Tooltip` | ✅ | | Contextual feature highlights |
276
- | `WelcomeModal` | ✅ | ✅ | Welcome screens with feature showcase |
277
- | `FeatureHighlight` | | - | Animated feature callouts with pulse effects |
278
-
279
- #### 📋 Layout Templates
280
-
281
- | Template | Web | Native | Description |
282
- |----------|-----|--------|-------------|
283
- | `DashboardLayout` | ✅ | ✅ | Complete dashboard with navigation |
284
- | `AuthLayout` | ✅ | ✅ | Authentication pages with features showcase |
285
- | `SettingsLayout` | ✅ | | Settings pages with tabbed navigation |
286
-
287
- ### Usage Examples
288
-
289
- #### Web Dashboard with Command Palette
290
- ```tsx
291
- import {
292
- DashboardLayout,
293
- CommandPalette,
294
- useCommandPalette
295
- } from '@digilogiclabs/saas-factory-ui';
296
-
297
- export default function Dashboard() {
298
- const commands = [
299
- {
300
- id: 'nav',
301
- label: 'Navigation',
302
- items: [
303
- { id: 'dashboard', label: 'Go to Dashboard', action: () => router.push('/') },
304
- { id: 'settings', label: 'Open Settings', action: () => router.push('/settings') },
305
- ]
306
- }
307
- ];
308
-
309
- const { isOpen, toggle } = useCommandPalette({
310
- commands,
311
- keyboardShortcut: 'cmd+k'
312
- });
313
-
314
- return (
315
- <DashboardLayout>
316
- <div className="p-6">
317
- <h1>Dashboard Content</h1>
318
- <p>Press Cmd+K to open command palette</p>
319
- </div>
320
-
321
- <CommandPalette
322
- open={isOpen}
323
- onOpenChange={toggle}
324
- commands={commands}
325
- />
326
- </DashboardLayout>
327
- );
328
- }
329
- ```
330
-
331
- #### Native App with Bottom Tabs
332
- ```tsx
333
- import {
334
- DashboardLayout,
335
- Tour,
336
- useTour
337
- } from '@digilogiclabs/saas-factory-ui/native';
338
-
339
- export default function MobileApp() {
340
- const tourSteps = [
341
- {
342
- id: 'welcome',
343
- title: 'Welcome!',
344
- content: 'Let me show you around',
345
- target: '#main-content'
346
- }
347
- ];
348
-
349
- const { isOpen, start } = useTour({
350
- steps: tourSteps,
351
- localStorage: { key: 'app-tour' }
352
- });
353
-
354
- return (
355
- <DashboardLayout
356
- showBottomTabs={true}
357
- bottomTabs={[
358
- { id: 'home', label: 'Home', icon: '🏠' },
359
- { id: 'search', label: 'Search', icon: '🔍' },
360
- { id: 'profile', label: 'Profile', icon: '👤' },
361
- ]}
362
- >
363
- <ScrollView>
364
- <Text style={styles.title}>Mobile Dashboard</Text>
365
- <TouchableOpacity onPress={start}>
366
- <Text>Start Tour</Text>
367
- </TouchableOpacity>
368
- </ScrollView>
369
-
370
- <Tour
371
- steps={tourSteps}
372
- isOpen={isOpen}
373
- onRequestClose={() => {}}
374
- />
375
- </DashboardLayout>
376
- );
377
- }
378
- ```
379
-
380
- ### 🔧 Available Hooks
381
-
382
- #### Cross-Platform Hooks
383
- - `useMounted` - Component mount status detection
384
- - `useNetworkInfo` - **NEW** Network connection monitoring
385
- - `useOfflineState` - **NEW** Online/offline status detection
386
- - `useCache` - **NEW** Persistent caching utilities
387
- - `useTour` - **NEW** Tour state management with localStorage persistence
388
- - `useOnboarding` - **NEW** Multi-step onboarding flow management
389
-
390
- #### Web-Only Hooks
391
- - `useMediaQuery` - Responsive breakpoint detection
392
- - `useLockBody` - Body scroll lock for modals
393
- - `useCommandPalette` - **NEW** Command palette state management
394
- - `useResponsive` - **NEW** Advanced responsive breakpoint detection
395
-
396
- #### Native-Only Hooks
397
- - `useDimensions` - Screen dimensions and orientation
398
- - `useKeyboard` - Keyboard visibility and height
399
-
400
- ## 🚀 New v0.13.0 Features
401
-
402
- ### Advanced Mobile Interactions
403
-
404
- #### PageTransition
405
- Smooth, customizable page transitions with multiple animation types:
406
-
407
- ```tsx
408
- // Web
409
- import { PageTransition } from '@digilogiclabs/saas-factory-ui';
410
-
411
- <PageTransition
412
- type="slide"
413
- direction="horizontal"
414
- duration={300}
415
- key={pageKey}
416
- >
417
- <YourPageContent />
418
- </PageTransition>
419
-
420
- // Supported types: 'slide', 'fade', 'scale', 'flip', 'elastic'
421
- // Directions: 'horizontal', 'vertical', 'up', 'down', 'left', 'right'
422
- ```
423
-
424
- #### SwipeableCard
425
- Touch-friendly cards with swipe actions and haptic feedback:
426
-
427
- ```tsx
428
- // Web
429
- import { SwipeableCard } from '@digilogiclabs/saas-factory-ui';
430
-
431
- <SwipeableCard
432
- leftActions={[{
433
- id: 'archive',
434
- label: 'Archive',
435
- backgroundColor: '#10B981',
436
- onAction: () => archiveItem()
437
- }]}
438
- rightActions={[{
439
- id: 'delete',
440
- label: 'Delete',
441
- backgroundColor: '#EF4444',
442
- onAction: () => deleteItem()
443
- }]}
444
- hapticFeedback={true}
445
- threshold={80}
446
- >
447
- <div className="p-4">
448
- <h3>Swipe me left or right!</h3>
449
- </div>
450
- </SwipeableCard>
451
- ```
452
-
453
- #### PullToRefresh
454
- Native pull-to-refresh functionality:
455
-
456
- ```tsx
457
- // Web
458
- import { PullToRefresh } from '@digilogiclabs/saas-factory-ui';
459
-
460
- <PullToRefresh
461
- onRefresh={async () => {
462
- await fetchFreshData();
463
- }}
464
- threshold={60}
465
- hapticFeedback={true}
466
- >
467
- <YourScrollableContent />
468
- </PullToRefresh>
469
- ```
470
-
471
- ### Performance Optimization
472
-
473
- #### LazyImage
474
- Intelligent lazy loading with modern format support:
475
-
476
- ```tsx
477
- // Web
478
- import { LazyImage } from '@digilogiclabs/saas-factory-ui';
479
-
480
- <LazyImage
481
- src="/large-image.jpg"
482
- alt="Description"
483
- placeholder="blur"
484
- webpSupport={true}
485
- mobileOptimization={{
486
- quality: 75,
487
- format: "webp",
488
- sizes: "(max-width: 768px) 100vw, 50vw"
489
- }}
490
- loading="lazy"
491
- fetchPriority="high"
492
- retryAttempts={3}
493
- />
494
- ```
495
-
496
- #### ProgressiveImage
497
- Quality-aware progressive loading:
498
-
499
- ```tsx
500
- // Web
501
- import { ProgressiveImage } from '@digilogiclabs/saas-factory-ui';
502
-
503
- <ProgressiveImage
504
- lowQualitySrc="/thumbnail.jpg"
505
- highQualitySrc="/full-quality.jpg"
506
- alt="Progressive image"
507
- mobileStrategy="blur-up"
508
- transition="fade"
509
- networkAware={true}
510
- />
511
- ```
512
-
513
- #### VirtualScrollList
514
- Memory-efficient virtual scrolling for large datasets:
515
-
516
- ```tsx
517
- // Web
518
- import { VirtualScrollList } from '@digilogiclabs/saas-factory-ui';
519
-
520
- <VirtualScrollList
521
- items={largeDataArray}
522
- itemHeight={80}
523
- containerHeight={400}
524
- renderItem={(item, index) => (
525
- <div key={index} className="p-4 border-b">
526
- {item.name}
527
- </div>
528
- )}
529
- onEndReached={() => loadMore()}
530
- mobileOptimized={true}
531
- overscan={5}
532
- />
533
- ```
534
-
535
- ### Network & Offline Support
536
-
537
- #### NetworkAwareContent
538
- Smart content delivery based on connection quality:
539
-
540
- ```tsx
541
- // Web
542
- import { NetworkAwareContent } from '@digilogiclabs/saas-factory-ui';
543
-
544
- <NetworkAwareContent
545
- showOnFast={<HighQualityContent />}
546
- showOnSlow={<LightweightContent />}
547
- showOnOffline={<OfflineMessage />}
548
- respectSaveData={true}
549
- >
550
- <DefaultContent />
551
- </NetworkAwareContent>
552
- ```
553
-
554
- #### OfflineWrapper
555
- Comprehensive offline support with caching:
556
-
557
- ```tsx
558
- // Web
559
- import { OfflineWrapper } from '@digilogiclabs/saas-factory-ui';
560
-
561
- <OfflineWrapper
562
- cacheStrategy="stale-while-revalidate"
563
- cacheKey="user-data"
564
- cacheDuration={3600000} // 1 hour
565
- showOfflineIndicator={true}
566
- retryOnReconnect={true}
567
- >
568
- <YourOnlineContent />
569
- </OfflineWrapper>
570
- ```
571
-
572
- ## 🎨 Advanced Usage Examples
573
-
574
- ### Mobile-Optimized Dashboard
575
-
576
- ```tsx
577
- import {
578
- PageTransition,
579
- NetworkAwareContent,
580
- VirtualScrollList,
581
- PullToRefresh,
582
- LazyImage
583
- } from '@digilogiclabs/saas-factory-ui';
584
-
585
- function MobileDashboard() {
586
- const [data, setData] = useState([]);
587
- const [refreshing, setRefreshing] = useState(false);
588
-
589
- const handleRefresh = async () => {
590
- setRefreshing(true);
591
- await fetchFreshData();
592
- setRefreshing(false);
593
- };
594
-
595
- return (
596
- <PageTransition type="slide" direction="up">
597
- <div className="h-screen flex flex-col">
598
- <NetworkAwareContent
599
- showOnSlow={<SimpleDashboardHeader />}
600
- showOnFast={<RichDashboardHeader />}
601
- >
602
- <DashboardHeader />
603
- </NetworkAwareContent>
604
-
605
- <PullToRefresh
606
- onRefresh={handleRefresh}
607
- className="flex-1"
608
- >
609
- <VirtualScrollList
610
- items={data}
611
- itemHeight={120}
612
- renderItem={(item, index) => (
613
- <div className="p-4 border-b">
614
- <div className="flex items-center space-x-3">
615
- <LazyImage
616
- src={item.avatar}
617
- alt={item.name}
618
- className="w-12 h-12 rounded-full"
619
- placeholder="blur"
620
- />
621
- <div>
622
- <h3 className="font-semibold">{item.name}</h3>
623
- <p className="text-sm text-gray-500">{item.status}</p>
624
- </div>
625
- </div>
626
- </div>
627
- )}
628
- onEndReached={loadMoreData}
629
- mobileOptimized={true}
630
- />
631
- </PullToRefresh>
632
- </div>
633
- </PageTransition>
634
- );
635
- }
636
- ```
637
-
638
- ### Swipeable Card List with Actions
639
-
640
- ```tsx
641
- import { SwipeableCard, LazyImage, Button } from '@digilogiclabs/saas-factory-ui';
642
-
643
- function MessageList({ messages }) {
644
- return (
645
- <div className="space-y-2">
646
- {messages.map((message) => (
647
- <SwipeableCard
648
- key={message.id}
649
- leftActions={[{
650
- id: 'archive',
651
- label: 'Archive',
652
- icon: '📁',
653
- backgroundColor: '#10B981',
654
- onAction: () => archiveMessage(message.id)
655
- }]}
656
- rightActions={[{
657
- id: 'delete',
658
- label: 'Delete',
659
- icon: '🗑️',
660
- backgroundColor: '#EF4444',
661
- onAction: () => deleteMessage(message.id)
662
- }]}
663
- threshold={100}
664
- hapticFeedback={true}
665
- >
666
- <div className="flex items-center p-4 bg-white rounded-lg shadow">
667
- <LazyImage
668
- src={message.sender.avatar}
669
- alt={message.sender.name}
670
- className="w-12 h-12 rounded-full mr-3"
671
- placeholder="skeleton"
672
- />
673
- <div className="flex-1">
674
- <h4 className="font-semibold">{message.sender.name}</h4>
675
- <p className="text-gray-600 truncate">{message.preview}</p>
676
- </div>
677
- <span className="text-xs text-gray-400">{message.time}</span>
678
- </div>
679
- </SwipeableCard>
680
- ))}
681
- </div>
682
- );
683
- }
684
- ```
685
-
686
- ### Progressive Image Gallery
687
-
688
- ```tsx
689
- import { ProgressiveImage, VirtualScrollList } from '@digilogiclabs/saas-factory-ui';
690
-
691
- function ImageGallery({ images }) {
692
- return (
693
- <VirtualScrollList
694
- items={images}
695
- itemHeight={300}
696
- renderItem={(image, index) => (
697
- <div className="p-2">
698
- <ProgressiveImage
699
- lowQualitySrc={image.thumbnail}
700
- highQualitySrc={image.fullSize}
701
- alt={image.description}
702
- className="w-full h-64 object-cover rounded-lg"
703
- mobileStrategy="blur-up"
704
- transition="crossfade"
705
- networkAware={true}
706
- />
707
- </div>
708
- )}
709
- containerHeight={600}
710
- mobileOptimized={true}
711
- />
712
- );
713
- }
714
- ```
715
-
716
- ## 🌐 Network-Aware Development
717
-
718
- ### Connection-Based Content Delivery
719
-
720
- ```tsx
721
- import { NetworkAwareContent, useNetworkInfo } from '@digilogiclabs/saas-factory-ui';
722
-
723
- function AdaptiveApp() {
724
- const networkInfo = useNetworkInfo();
725
-
726
- return (
727
- <div>
728
- <NetworkAwareContent
729
- fastThreshold={['4g', 'fast']}
730
- slowThreshold={['2g', '3g', 'slow']}
731
- showOnFast={
732
- <div>
733
- <HighResolutionImages />
734
- <AnimatedComponents />
735
- <VideoContent />
736
- </div>
737
- }
738
- showOnSlow={
739
- <div>
740
- <CompressedImages />
741
- <StaticComponents />
742
- <TextContent />
743
- </div>
744
- }
745
- showOnOffline={<OfflineFallback />}
746
- respectSaveData={true}
747
- onNetworkChange={(info) => {
748
- console.log('Network changed:', info);
749
- // Adjust app behavior based on network
750
- }}
751
- >
752
- <DefaultContent />
753
- </NetworkAwareContent>
754
- </div>
755
- );
756
- }
757
- ```
758
-
759
- ### Offline-First Architecture
760
-
761
- ```tsx
762
- import { OfflineWrapper, useOfflineState, useCache } from '@digilogiclabs/saas-factory-ui';
763
-
764
- function OfflineCapableComponent() {
765
- const isOnline = useOfflineState();
766
- const { get, set } = useCache('user-preferences', 3600000);
767
-
768
- return (
769
- <OfflineWrapper
770
- cacheStrategy="stale-while-revalidate"
771
- cacheKey="dashboard-data"
772
- showOfflineIndicator={true}
773
- enableServiceWorker={true}
774
- onOffline={() => console.log('Gone offline')}
775
- onOnline={() => console.log('Back online')}
776
- fallback={
777
- <div className="text-center p-8">
778
- <h3>You're offline</h3>
779
- <p>Some features may not be available</p>
780
- </div>
781
- }
782
- >
783
- <div>
784
- <h2>Dashboard {isOnline ? '🟢' : '🔴'}</h2>
785
- <DashboardContent />
786
- </div>
787
- </OfflineWrapper>
788
- );
789
- }
790
- ```
791
-
792
- ## 🎨 Theming & Styling
793
-
794
- ### Custom Theme Configuration
795
-
796
- Create a custom theme by extending the default CSS variables:
797
-
798
- ```css
799
- /* custom-theme.css */
800
- :root {
801
- /* Primary colors */
802
- --primary: 262 83% 58%; /* Purple */
803
- --primary-foreground: 0 0% 98%;
804
-
805
- /* Secondary colors */
806
- --secondary: 220 14% 96%;
807
- --secondary-foreground: 220 9% 46%;
808
-
809
- /* Accent colors */
810
- --accent: 262 83% 58%;
811
- --accent-foreground: 0 0% 98%;
812
-
813
- /* Custom border radius */
814
- --radius: 0.75rem;
815
- }
816
-
817
- /* Dark mode overrides */
818
- .dark {
819
- --primary: 262 83% 58%;
820
- --primary-foreground: 0 0% 98%;
821
- --background: 224 71% 4%;
822
- --foreground: 213 31% 91%;
823
- }
824
- ```
825
-
826
- ## 📝 Migration Guide
827
-
828
- ### From v0.12.x to v0.13.0
829
-
830
- #### New Dependencies (Optional)
831
- For full functionality, install additional dependencies:
832
-
833
- ```bash
834
- # For React Native projects
835
- npm install @react-native-community/netinfo
836
- npm install @react-native-async-storage/async-storage
837
- npm install expo-haptics
838
-
839
- # These are optional and only needed if using specific components
840
- ```
841
-
842
- #### Breaking Changes
843
- - None. All new components are additive.
844
-
845
- #### New Features Available
846
- - Advanced mobile interactions (PageTransition, SwipeableCard, PullToRefresh)
847
- - Performance optimization components (LazyImage, ProgressiveImage, VirtualScrollList)
848
- - Network and offline support (NetworkAwareContent, OfflineWrapper)
849
- - New hooks (useNetworkInfo, useOfflineState, useCache)
850
-
851
- ## 🏗 Development Status
852
-
853
- ### Completed (v0.13.0) - Mobile-First Optimization Release
854
-
855
- **Advanced Mobile Interactions**
856
- - ✅ PageTransition - Smooth page transitions with gesture support
857
- - SwipeableCard - Touch-friendly swipe gestures with haptic feedback
858
- - ✅ PullToRefresh - Native pull-to-refresh functionality
859
-
860
- **Performance Optimization**
861
- - LazyImage - Intelligent lazy loading with WebP support
862
- - ProgressiveImage - Quality-aware progressive image loading
863
- - ✅ VirtualScrollList - Memory-efficient virtual scrolling
864
-
865
- **Network & Offline Support**
866
- - NetworkAwareContent - Smart content delivery based on network conditions
867
- - ✅ OfflineWrapper - Comprehensive offline support with caching strategies
868
- - Network detection hooks and utilities
869
-
870
- **Developer Experience**
871
- - ✅ Cross-platform architecture (Web + React Native)
872
- - Full TypeScript support with platform-specific types
873
- - ✅ Accessibility-first design (WCAG 2.2 AA compliant)
874
- - ✅ Tree-shakeable exports and optimized bundle sizes
875
- - Comprehensive documentation and examples
876
-
877
- ### 🚧 Coming Next (v0.14.0)
878
-
879
- **Enhanced Authentication Components**
880
- - 🔄 MobileAuthForm with biometric authentication
881
- - 🔄 MobileUserMenu with gesture-enabled navigation
882
- - 🔄 Social login optimizations
883
-
884
- **Mobile Payment Optimization**
885
- - 🔄 MobileCheckout with Apple Pay/Google Pay
886
- - 🔄 MobileBilling dashboard
887
- - 🔄 MobilePricing with comparison tables
888
-
889
- ### 📋 Future Roadmap
890
-
891
- - Advanced UI components (BottomSheet, InfiniteScroll, FAB)
892
- - Enhanced theming system with brand color extraction
893
- - Real-time components with WebSocket integration
894
- - PWA optimization features
895
- - Advanced accessibility features
896
- - Comprehensive Storybook documentation
897
-
898
- ## 🚀 Performance Metrics
899
-
900
- ### Bundle Sizes (v0.13.0)
901
- - **Main Bundle**: 270KB ESM (295KB CJS) + 73KB CSS
902
- - **Web Bundle**: 295KB optimized for web platforms
903
- - **Native Bundle**: 18KB optimized for React Native
904
- - **Tree-shakeable**: Import only what you need
905
-
906
- ### Performance Targets
907
- - **Bundle Size**: < 250KB gzipped (Optimized)
908
- - **Load Time**: < 3s on 3G networks ✅
909
- - **First Paint**: < 1.5s ✅
910
- - **Interaction Ready**: < 2.5s ✅
911
- - **Accessibility Score**: 95+ Lighthouse ✅
912
-
913
- ## 🔧 Development & Contributing
914
-
915
- ### Local Development
916
-
917
- ```bash
918
- # Clone the repository
919
- git clone https://github.com/DigiLogicLabs/saas-factory-ui
920
- cd saas-factory-ui
921
-
922
- # Install dependencies
923
- npm install
924
-
925
- # Build the package
926
- npm run build
927
-
928
- # Run tests
929
- npm run test
930
-
931
- # Type check
932
- npm run type-check
933
-
934
- # Lint
935
- npm run lint
936
-
937
- # Link for local testing
938
- npm link
939
-
940
- # In your test project
941
- npm link @digilogiclabs/saas-factory-ui
942
- ```
943
-
944
- ### Testing Your Changes
945
-
946
- 1. Build the package: `npm run build`
947
- 2. Test in a Next.js app with mobile interactions
948
- 3. Test in a React Native/Expo app
949
- 4. Verify TypeScript types work correctly
950
- 5. Test offline/online scenarios
951
- 6. Verify accessibility with screen readers
952
-
953
- ## 🐛 Troubleshooting
954
-
955
- ### Quick Diagnostic Commands
956
-
957
- ```bash
958
- # Check if package is installed correctly
959
- npm ls @digilogiclabs/saas-factory-ui
960
-
961
- # Check package contents
962
- ls node_modules/@digilogiclabs/saas-factory-ui/dist/
963
-
964
- # Verify CSS file exists
965
- find node_modules/@digilogiclabs/saas-factory-ui -name "*.css"
966
-
967
- # Test network features (in browser console)
968
- navigator.onLine // Should return true/false
969
- navigator.connection // Should show connection info
970
- ```
971
-
972
- ### Common Solutions
973
-
974
- 1. **Clear cache**: `rm -rf .next node_modules package-lock.json && npm install`
975
- 2. **Rebuild**: `npm run build` in your project
976
- 3. **Check imports**: Verify import paths match package exports
977
- 4. **Update dependencies**: Ensure compatible React/Next.js versions
978
- 5. **Network features not working**: Check browser support and permissions
979
- 6. **Haptic feedback not working**: Verify device and browser support
980
-
981
- ### Mobile-Specific Issues
982
-
983
- 1. **Gestures not working**: Ensure `touch-action` CSS is not preventing interactions
984
- 2. **Performance issues**: Enable `mobileOptimized` props where available
985
- 3. **Network detection not working on mobile**: Check app permissions and service worker registration
986
-
987
- ## 📄 License
988
-
989
- MIT © [DigiLogic Labs](https://github.com/DigiLogicLabs)
990
-
991
- ## 🔗 Links
992
-
993
- - [Documentation](https://github.com/DigiLogicLabs/saas-factory-ui)
994
- - [NPM Package](https://www.npmjs.com/package/@digilogiclabs/saas-factory-ui)
995
- - [Issues](https://github.com/DigiLogicLabs/saas-factory-ui/issues)
996
- - [Changelog](CHANGELOG.md)
997
- - [Migration Guide](MIGRATION.md)
998
-
999
- ---
1000
-
1001
- **Current Version**: 0.13.0
1002
- **Release Date**: September 2025
1003
- **Platforms**: Web (Next.js/React) + React Native/Expo
1004
- **License**: MIT
1
+ # @digilogiclabs/saas-factory-ui
2
+
3
+ A comprehensive cross-platform UI component library built for both **Next.js web applications** and **React Native/Expo mobile applications**. This package provides a complete set of accessible, mobile-optimized components with consistent design across platforms.
4
+
5
+ ## 🌟 Features
6
+
7
+ - 🎨 **Cross-Platform Design System**
8
+ - Consistent components for web and mobile
9
+ - Platform-optimized implementations
10
+ - Shared design tokens and theming
11
+ - 🌐 **Web Support**
12
+ - Built with React, Tailwind CSS, Radix UI, and Framer Motion
13
+ - Dark mode support
14
+ - Responsive by default
15
+ - 📱 **React Native Support**
16
+ - Native mobile components with Expo compatibility
17
+ - Platform-specific optimizations
18
+ - Haptic feedback integration
19
+ - ♿️ **Accessibility First**
20
+ - WCAG 2.2 AA compliant components
21
+ - Screen reader support
22
+ - Keyboard navigation and touch alternatives
23
+ - ⚡ **Performance Optimized**
24
+ - Advanced mobile interactions with gesture recognition
25
+ - Lazy loading and progressive image optimization
26
+ - Virtual scrolling for large datasets
27
+ - Network-aware content delivery
28
+ - 🌐 **Offline Support**
29
+ - Comprehensive caching strategies
30
+ - Offline-first component architecture
31
+ - Network detection and graceful degradation
32
+ - 🎯 **Developer Experience**
33
+ - Full TypeScript support
34
+ - Tree-shakeable exports
35
+ - Comprehensive documentation
36
+ - Optimized bundle sizes
37
+
38
+ ## 📦 Installation
39
+
40
+ ```bash
41
+ npm install @digilogiclabs/saas-factory-ui
42
+ ```
43
+
44
+ ## 🚀 Platform Requirements
45
+
46
+ ### Web Applications
47
+
48
+ - Node.js >=20.0.0
49
+ - Next.js 15+ or React 19+
50
+ - Tailwind CSS 3.4 or higher
51
+ - TypeScript (recommended)
52
+
53
+ ### React Native Applications
54
+
55
+ - Node.js >=20.0.0
56
+ - React Native 0.70 or higher
57
+ - Expo SDK 49 or higher
58
+ - React 19 or higher
59
+
60
+ ## 🌐 Web Setup (Next.js)
61
+
62
+ ### 1. Install Dependencies
63
+
64
+ ```bash
65
+ npm install @digilogiclabs/saas-factory-ui
66
+ npm install -D tailwindcss postcss autoprefixer
67
+ npx tailwindcss init -p
68
+ ```
69
+
70
+ ### 2. Configure Tailwind CSS
71
+
72
+ Update your `tailwind.config.js` to include the component library:
73
+
74
+ ```js
75
+ // tailwind.config.js
76
+ /** @type {import('tailwindcss').Config} */
77
+ export default {
78
+ content: [
79
+ "./src/**/*.{js,ts,jsx,tsx}",
80
+ "./app/**/*.{js,ts,jsx,tsx}",
81
+ "./pages/**/*.{js,ts,jsx,tsx}",
82
+ "./components/**/*.{js,ts,jsx,tsx}",
83
+ // 🚨 IMPORTANT: Include the UI package
84
+ "./node_modules/@digilogiclabs/saas-factory-ui/**/*.{js,ts,jsx,tsx}",
85
+ ],
86
+ theme: {
87
+ extend: {},
88
+ },
89
+ plugins: [],
90
+ };
91
+ ```
92
+
93
+ ### 3. Import Styles (REQUIRED)
94
+
95
+ Add the CSS import to your root layout or app file:
96
+
97
+ ```tsx
98
+ // app/layout.tsx (Next.js 13+) or pages/_app.tsx (Next.js 12)
99
+ import "@digilogiclabs/saas-factory-ui/styles.css";
100
+ import "./globals.css"; // Your app styles
101
+ ```
102
+
103
+ ### 4. Use Components
104
+
105
+ ```tsx
106
+ import {
107
+ Button,
108
+ Card,
109
+ Container,
110
+ PageTransition,
111
+ SwipeableCard,
112
+ LazyImage,
113
+ } from "@digilogiclabs/saas-factory-ui";
114
+
115
+ export default function HomePage() {
116
+ return (
117
+ <PageTransition type="slide" direction="horizontal">
118
+ <Container>
119
+ <Card className="p-6">
120
+ <h1 className="text-2xl font-bold mb-4">Welcome to Web</h1>
121
+ <LazyImage
122
+ src="/hero-image.jpg"
123
+ alt="Hero image"
124
+ className="w-full h-64 object-cover rounded-lg mb-4"
125
+ placeholder="blur"
126
+ webpSupport={true}
127
+ />
128
+ <Button variant="default" size="lg">
129
+ Get Started
130
+ </Button>
131
+ </Card>
132
+ </Container>
133
+ </PageTransition>
134
+ );
135
+ }
136
+ ```
137
+
138
+ ## 📱 React Native Setup
139
+
140
+ ### 1. Install Dependencies
141
+
142
+ ```bash
143
+ npm install @digilogiclabs/saas-factory-ui
144
+ # Required for advanced features
145
+ npm install @react-native-community/netinfo
146
+ npm install @react-native-async-storage/async-storage
147
+ npm install expo-haptics
148
+ ```
149
+
150
+ ### 2. Import Native Components
151
+
152
+ ```tsx
153
+ import {
154
+ NativeButton,
155
+ NativeContainer,
156
+ NativeCard,
157
+ NativePageTransition,
158
+ NativeSwipeableCard,
159
+ NativeLazyImage,
160
+ } from "@digilogiclabs/saas-factory-ui/native";
161
+ import { Text } from "react-native";
162
+
163
+ export default function App() {
164
+ return (
165
+ <NativePageTransition type="slide" direction="horizontal">
166
+ <NativeContainer style={{ flex: 1, padding: 20 }}>
167
+ <NativeCard style={{ padding: 20 }}>
168
+ <Text style={{ fontSize: 20, fontWeight: "bold", marginBottom: 16 }}>
169
+ Welcome to Mobile
170
+ </Text>
171
+ <NativeLazyImage
172
+ source={{ uri: "https://example.com/image.jpg" }}
173
+ style={{
174
+ width: "100%",
175
+ height: 200,
176
+ borderRadius: 8,
177
+ marginBottom: 16,
178
+ }}
179
+ placeholder="skeleton"
180
+ />
181
+ <NativeButton
182
+ variant="default"
183
+ size="lg"
184
+ onPress={() => console.log("Pressed")}
185
+ >
186
+ Get Started
187
+ </NativeButton>
188
+ </NativeCard>
189
+ </NativeContainer>
190
+ </NativePageTransition>
191
+ );
192
+ }
193
+ ```
194
+
195
+ ## 📚 Available Components
196
+
197
+ ###Core Components (v0.13.0)
198
+
199
+ | Component | Web | Native | Description |
200
+ | -------------------------------- | --- | ------ | ------------------------------------------------------------- |
201
+ | **Layout & Structure** | | | |
202
+ | `Container` | | | Responsive layout containers |
203
+ | `Grid` | ✅ | ✅ | Flexible grid layouts |
204
+ | `Section` | ✅ | ✅ | Semantic page sections |
205
+ | `Card` | | | Content containers with elevation |
206
+ | **Interactive Elements** | | | |
207
+ | `Button` | ✅ | ✅ | Primary action buttons with variants |
208
+ | `SwipeableCard` | ✅ | ✅ | **NEW** Touch-friendly swipe gestures with haptic feedback |
209
+ | **Advanced Mobile Interactions** | | | |
210
+ | `PageTransition` | ✅ | ✅ | **NEW** Smooth page transitions with multiple animation types |
211
+ | `PullToRefresh` | ✅ | ✅ | **NEW** Native pull-to-refresh functionality |
212
+ | **Performance & Media** | | | |
213
+ | `LazyImage` | ✅ | ✅ | **NEW** Intelligent lazy loading with WebP support |
214
+ | `ProgressiveImage` | ✅ | ✅ | **NEW** Quality-aware progressive image loading |
215
+ | `VirtualScrollList` | ✅ | ✅ | **NEW** Memory-efficient virtual scrolling |
216
+ | **Network & Offline** | | | |
217
+ | `NetworkAwareContent` | ✅ | ✅ | **NEW** Smart content delivery based on network conditions |
218
+ | `OfflineWrapper` | ✅ | ✅ | **NEW** Comprehensive offline support with caching |
219
+
220
+ ### 🌐 Web-Specific Components
221
+
222
+ - `Alert` - Contextual feedback messages
223
+ - `Avatar` - User profile pictures and initials
224
+ - `Badge` - Status indicators and counts
225
+ - `Checkbox` - Boolean input controls
226
+ - `DataTable` - Sortable data tables with pagination support
227
+ - `Dialog` - Modal dialogs and overlays
228
+ - `DropdownMenu` - Contextual action menus
229
+ - `Form` - Form validation and state management
230
+ - `Input` - Text input fields with validation
231
+ - `Label` - Accessible form labels
232
+ - `Modal` - Simple modal wrapper component
233
+ - `Pagination` - Data navigation with page controls
234
+ - `Progress` - Progress indicators and loading bars
235
+ - `Select` - Dropdown selection controls
236
+ - `Skeleton` - Loading state placeholders
237
+ - `Tabs` - Tabbed content navigation
238
+ - `Toast` - Notification messages
239
+ - `Tooltip` - Contextual help and information
240
+ - `AudioPlayer` - Advanced audio playback with playlists
241
+ - `VideoPlayer` - Feature-rich video player
242
+ - `AudioUploader` - Audio file upload with preview
243
+ - `FileUpload` - Drag-and-drop file uploads
244
+ - `Waveform` - Audio waveform visualization
245
+
246
+ ### 📱 Native-Specific Components
247
+
248
+ - `SafeContainer` - Safe area aware container
249
+ - `TouchableCard` - Pressable card component
250
+
251
+ ## 🆕 NEW v0.21.0: Layout & Navigation System
252
+
253
+ ### Complete Application Structure
254
+
255
+ A comprehensive system providing everything needed for modern SaaS applications:
256
+
257
+ #### 🏗️ App Shell Components
258
+
259
+ | Component | Web | Native | Description |
260
+ | ------------- | --- | ------ | ----------------------------------------- |
261
+ | `AppShell` | | | Complete application layout orchestration |
262
+ | `Header` | ✅ | ✅ | Top navigation with user menu and actions |
263
+ | `Sidebar` | ✅ | - | Collapsible navigation sidebar (web) |
264
+ | `Drawer` | - | ✅ | Slide-out navigation drawer (mobile) |
265
+ | `Breadcrumbs` | ✅ | - | Hierarchical navigation breadcrumbs |
266
+
267
+ #### 🧭 Navigation Components
268
+
269
+ | Component | Web | Native | Description |
270
+ | ---------------- | --- | ------ | --------------------------------------- |
271
+ | `Tabs` | | | Feature-rich tabbed navigation |
272
+ | `BottomTabBar` | - | ✅ | Mobile-optimized bottom tab navigation |
273
+ | `Stepper` | ✅ | ✅ | Step-by-step process visualization |
274
+ | `Pagination` | ✅ | ✅ | Data navigation with page controls |
275
+ | `CommandPalette` | ✅ | - | Keyboard-driven command palette (Cmd+K) |
276
+
277
+ #### 🎯 Tour & Onboarding
278
+
279
+ | Component | Web | Native | Description |
280
+ | ------------------ | --- | ------ | -------------------------------------------- |
281
+ | `Tour` | | | Interactive guided tours with spotlights |
282
+ | `Onboarding` | ✅ | ✅ | Multi-step onboarding with progress tracking |
283
+ | `Tooltip` | ✅ | ✅ | Contextual feature highlights |
284
+ | `WelcomeModal` | ✅ | ✅ | Welcome screens with feature showcase |
285
+ | `FeatureHighlight` | ✅ | - | Animated feature callouts with pulse effects |
286
+
287
+ #### 📋 Layout Templates
288
+
289
+ | Template | Web | Native | Description |
290
+ | ----------------- | --- | ------ | ------------------------------------------- |
291
+ | `DashboardLayout` | ✅ | ✅ | Complete dashboard with navigation |
292
+ | `AuthLayout` | ✅ | ✅ | Authentication pages with features showcase |
293
+ | `SettingsLayout` | ✅ | ✅ | Settings pages with tabbed navigation |
294
+
295
+ ### Usage Examples
296
+
297
+ #### Web Dashboard with Command Palette
298
+
299
+ ```tsx
300
+ import {
301
+ DashboardLayout,
302
+ CommandPalette,
303
+ useCommandPalette,
304
+ } from "@digilogiclabs/saas-factory-ui";
305
+
306
+ export default function Dashboard() {
307
+ const commands = [
308
+ {
309
+ id: "nav",
310
+ label: "Navigation",
311
+ items: [
312
+ {
313
+ id: "dashboard",
314
+ label: "Go to Dashboard",
315
+ action: () => router.push("/"),
316
+ },
317
+ {
318
+ id: "settings",
319
+ label: "Open Settings",
320
+ action: () => router.push("/settings"),
321
+ },
322
+ ],
323
+ },
324
+ ];
325
+
326
+ const { isOpen, toggle } = useCommandPalette({
327
+ commands,
328
+ keyboardShortcut: "cmd+k",
329
+ });
330
+
331
+ return (
332
+ <DashboardLayout>
333
+ <div className="p-6">
334
+ <h1>Dashboard Content</h1>
335
+ <p>Press Cmd+K to open command palette</p>
336
+ </div>
337
+
338
+ <CommandPalette open={isOpen} onOpenChange={toggle} commands={commands} />
339
+ </DashboardLayout>
340
+ );
341
+ }
342
+ ```
343
+
344
+ #### Native App with Bottom Tabs
345
+
346
+ ```tsx
347
+ import {
348
+ DashboardLayout,
349
+ Tour,
350
+ useTour,
351
+ } from "@digilogiclabs/saas-factory-ui/native";
352
+
353
+ export default function MobileApp() {
354
+ const tourSteps = [
355
+ {
356
+ id: "welcome",
357
+ title: "Welcome!",
358
+ content: "Let me show you around",
359
+ target: "#main-content",
360
+ },
361
+ ];
362
+
363
+ const { isOpen, start } = useTour({
364
+ steps: tourSteps,
365
+ localStorage: { key: "app-tour" },
366
+ });
367
+
368
+ return (
369
+ <DashboardLayout
370
+ showBottomTabs={true}
371
+ bottomTabs={[
372
+ { id: "home", label: "Home", icon: "🏠" },
373
+ { id: "search", label: "Search", icon: "🔍" },
374
+ { id: "profile", label: "Profile", icon: "👤" },
375
+ ]}
376
+ >
377
+ <ScrollView>
378
+ <Text style={styles.title}>Mobile Dashboard</Text>
379
+ <TouchableOpacity onPress={start}>
380
+ <Text>Start Tour</Text>
381
+ </TouchableOpacity>
382
+ </ScrollView>
383
+
384
+ <Tour steps={tourSteps} isOpen={isOpen} onRequestClose={() => {}} />
385
+ </DashboardLayout>
386
+ );
387
+ }
388
+ ```
389
+
390
+ ### 🔧 Available Hooks
391
+
392
+ #### Cross-Platform Hooks
393
+
394
+ - `useMounted` - Component mount status detection
395
+ - `useNetworkInfo` - **NEW** Network connection monitoring
396
+ - `useOfflineState` - **NEW** Online/offline status detection
397
+ - `useCache` - **NEW** Persistent caching utilities
398
+ - `useTour` - **NEW** Tour state management with localStorage persistence
399
+ - `useOnboarding` - **NEW** Multi-step onboarding flow management
400
+
401
+ #### Web-Only Hooks
402
+
403
+ - `useMediaQuery` - Responsive breakpoint detection
404
+ - `useLockBody` - Body scroll lock for modals
405
+ - `useCommandPalette` - **NEW** Command palette state management
406
+ - `useResponsive` - **NEW** Advanced responsive breakpoint detection
407
+
408
+ #### Native-Only Hooks
409
+
410
+ - `useDimensions` - Screen dimensions and orientation
411
+ - `useKeyboard` - Keyboard visibility and height
412
+
413
+ ## 🚀 New v0.13.0 Features
414
+
415
+ ### Advanced Mobile Interactions
416
+
417
+ #### PageTransition
418
+
419
+ Smooth, customizable page transitions with multiple animation types:
420
+
421
+ ```tsx
422
+ // Web
423
+ import { PageTransition } from "@digilogiclabs/saas-factory-ui";
424
+
425
+ <PageTransition
426
+ type="slide"
427
+ direction="horizontal"
428
+ duration={300}
429
+ key={pageKey}
430
+ >
431
+ <YourPageContent />
432
+ </PageTransition>;
433
+
434
+ // Supported types: 'slide', 'fade', 'scale', 'flip', 'elastic'
435
+ // Directions: 'horizontal', 'vertical', 'up', 'down', 'left', 'right'
436
+ ```
437
+
438
+ #### SwipeableCard
439
+
440
+ Touch-friendly cards with swipe actions and haptic feedback:
441
+
442
+ ```tsx
443
+ // Web
444
+ import { SwipeableCard } from "@digilogiclabs/saas-factory-ui";
445
+
446
+ <SwipeableCard
447
+ leftActions={[
448
+ {
449
+ id: "archive",
450
+ label: "Archive",
451
+ backgroundColor: "#10B981",
452
+ onAction: () => archiveItem(),
453
+ },
454
+ ]}
455
+ rightActions={[
456
+ {
457
+ id: "delete",
458
+ label: "Delete",
459
+ backgroundColor: "#EF4444",
460
+ onAction: () => deleteItem(),
461
+ },
462
+ ]}
463
+ hapticFeedback={true}
464
+ threshold={80}
465
+ >
466
+ <div className="p-4">
467
+ <h3>Swipe me left or right!</h3>
468
+ </div>
469
+ </SwipeableCard>;
470
+ ```
471
+
472
+ #### PullToRefresh
473
+
474
+ Native pull-to-refresh functionality:
475
+
476
+ ```tsx
477
+ // Web
478
+ import { PullToRefresh } from "@digilogiclabs/saas-factory-ui";
479
+
480
+ <PullToRefresh
481
+ onRefresh={async () => {
482
+ await fetchFreshData();
483
+ }}
484
+ threshold={60}
485
+ hapticFeedback={true}
486
+ >
487
+ <YourScrollableContent />
488
+ </PullToRefresh>;
489
+ ```
490
+
491
+ ### Performance Optimization
492
+
493
+ #### LazyImage
494
+
495
+ Intelligent lazy loading with modern format support:
496
+
497
+ ```tsx
498
+ // Web
499
+ import { LazyImage } from "@digilogiclabs/saas-factory-ui";
500
+
501
+ <LazyImage
502
+ src="/large-image.jpg"
503
+ alt="Description"
504
+ placeholder="blur"
505
+ webpSupport={true}
506
+ mobileOptimization={{
507
+ quality: 75,
508
+ format: "webp",
509
+ sizes: "(max-width: 768px) 100vw, 50vw",
510
+ }}
511
+ loading="lazy"
512
+ fetchPriority="high"
513
+ retryAttempts={3}
514
+ />;
515
+ ```
516
+
517
+ #### ProgressiveImage
518
+
519
+ Quality-aware progressive loading:
520
+
521
+ ```tsx
522
+ // Web
523
+ import { ProgressiveImage } from "@digilogiclabs/saas-factory-ui";
524
+
525
+ <ProgressiveImage
526
+ lowQualitySrc="/thumbnail.jpg"
527
+ highQualitySrc="/full-quality.jpg"
528
+ alt="Progressive image"
529
+ mobileStrategy="blur-up"
530
+ transition="fade"
531
+ networkAware={true}
532
+ />;
533
+ ```
534
+
535
+ #### VirtualScrollList
536
+
537
+ Memory-efficient virtual scrolling for large datasets:
538
+
539
+ ```tsx
540
+ // Web
541
+ import { VirtualScrollList } from "@digilogiclabs/saas-factory-ui";
542
+
543
+ <VirtualScrollList
544
+ items={largeDataArray}
545
+ itemHeight={80}
546
+ containerHeight={400}
547
+ renderItem={(item, index) => (
548
+ <div key={index} className="p-4 border-b">
549
+ {item.name}
550
+ </div>
551
+ )}
552
+ onEndReached={() => loadMore()}
553
+ mobileOptimized={true}
554
+ overscan={5}
555
+ />;
556
+ ```
557
+
558
+ ### Network & Offline Support
559
+
560
+ #### NetworkAwareContent
561
+
562
+ Smart content delivery based on connection quality:
563
+
564
+ ```tsx
565
+ // Web
566
+ import { NetworkAwareContent } from "@digilogiclabs/saas-factory-ui";
567
+
568
+ <NetworkAwareContent
569
+ showOnFast={<HighQualityContent />}
570
+ showOnSlow={<LightweightContent />}
571
+ showOnOffline={<OfflineMessage />}
572
+ respectSaveData={true}
573
+ >
574
+ <DefaultContent />
575
+ </NetworkAwareContent>;
576
+ ```
577
+
578
+ #### OfflineWrapper
579
+
580
+ Comprehensive offline support with caching:
581
+
582
+ ```tsx
583
+ // Web
584
+ import { OfflineWrapper } from "@digilogiclabs/saas-factory-ui";
585
+
586
+ <OfflineWrapper
587
+ cacheStrategy="stale-while-revalidate"
588
+ cacheKey="user-data"
589
+ cacheDuration={3600000} // 1 hour
590
+ showOfflineIndicator={true}
591
+ retryOnReconnect={true}
592
+ >
593
+ <YourOnlineContent />
594
+ </OfflineWrapper>;
595
+ ```
596
+
597
+ ## 🎨 Advanced Usage Examples
598
+
599
+ ### Mobile-Optimized Dashboard
600
+
601
+ ```tsx
602
+ import {
603
+ PageTransition,
604
+ NetworkAwareContent,
605
+ VirtualScrollList,
606
+ PullToRefresh,
607
+ LazyImage,
608
+ } from "@digilogiclabs/saas-factory-ui";
609
+
610
+ function MobileDashboard() {
611
+ const [data, setData] = useState([]);
612
+ const [refreshing, setRefreshing] = useState(false);
613
+
614
+ const handleRefresh = async () => {
615
+ setRefreshing(true);
616
+ await fetchFreshData();
617
+ setRefreshing(false);
618
+ };
619
+
620
+ return (
621
+ <PageTransition type="slide" direction="up">
622
+ <div className="h-screen flex flex-col">
623
+ <NetworkAwareContent
624
+ showOnSlow={<SimpleDashboardHeader />}
625
+ showOnFast={<RichDashboardHeader />}
626
+ >
627
+ <DashboardHeader />
628
+ </NetworkAwareContent>
629
+
630
+ <PullToRefresh onRefresh={handleRefresh} className="flex-1">
631
+ <VirtualScrollList
632
+ items={data}
633
+ itemHeight={120}
634
+ renderItem={(item, index) => (
635
+ <div className="p-4 border-b">
636
+ <div className="flex items-center space-x-3">
637
+ <LazyImage
638
+ src={item.avatar}
639
+ alt={item.name}
640
+ className="w-12 h-12 rounded-full"
641
+ placeholder="blur"
642
+ />
643
+ <div>
644
+ <h3 className="font-semibold">{item.name}</h3>
645
+ <p className="text-sm text-gray-500">{item.status}</p>
646
+ </div>
647
+ </div>
648
+ </div>
649
+ )}
650
+ onEndReached={loadMoreData}
651
+ mobileOptimized={true}
652
+ />
653
+ </PullToRefresh>
654
+ </div>
655
+ </PageTransition>
656
+ );
657
+ }
658
+ ```
659
+
660
+ ### Swipeable Card List with Actions
661
+
662
+ ```tsx
663
+ import {
664
+ SwipeableCard,
665
+ LazyImage,
666
+ Button,
667
+ } from "@digilogiclabs/saas-factory-ui";
668
+
669
+ function MessageList({ messages }) {
670
+ return (
671
+ <div className="space-y-2">
672
+ {messages.map((message) => (
673
+ <SwipeableCard
674
+ key={message.id}
675
+ leftActions={[
676
+ {
677
+ id: "archive",
678
+ label: "Archive",
679
+ icon: "📁",
680
+ backgroundColor: "#10B981",
681
+ onAction: () => archiveMessage(message.id),
682
+ },
683
+ ]}
684
+ rightActions={[
685
+ {
686
+ id: "delete",
687
+ label: "Delete",
688
+ icon: "🗑️",
689
+ backgroundColor: "#EF4444",
690
+ onAction: () => deleteMessage(message.id),
691
+ },
692
+ ]}
693
+ threshold={100}
694
+ hapticFeedback={true}
695
+ >
696
+ <div className="flex items-center p-4 bg-white rounded-lg shadow">
697
+ <LazyImage
698
+ src={message.sender.avatar}
699
+ alt={message.sender.name}
700
+ className="w-12 h-12 rounded-full mr-3"
701
+ placeholder="skeleton"
702
+ />
703
+ <div className="flex-1">
704
+ <h4 className="font-semibold">{message.sender.name}</h4>
705
+ <p className="text-gray-600 truncate">{message.preview}</p>
706
+ </div>
707
+ <span className="text-xs text-gray-400">{message.time}</span>
708
+ </div>
709
+ </SwipeableCard>
710
+ ))}
711
+ </div>
712
+ );
713
+ }
714
+ ```
715
+
716
+ ### Progressive Image Gallery
717
+
718
+ ```tsx
719
+ import {
720
+ ProgressiveImage,
721
+ VirtualScrollList,
722
+ } from "@digilogiclabs/saas-factory-ui";
723
+
724
+ function ImageGallery({ images }) {
725
+ return (
726
+ <VirtualScrollList
727
+ items={images}
728
+ itemHeight={300}
729
+ renderItem={(image, index) => (
730
+ <div className="p-2">
731
+ <ProgressiveImage
732
+ lowQualitySrc={image.thumbnail}
733
+ highQualitySrc={image.fullSize}
734
+ alt={image.description}
735
+ className="w-full h-64 object-cover rounded-lg"
736
+ mobileStrategy="blur-up"
737
+ transition="crossfade"
738
+ networkAware={true}
739
+ />
740
+ </div>
741
+ )}
742
+ containerHeight={600}
743
+ mobileOptimized={true}
744
+ />
745
+ );
746
+ }
747
+ ```
748
+
749
+ ## 🌐 Network-Aware Development
750
+
751
+ ### Connection-Based Content Delivery
752
+
753
+ ```tsx
754
+ import {
755
+ NetworkAwareContent,
756
+ useNetworkInfo,
757
+ } from "@digilogiclabs/saas-factory-ui";
758
+
759
+ function AdaptiveApp() {
760
+ const networkInfo = useNetworkInfo();
761
+
762
+ return (
763
+ <div>
764
+ <NetworkAwareContent
765
+ fastThreshold={["4g", "fast"]}
766
+ slowThreshold={["2g", "3g", "slow"]}
767
+ showOnFast={
768
+ <div>
769
+ <HighResolutionImages />
770
+ <AnimatedComponents />
771
+ <VideoContent />
772
+ </div>
773
+ }
774
+ showOnSlow={
775
+ <div>
776
+ <CompressedImages />
777
+ <StaticComponents />
778
+ <TextContent />
779
+ </div>
780
+ }
781
+ showOnOffline={<OfflineFallback />}
782
+ respectSaveData={true}
783
+ onNetworkChange={(info) => {
784
+ console.log("Network changed:", info);
785
+ // Adjust app behavior based on network
786
+ }}
787
+ >
788
+ <DefaultContent />
789
+ </NetworkAwareContent>
790
+ </div>
791
+ );
792
+ }
793
+ ```
794
+
795
+ ### Offline-First Architecture
796
+
797
+ ```tsx
798
+ import {
799
+ OfflineWrapper,
800
+ useOfflineState,
801
+ useCache,
802
+ } from "@digilogiclabs/saas-factory-ui";
803
+
804
+ function OfflineCapableComponent() {
805
+ const isOnline = useOfflineState();
806
+ const { get, set } = useCache("user-preferences", 3600000);
807
+
808
+ return (
809
+ <OfflineWrapper
810
+ cacheStrategy="stale-while-revalidate"
811
+ cacheKey="dashboard-data"
812
+ showOfflineIndicator={true}
813
+ enableServiceWorker={true}
814
+ onOffline={() => console.log("Gone offline")}
815
+ onOnline={() => console.log("Back online")}
816
+ fallback={
817
+ <div className="text-center p-8">
818
+ <h3>You're offline</h3>
819
+ <p>Some features may not be available</p>
820
+ </div>
821
+ }
822
+ >
823
+ <div>
824
+ <h2>Dashboard {isOnline ? "🟢" : "🔴"}</h2>
825
+ <DashboardContent />
826
+ </div>
827
+ </OfflineWrapper>
828
+ );
829
+ }
830
+ ```
831
+
832
+ ## 🎨 Theming & Styling
833
+
834
+ ### Custom Theme Configuration
835
+
836
+ Create a custom theme by extending the default CSS variables:
837
+
838
+ ```css
839
+ /* custom-theme.css */
840
+ :root {
841
+ /* Primary colors */
842
+ --primary: 262 83% 58%; /* Purple */
843
+ --primary-foreground: 0 0% 98%;
844
+
845
+ /* Secondary colors */
846
+ --secondary: 220 14% 96%;
847
+ --secondary-foreground: 220 9% 46%;
848
+
849
+ /* Accent colors */
850
+ --accent: 262 83% 58%;
851
+ --accent-foreground: 0 0% 98%;
852
+
853
+ /* Custom border radius */
854
+ --radius: 0.75rem;
855
+ }
856
+
857
+ /* Dark mode overrides */
858
+ .dark {
859
+ --primary: 262 83% 58%;
860
+ --primary-foreground: 0 0% 98%;
861
+ --background: 224 71% 4%;
862
+ --foreground: 213 31% 91%;
863
+ }
864
+ ```
865
+
866
+ ## 📝 Migration Guide
867
+
868
+ ### From v0.12.x to v0.13.0
869
+
870
+ #### New Dependencies (Optional)
871
+
872
+ For full functionality, install additional dependencies:
873
+
874
+ ```bash
875
+ # For React Native projects
876
+ npm install @react-native-community/netinfo
877
+ npm install @react-native-async-storage/async-storage
878
+ npm install expo-haptics
879
+
880
+ # These are optional and only needed if using specific components
881
+ ```
882
+
883
+ #### Breaking Changes
884
+
885
+ - None. All new components are additive.
886
+
887
+ #### New Features Available
888
+
889
+ - Advanced mobile interactions (PageTransition, SwipeableCard, PullToRefresh)
890
+ - Performance optimization components (LazyImage, ProgressiveImage, VirtualScrollList)
891
+ - Network and offline support (NetworkAwareContent, OfflineWrapper)
892
+ - New hooks (useNetworkInfo, useOfflineState, useCache)
893
+
894
+ ## 🏗 Development Status
895
+
896
+ ### ✅ Completed (v0.13.0) - Mobile-First Optimization Release
897
+
898
+ **Advanced Mobile Interactions**
899
+
900
+ - PageTransition - Smooth page transitions with gesture support
901
+ - SwipeableCard - Touch-friendly swipe gestures with haptic feedback
902
+ - PullToRefresh - Native pull-to-refresh functionality
903
+
904
+ **Performance Optimization**
905
+
906
+ - LazyImage - Intelligent lazy loading with WebP support
907
+ - ProgressiveImage - Quality-aware progressive image loading
908
+ - VirtualScrollList - Memory-efficient virtual scrolling
909
+
910
+ **Network & Offline Support**
911
+
912
+ - ✅ NetworkAwareContent - Smart content delivery based on network conditions
913
+ - OfflineWrapper - Comprehensive offline support with caching strategies
914
+ - ✅ Network detection hooks and utilities
915
+
916
+ **Developer Experience**
917
+
918
+ - Cross-platform architecture (Web + React Native)
919
+ - Full TypeScript support with platform-specific types
920
+ - ✅ Accessibility-first design (WCAG 2.2 AA compliant)
921
+ - ✅ Tree-shakeable exports and optimized bundle sizes
922
+ - Comprehensive documentation and examples
923
+
924
+ ### ✅ Completed (v1.1.0) - Security Validators & Animation Presets
925
+
926
+ **Security Validators**
927
+
928
+ - `noHtml` - Block HTML tags in text fields (contact forms, comments)
929
+ - `noUrls` - Block protocol-prefixed URLs (https://, http://, ftp://, www.)
930
+ - ✅ `noLinks` - Block all links including bare domains (stricter than noUrls)
931
+
932
+ **Framer Motion Presets**
933
+
934
+ - ✅ `DURATIONS` - Standardized animation durations (instant/fast/normal/slow/slower)
935
+ - `EASINGS` - Easing curves including cubic-bezier and spring configs
936
+ - ✅ `VARIANTS` - 10 reusable animation variants (fadeIn, slideUp, scale, cardReveal, etc.)
937
+ - `HOVER` / `HOVER_TRANSITION` - Consistent hover effect presets
938
+ - ✅ `STAGGER_CONTAINERS` / `STAGGER_ITEMS` - Staggered children animations
939
+ - ✅ `VIEWPORT` - Scroll-trigger viewport settings
940
+ - `DISTANCES` - Movement distance presets (sm/md/lg/xl)
941
+ - Helper functions: `createTransition()`, `createSlideVariant()`, `mergeVariants()`
942
+
943
+ ### 🚧 Coming Next (v1.2.0)
944
+
945
+ **Enhanced Authentication Components**
946
+
947
+ - 🔄 MobileAuthForm with biometric authentication
948
+ - 🔄 MobileUserMenu with gesture-enabled navigation
949
+ - 🔄 Social login optimizations
950
+
951
+ **Mobile Payment Optimization**
952
+
953
+ - 🔄 MobileCheckout with Apple Pay/Google Pay
954
+ - 🔄 MobileBilling dashboard
955
+ - 🔄 MobilePricing with comparison tables
956
+
957
+ ### 📋 Future Roadmap
958
+
959
+ - Advanced UI components (BottomSheet, InfiniteScroll, FAB)
960
+ - Enhanced theming system with brand color extraction
961
+ - Real-time components with WebSocket integration
962
+ - PWA optimization features
963
+ - Advanced accessibility features
964
+ - Comprehensive Storybook documentation
965
+
966
+ ## 🚀 Performance Metrics
967
+
968
+ ### Bundle Sizes (v0.13.0)
969
+
970
+ - **Main Bundle**: 270KB ESM (295KB CJS) + 73KB CSS
971
+ - **Web Bundle**: 295KB optimized for web platforms
972
+ - **Native Bundle**: 18KB optimized for React Native
973
+ - **Tree-shakeable**: Import only what you need
974
+
975
+ ### Performance Targets
976
+
977
+ - **Bundle Size**: < 250KB gzipped ✅ (Optimized)
978
+ - **Load Time**: < 3s on 3G networks
979
+ - **First Paint**: < 1.5s
980
+ - **Interaction Ready**: < 2.5s ✅
981
+ - **Accessibility Score**: 95+ Lighthouse ✅
982
+
983
+ ## 🔧 Development & Contributing
984
+
985
+ ### Local Development
986
+
987
+ ```bash
988
+ # Clone the repository
989
+ git clone https://github.com/DigiLogicLabs/saas-factory-ui
990
+ cd saas-factory-ui
991
+
992
+ # Install dependencies
993
+ npm install
994
+
995
+ # Build the package
996
+ npm run build
997
+
998
+ # Run tests
999
+ npm run test
1000
+
1001
+ # Type check
1002
+ npm run type-check
1003
+
1004
+ # Lint
1005
+ npm run lint
1006
+
1007
+ # Link for local testing
1008
+ npm link
1009
+
1010
+ # In your test project
1011
+ npm link @digilogiclabs/saas-factory-ui
1012
+ ```
1013
+
1014
+ ### Testing Your Changes
1015
+
1016
+ 1. Build the package: `npm run build`
1017
+ 2. Test in a Next.js app with mobile interactions
1018
+ 3. Test in a React Native/Expo app
1019
+ 4. Verify TypeScript types work correctly
1020
+ 5. Test offline/online scenarios
1021
+ 6. Verify accessibility with screen readers
1022
+
1023
+ ## 🐛 Troubleshooting
1024
+
1025
+ ### Quick Diagnostic Commands
1026
+
1027
+ ```bash
1028
+ # Check if package is installed correctly
1029
+ npm ls @digilogiclabs/saas-factory-ui
1030
+
1031
+ # Check package contents
1032
+ ls node_modules/@digilogiclabs/saas-factory-ui/dist/
1033
+
1034
+ # Verify CSS file exists
1035
+ find node_modules/@digilogiclabs/saas-factory-ui -name "*.css"
1036
+
1037
+ # Test network features (in browser console)
1038
+ navigator.onLine // Should return true/false
1039
+ navigator.connection // Should show connection info
1040
+ ```
1041
+
1042
+ ### Common Solutions
1043
+
1044
+ 1. **Clear cache**: `rm -rf .next node_modules package-lock.json && npm install`
1045
+ 2. **Rebuild**: `npm run build` in your project
1046
+ 3. **Check imports**: Verify import paths match package exports
1047
+ 4. **Update dependencies**: Ensure compatible React/Next.js versions
1048
+ 5. **Network features not working**: Check browser support and permissions
1049
+ 6. **Haptic feedback not working**: Verify device and browser support
1050
+
1051
+ ### Mobile-Specific Issues
1052
+
1053
+ 1. **Gestures not working**: Ensure `touch-action` CSS is not preventing interactions
1054
+ 2. **Performance issues**: Enable `mobileOptimized` props where available
1055
+ 3. **Network detection not working on mobile**: Check app permissions and service worker registration
1056
+
1057
+ ## 📄 License
1058
+
1059
+ MIT © [DigiLogic Labs](https://github.com/DigiLogicLabs)
1060
+
1061
+ ## 🔗 Links
1062
+
1063
+ - [Documentation](https://github.com/DigiLogicLabs/saas-factory-ui)
1064
+ - [NPM Package](https://www.npmjs.com/package/@digilogiclabs/saas-factory-ui)
1065
+ - [Issues](https://github.com/DigiLogicLabs/saas-factory-ui/issues)
1066
+ - [Changelog](CHANGELOG.md)
1067
+
1068
+ ---
1069
+
1070
+ **Current Version**: 1.1.0
1071
+ **Platforms**: Web (Next.js/React) + React Native/Expo
1072
+ **License**: MIT