@djangocfg/ui-nextjs 2.1.227 → 2.1.229
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 +55 -0
- package/package.json +12 -6
- package/src/components/sidebar.tsx +3 -1
- package/src/pwa/@docs/README.md +92 -0
- package/src/pwa/@docs/research/ios-android-install-flows.md +576 -0
- package/src/pwa/README.md +235 -0
- package/src/pwa/components/A2HSHint.tsx +236 -0
- package/src/pwa/components/DesktopGuide.tsx +234 -0
- package/src/pwa/components/IOSGuide.tsx +29 -0
- package/src/pwa/components/IOSGuideDrawer.tsx +103 -0
- package/src/pwa/components/IOSGuideModal.tsx +103 -0
- package/src/pwa/components/PWAPageResumeManager.tsx +33 -0
- package/src/pwa/context/InstallContext.tsx +102 -0
- package/src/pwa/hooks/useInstallPrompt.ts +168 -0
- package/src/pwa/hooks/useIsPWA.ts +116 -0
- package/src/pwa/hooks/usePWAPageResume.ts +163 -0
- package/src/pwa/index.ts +80 -0
- package/src/pwa/types/components.ts +95 -0
- package/src/pwa/types/config.ts +29 -0
- package/src/pwa/types/index.ts +26 -0
- package/src/pwa/types/install.ts +38 -0
- package/src/pwa/types/platform.ts +29 -0
- package/src/pwa/utils/localStorage.ts +181 -0
- package/src/pwa/utils/logger.ts +149 -0
- package/src/pwa/utils/platform.ts +151 -0
package/README.md
CHANGED
|
@@ -241,6 +241,61 @@ function App({ children }) {
|
|
|
241
241
|
- Opacity modifiers (`bg-background/80`) broken with HSL — use inline styles
|
|
242
242
|
- Define spacing/z-index in `@theme` block
|
|
243
243
|
|
|
244
|
+
## PWA Install
|
|
245
|
+
|
|
246
|
+
Full Progressive Web App installation support — iOS/Android/Desktop, Add to Home Screen prompt, page resume.
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { PwaProvider, A2HSHint, PWAPageResumeManager, useInstall } from '@djangocfg/ui-nextjs/pwa';
|
|
250
|
+
|
|
251
|
+
// Wrap your app
|
|
252
|
+
<PwaProvider enabled={true}>
|
|
253
|
+
{children}
|
|
254
|
+
<A2HSHint resetAfterDays={7} delayMs={3000} logo="/logo192.png" />
|
|
255
|
+
<PWAPageResumeManager enabled={true} />
|
|
256
|
+
</PwaProvider>
|
|
257
|
+
|
|
258
|
+
// In any component
|
|
259
|
+
function InstallButton() {
|
|
260
|
+
const { canPrompt, install, isInstalled, isIOS, isAndroid } = useInstall();
|
|
261
|
+
if (isInstalled || (!canPrompt && !isIOS)) return null;
|
|
262
|
+
return <button onClick={install}>Install App</button>;
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Hooks & Utilities
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
import { useIsPWA, useInstall } from '@djangocfg/ui-nextjs/pwa';
|
|
270
|
+
|
|
271
|
+
const isPWA = useIsPWA(); // is running as installed PWA
|
|
272
|
+
const { isIOS, isAndroid, canPrompt } = useInstall();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import {
|
|
277
|
+
isStandalone, // window.matchMedia('display-mode: standalone')
|
|
278
|
+
isStandaloneReliable, // standalone + navigator.standalone
|
|
279
|
+
isMobileDevice, // iOS or Android
|
|
280
|
+
hasValidManifest, // checks <link rel="manifest">
|
|
281
|
+
clearAllPWAInstallData, // reset localStorage flags
|
|
282
|
+
} from '@djangocfg/ui-nextjs/pwa';
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Guide Components
|
|
286
|
+
|
|
287
|
+
| Component | Description |
|
|
288
|
+
|-----------|-------------|
|
|
289
|
+
| `IOSGuide` | Step-by-step iOS Safari "Add to Home Screen" guide |
|
|
290
|
+
| `DesktopGuide` | Desktop Chrome/Edge install guide |
|
|
291
|
+
| `A2HSHint` | Floating hint bubble (auto-shows on eligible devices) |
|
|
292
|
+
|
|
293
|
+
### Subpath Import
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
import { ... } from '@djangocfg/ui-nextjs/pwa';
|
|
297
|
+
```
|
|
298
|
+
|
|
244
299
|
## Requirements
|
|
245
300
|
|
|
246
301
|
- Next.js >= 16
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ui-nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.229",
|
|
4
4
|
"description": "Next.js UI component library with Radix UI primitives, Tailwind CSS styling, charts, and form components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui-components",
|
|
@@ -64,6 +64,11 @@
|
|
|
64
64
|
"import": "./src/theme/index.ts",
|
|
65
65
|
"require": "./src/theme/index.ts"
|
|
66
66
|
},
|
|
67
|
+
"./pwa": {
|
|
68
|
+
"types": "./src/pwa/index.ts",
|
|
69
|
+
"import": "./src/pwa/index.ts",
|
|
70
|
+
"require": "./src/pwa/index.ts"
|
|
71
|
+
},
|
|
67
72
|
"./types/*": "./src/types/*",
|
|
68
73
|
"./global": "./src/global.d.ts",
|
|
69
74
|
"./styles": "./src/styles/index.css"
|
|
@@ -80,10 +85,11 @@
|
|
|
80
85
|
"check": "tsc --noEmit"
|
|
81
86
|
},
|
|
82
87
|
"peerDependencies": {
|
|
83
|
-
"@djangocfg/api": "^2.1.
|
|
84
|
-
"@djangocfg/
|
|
85
|
-
"@djangocfg/
|
|
86
|
-
"@djangocfg/ui-
|
|
88
|
+
"@djangocfg/api": "^2.1.229",
|
|
89
|
+
"@djangocfg/i18n": "^2.1.229",
|
|
90
|
+
"@djangocfg/nextjs": "^2.1.229",
|
|
91
|
+
"@djangocfg/ui-core": "^2.1.229",
|
|
92
|
+
"@djangocfg/ui-tools": "^2.1.229",
|
|
87
93
|
"@types/react": "^19.1.0",
|
|
88
94
|
"@types/react-dom": "^19.1.0",
|
|
89
95
|
"consola": "^3.4.2",
|
|
@@ -106,7 +112,7 @@
|
|
|
106
112
|
"react-chartjs-2": "^5.3.0"
|
|
107
113
|
},
|
|
108
114
|
"devDependencies": {
|
|
109
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
115
|
+
"@djangocfg/typescript-config": "^2.1.229",
|
|
110
116
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
111
117
|
"@radix-ui/react-slot": "^1.2.4",
|
|
112
118
|
"@types/node": "^24.7.2",
|
|
@@ -366,7 +366,9 @@ const SidebarInset = React.forwardRef<
|
|
|
366
366
|
})
|
|
367
367
|
SidebarInset.displayName = "SidebarInset"
|
|
368
368
|
|
|
369
|
-
const SidebarInput
|
|
369
|
+
const SidebarInput: React.ForwardRefExoticComponent<
|
|
370
|
+
React.ComponentProps<typeof Input> & React.RefAttributes<HTMLInputElement>
|
|
371
|
+
> = React.forwardRef<
|
|
370
372
|
React.ElementRef<typeof Input>,
|
|
371
373
|
React.ComponentProps<typeof Input>
|
|
372
374
|
>(({ className, ...props }, ref) => {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# PWAInstall Documentation
|
|
2
|
+
|
|
3
|
+
Comprehensive documentation for the PWAInstall snippet.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
PWAInstall handles **Progressive Web App installation** on user devices (Add to Home Screen functionality).
|
|
8
|
+
|
|
9
|
+
**Responsibility**: Device installation only (not push notifications)
|
|
10
|
+
|
|
11
|
+
## Documentation Structure
|
|
12
|
+
|
|
13
|
+
### `/research/`
|
|
14
|
+
Research and best practices:
|
|
15
|
+
- **[ios-android-install-flows.md](./research/ios-android-install-flows.md)** - iOS vs Android PWA installation patterns, limitations, and best practices (2024-2025)
|
|
16
|
+
|
|
17
|
+
### `/architecture/`
|
|
18
|
+
Architecture and design:
|
|
19
|
+
- Coming soon: Architecture decisions, component design, state management
|
|
20
|
+
|
|
21
|
+
### `/legacy/`
|
|
22
|
+
Historical documentation:
|
|
23
|
+
- Old architecture analysis (before snippet split)
|
|
24
|
+
- Refactoring history
|
|
25
|
+
|
|
26
|
+
## Quick Navigation
|
|
27
|
+
|
|
28
|
+
### For Users
|
|
29
|
+
Start here if you want to use PWAInstall:
|
|
30
|
+
- [Main README](../README.md) - Quick start and API reference
|
|
31
|
+
- [Migration Guide](../../MIGRATION.md) - Migrating from old PWA snippet
|
|
32
|
+
|
|
33
|
+
### For Contributors
|
|
34
|
+
Start here if you want to understand or modify PWAInstall:
|
|
35
|
+
- [iOS/Android Install Flows](./research/ios-android-install-flows.md) - Platform-specific behavior
|
|
36
|
+
- [Architecture](./architecture/) - How it's built
|
|
37
|
+
|
|
38
|
+
### For Researchers
|
|
39
|
+
Start here if you want to understand PWA installation patterns:
|
|
40
|
+
- [Research](./research/) - Industry research and best practices
|
|
41
|
+
|
|
42
|
+
## Key Concepts
|
|
43
|
+
|
|
44
|
+
### Platform Asymmetry
|
|
45
|
+
|
|
46
|
+
| Aspect | Android Chrome | iOS Safari |
|
|
47
|
+
|--------|----------------|------------|
|
|
48
|
+
| Install API | `beforeinstallprompt` | ❌ No API |
|
|
49
|
+
| User effort | 1 tap | 3-4 taps |
|
|
50
|
+
| Detection | Event-based | Heuristic |
|
|
51
|
+
| Guidance | Optional | **Required** |
|
|
52
|
+
|
|
53
|
+
**PWAInstall handles this asymmetry transparently.**
|
|
54
|
+
|
|
55
|
+
### Components
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
A2HSHint (Unified hint)
|
|
59
|
+
├── Android → Native install prompt
|
|
60
|
+
└── iOS → Visual guide (IOSGuide)
|
|
61
|
+
├── Mobile → IOSGuideDrawer
|
|
62
|
+
└── Desktop → IOSGuideModal
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### State Management
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
useInstall() hook
|
|
69
|
+
├── Platform detection (isIOS, isAndroid, isSafari)
|
|
70
|
+
├── Installation state (isInstalled, canPrompt)
|
|
71
|
+
└── Install action (install())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Related Documentation
|
|
75
|
+
|
|
76
|
+
- **[PushNotifications Docs](../../PushNotifications/@docs/)** - Web push notifications (separate concern)
|
|
77
|
+
- **[Refactoring Summary](../../REFACTORING_SUMMARY.md)** - Why snippets were split
|
|
78
|
+
- **[Migration Guide](../../MIGRATION.md)** - How to migrate from old PWA snippet
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
When adding documentation:
|
|
83
|
+
1. **Research** → `/research/` - Industry patterns, browser behavior
|
|
84
|
+
2. **Architecture** → `/architecture/` - Design decisions, component structure
|
|
85
|
+
3. **Historical** → `/legacy/` - Old docs (keep for reference)
|
|
86
|
+
|
|
87
|
+
## Questions?
|
|
88
|
+
|
|
89
|
+
- Implementation questions → See [Main README](../README.md)
|
|
90
|
+
- Architecture questions → See [/architecture/](./architecture/)
|
|
91
|
+
- Platform behavior → See [/research/](./research/)
|
|
92
|
+
- Migration questions → See [Migration Guide](../../MIGRATION.md)
|