@djangocfg/ui-nextjs 2.1.320 → 2.1.322

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
@@ -6,13 +6,11 @@
6
6
 
7
7
  # @djangocfg/ui-nextjs
8
8
 
9
- Next.js UI library extending `@djangocfg/ui-core` with 69+ components built on Radix UI + Tailwind CSS v4.
9
+ Next-specific runtime for DjangoCFG: theme provider, PWA install support, and browser-storage hooks.
10
10
 
11
- All navigation components are **locale-aware** via `next-intl`links automatically include the locale prefix (e.g. `/ru/dashboard`).
11
+ UI primitives (Button, Card, Sidebar, Pagination, Breadcrumb, etc.) live in [`@djangocfg/ui-core`](../ui-core)they're framework-agnostic and don't belong here. Import them from there directly.
12
12
 
13
- **Part of [DjangoCFG](https://djangocfg.com)** — modern Django framework for production-ready SaaS applications.
14
-
15
- **[Live Demo & Props](https://djangocfg.com/demo/)**
13
+ **Part of [DjangoCFG](https://djangocfg.com).**
16
14
 
17
15
  ## Install
18
16
 
@@ -20,291 +18,58 @@ All navigation components are **locale-aware** via `next-intl` — links automat
20
18
  pnpm add @djangocfg/ui-nextjs
21
19
  ```
22
20
 
23
- Peer dependencies: `next`, `next-intl`, `react`, `tailwindcss`.
24
-
25
- ## Architecture
26
-
27
- ```
28
- @djangocfg/ui-nextjs
29
- ├── Re-exports everything from @djangocfg/ui-core (components + hooks)
30
- ├── + Next.js locale-aware components (11)
31
- ├── + Navigation hooks (useNavigation, useRouter, usePathname)
32
- ├── + Browser storage hooks (2)
33
- ├── + Blocks, Theme, Animations
34
- ```
35
-
36
- | Package | Use Case |
37
- |---------|----------|
38
- | `@djangocfg/ui-core` | Electron, Vite, CRA, any React app |
39
- | `@djangocfg/ui-nextjs` | Next.js apps (includes ui-core + locale-aware navigation) |
40
-
41
- ## Components
42
-
43
- ### From ui-core (60)
44
- All components from `@djangocfg/ui-core` are re-exported.
45
-
46
- ### Next.js Specific
47
-
48
- | Component | Description |
49
- |-----------|-------------|
50
- | `Sidebar` | Collapsible sidebar; `SidebarTrigger` shows an OS-aware tooltip (`⌘+B` / `Ctrl+B`); `SidebarMenuButton` accepts `tooltip` for icon-rail hints |
51
- | `Breadcrumb` | Breadcrumb primitives (uses ui-core `<Link>`) |
52
- | `BreadcrumbNavigation` | High-level breadcrumb component |
53
- | `Pagination` | Pagination link primitives |
54
- | `SSRPagination` | Server-compatible pagination |
55
- | `DropdownMenu` | Local override of ui-core `DropdownMenu` (kept for legacy ui-nextjs callers) |
56
-
57
- > **Links**: use `<Link>` and `<ButtonLink>` from `@djangocfg/ui-core/components` directly.
58
- > Mounted via `NextLinkProvider` (in `BaseApp` from `@djangocfg/layouts`), they
59
- > render through `next/link` — so prefetch / RSC handling work as expected.
60
-
61
- ### MultiSelect Pro
62
- `MultiSelectPro` `MultiSelectProAsync` — Advanced multi-select with async loading
63
-
64
- ### Blocks (7)
65
- `Hero` `SuperHero` `SplitHero` `ArticleCard` `FeatureSection` `CTASection` `StatsSection`
66
-
67
- ```tsx
68
- import { Hero } from '@djangocfg/ui-nextjs/blocks';
69
- ```
70
-
71
- ## Hooks
72
-
73
- ### Navigation (locale-aware)
74
-
75
- | Hook | Description |
76
- |------|-------------|
77
- | `useNavigation` | Returns `{ router, pathname, redirect }` — all locale-aware |
78
- | `useRouter` | Locale-aware router (`router.push('/page')` → `/ru/page`) |
79
- | `usePathname` | Current pathname without locale prefix |
80
-
81
- ```tsx
82
- import { useNavigation } from '@djangocfg/ui-nextjs/hooks';
83
-
84
- function MyComponent() {
85
- const { router, pathname } = useNavigation();
86
- // pathname: "/dashboard" (not "/ru/dashboard")
87
- // router.push('/settings') → navigates to /ru/settings
88
- }
89
- ```
90
-
91
- ### From ui-core (re-exported)
92
-
93
- All hooks from `@djangocfg/ui-core/hooks` are available. Common examples:
94
-
95
- | Hook | Description |
96
- |------|-------------|
97
- | `useMediaQuery` | Responsive breakpoints |
98
- | `useIsMobile` | Mobile detection |
99
- | `useShortcutModLabel` | `⌘` vs `Ctrl` labels for shortcut tooltips |
100
- | `useCopy` | Copy to clipboard |
101
- | `useCountdown` | Countdown timer |
102
- | `useDebounce` | Debounce values |
103
- | `useDebouncedCallback` | Debounced callbacks |
104
- | `useImageLoader` | Image loading state |
105
- | `useToast` / `toast` | Toast notifications (Sonner) |
106
- | `useEventListener` | Event bus |
107
- | `useDebugTools` | Debug utilities |
108
- | `useHotkey` | Keyboard shortcuts |
109
- | `useBrowserDetect` | Browser detection |
110
- | `useDeviceDetect` | Device detection |
111
-
112
- ### Next.js Specific (3)
113
-
114
- | Hook | Description |
115
- |------|-------------|
116
- | `useResolvedTheme` | Light/dark theme resolution (next-themes) |
117
- | `useLocalStorage` | Persistent state in localStorage |
118
- | `useSessionStorage` | Persistent state in sessionStorage |
119
-
120
- ## Dialog Service
121
-
122
- The dialog service from ui-core is available for replacing native dialogs:
123
-
124
- ```tsx
125
- import { DialogProvider, useDialog, dialog } from '@djangocfg/ui-core/lib/dialog-service';
126
- ```
127
-
128
- See ui-core README for full documentation.
129
-
130
- ## Usage
131
-
132
- ```tsx
133
- import {
134
- Button, ButtonLink, Card, Input, Sidebar
135
- } from '@djangocfg/ui-nextjs';
136
- import { useNavigate } from '@djangocfg/ui-core/hooks';
137
- import { useLocalStorage } from '@djangocfg/ui-nextjs/hooks';
138
-
139
- function Example() {
140
- const { navigate } = useNavigate();
141
- const [saved, setSaved] = useLocalStorage('form', null);
142
-
143
- return (
144
- <Sidebar>
145
- <Card>
146
- <Input placeholder="Email" />
147
- <Button onClick={() => navigate('/dashboard')}>
148
- Submit
149
- </Button>
150
- <ButtonLink href="/docs" variant="outline">
151
- Documentation
152
- </ButtonLink>
153
- </Card>
154
- </Sidebar>
155
- );
156
- }
157
- ```
158
-
159
- ### `<ButtonLink>` examples
160
-
161
- `<ButtonLink>` lives in `@djangocfg/ui-core/components`. In Next.js apps it renders
162
- through `next/link` automatically (via `NextLinkProvider` mounted in `BaseApp`).
163
- In Wails / Electron / Vite consumers it falls back to a plain `<a>` driven by
164
- `useNavigate`.
165
-
166
- ```tsx
167
- import { ButtonLink } from '@djangocfg/ui-core/components';
168
- import { ArrowLeft, Settings } from 'lucide-react';
169
-
170
- <ButtonLink href="/dashboard">Dashboard</ButtonLink>
171
-
172
- <ButtonLink href="/settings" variant="outline" size="sm">
173
- <Settings className="h-4 w-4 mr-2" />
174
- Settings
175
- </ButtonLink>
176
-
177
- <ButtonLink href="/list" variant="ghost" size="icon">
178
- <ArrowLeft className="h-4 w-4" />
179
- </ButtonLink>
180
-
181
- <ButtonLink href="/page" prefetch={false} replace>
182
- Navigate (replaceState)
183
- </ButtonLink>
184
- ```
185
-
186
- ## Styling
187
-
188
- ```tsx
189
- // Import global styles
190
- import '@djangocfg/ui-nextjs/styles/globals';
191
- ```
192
-
193
- ## Logger
21
+ ## What's inside
194
22
 
195
- Universal logger with consola + zustand for Console panel integration.
196
-
197
- ```tsx
198
- import { createLogger, createMediaLogger } from '@djangocfg/ui-nextjs/lib';
23
+ | Subpath | Purpose |
24
+ |---|---|
25
+ | `@djangocfg/ui-nextjs/theme` | `ThemeProvider` (next-themes), `ThemeToggle`, `useResolvedTheme` |
26
+ | `@djangocfg/ui-nextjs/pwa` | `PwaProvider`, `A2HSHint`, `useInstall`, `useIsPWA`, install detection helpers |
27
+ | `@djangocfg/ui-nextjs/hooks` | `useLocalStorage`, `useSessionStorage` and other Next-runtime-only hooks |
199
28
 
200
- // Basic logger
201
- const log = createLogger('MyComponent');
202
- log.info('User logged in', { userId: 123 });
203
- log.error('Failed to load', { error });
204
-
205
- // Media logger (with seek/buffer helpers)
206
- const mediaLog = createMediaLogger('AudioPlayer');
207
- mediaLog.load(src, 'stream');
208
- mediaLog.seek(from, to, duration);
209
- mediaLog.buffer(buffered, duration);
210
- ```
211
-
212
- ## Exports
213
-
214
- | Path | Content |
215
- |------|---------|
216
- | `@djangocfg/ui-nextjs` | All components & hooks |
217
- | `@djangocfg/ui-nextjs/components` | Components only |
218
- | `@djangocfg/ui-nextjs/hooks` | Hooks only |
219
- | `@djangocfg/ui-nextjs/blocks` | Landing page blocks |
220
- | `@djangocfg/ui-nextjs/lib` | Logger, utilities |
221
- | `@djangocfg/ui-nextjs/theme` | ThemeProvider, ThemeToggle |
222
- | `@djangocfg/ui-nextjs/animations` | Background animations |
223
- | `@djangocfg/ui-nextjs/styles` | CSS |
29
+ That's it. Anything else you might be looking for is in `@djangocfg/ui-core`.
224
30
 
225
31
  ## Theme
226
32
 
227
33
  ```tsx
228
34
  import { ThemeProvider, ThemeToggle } from '@djangocfg/ui-nextjs/theme';
229
35
 
230
- function App({ children }) {
231
- return (
232
- <ThemeProvider>
233
- {children}
234
- <ThemeToggle />
235
- </ThemeProvider>
236
- );
237
- }
36
+ <ThemeProvider>
37
+ {children}
38
+ <ThemeToggle />
39
+ </ThemeProvider>
238
40
  ```
239
41
 
240
- ## Tailwind v4 Notes
241
-
242
- - Arbitrary values (`h-[80px]`) may not work — use inline styles
243
- - Opacity modifiers (`bg-background/80`) broken with HSL — use inline styles
244
- - Define spacing/z-index in `@theme` block
245
-
246
- ## PWA Install
247
-
248
- Full Progressive Web App installation support — iOS/Android/Desktop, Add to Home Screen prompt, page resume.
42
+ ## PWA
249
43
 
250
44
  ```tsx
251
- import { PwaProvider, A2HSHint, PWAPageResumeManager, useInstall } from '@djangocfg/ui-nextjs/pwa';
45
+ import { PwaProvider, A2HSHint, useInstall } from '@djangocfg/ui-nextjs/pwa';
252
46
 
253
- // Wrap your app
254
- <PwaProvider enabled={true}>
47
+ <PwaProvider enabled>
255
48
  {children}
256
49
  <A2HSHint resetAfterDays={7} delayMs={3000} logo="/logo192.png" />
257
- <PWAPageResumeManager enabled={true} />
258
50
  </PwaProvider>
259
51
 
260
- // In any component
261
52
  function InstallButton() {
262
- const { canPrompt, install, isInstalled, isIOS, isAndroid } = useInstall();
263
- if (isInstalled || (!canPrompt && !isIOS)) return null;
264
- return <button onClick={install}>Install App</button>;
53
+ const { canPrompt, install, isInstalled } = useInstall();
54
+ if (isInstalled || !canPrompt) return null;
55
+ return <button onClick={install}>Install</button>;
265
56
  }
266
57
  ```
267
58
 
268
- ### Hooks & Utilities
59
+ ## Browser storage
269
60
 
270
61
  ```tsx
271
- import { useIsPWA, useInstall } from '@djangocfg/ui-nextjs/pwa';
272
-
273
- const isPWA = useIsPWA(); // is running as installed PWA
274
- const { isIOS, isAndroid, canPrompt } = useInstall();
275
- ```
276
-
277
- ```tsx
278
- import {
279
- isStandalone, // window.matchMedia('display-mode: standalone')
280
- isStandaloneReliable, // standalone + navigator.standalone
281
- isMobileDevice, // iOS or Android
282
- hasValidManifest, // checks <link rel="manifest">
283
- clearAllPWAInstallData, // reset localStorage flags
284
- } from '@djangocfg/ui-nextjs/pwa';
285
- ```
286
-
287
- ### Guide Components
288
-
289
- | Component | Description |
290
- |-----------|-------------|
291
- | `IOSGuide` | Step-by-step iOS Safari "Add to Home Screen" guide |
292
- | `DesktopGuide` | Desktop Chrome/Edge install guide |
293
- | `A2HSHint` | Floating hint bubble (auto-shows on eligible devices) |
294
-
295
- ### Subpath Import
62
+ import { useLocalStorage } from '@djangocfg/ui-nextjs/hooks';
296
63
 
297
- ```tsx
298
- import { ... } from '@djangocfg/ui-nextjs/pwa';
64
+ const [draft, setDraft] = useLocalStorage('contact-form', null);
299
65
  ```
300
66
 
301
67
  ## Requirements
302
68
 
303
- - Next.js >= 16
304
- - React >= 19
305
- - Tailwind CSS >= 4
306
- - next-intl >= 4
69
+ - Next.js 16
70
+ - React 19
71
+ - Tailwind CSS 4 (for theme tokens consumed by ui-core components)
307
72
 
308
73
  ---
309
74
 
310
- **[Full documentation & examples](https://djangocfg.com/demo/)**
75
+ **[djangocfg.com](https://djangocfg.com)**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-nextjs",
3
- "version": "2.1.320",
3
+ "version": "2.1.322",
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",
@@ -49,16 +49,6 @@
49
49
  "import": "./src/hooks/index.ts",
50
50
  "require": "./src/hooks/index.ts"
51
51
  },
52
- "./blocks": {
53
- "types": "./src/blocks/index.ts",
54
- "import": "./src/blocks/index.ts",
55
- "require": "./src/blocks/index.ts"
56
- },
57
- "./animations": {
58
- "types": "./src/animations/index.ts",
59
- "import": "./src/animations/index.ts",
60
- "require": "./src/animations/index.ts"
61
- },
62
52
  "./theme": {
63
53
  "types": "./src/theme/index.ts",
64
54
  "import": "./src/theme/index.ts",
@@ -85,11 +75,11 @@
85
75
  "check": "tsc --noEmit"
86
76
  },
87
77
  "peerDependencies": {
88
- "@djangocfg/api": "^2.1.320",
89
- "@djangocfg/i18n": "^2.1.320",
90
- "@djangocfg/nextjs": "^2.1.320",
91
- "@djangocfg/ui-core": "^2.1.320",
92
- "@djangocfg/ui-tools": "^2.1.320",
78
+ "@djangocfg/api": "^2.1.322",
79
+ "@djangocfg/i18n": "^2.1.322",
80
+ "@djangocfg/nextjs": "^2.1.322",
81
+ "@djangocfg/ui-core": "^2.1.322",
82
+ "@djangocfg/ui-tools": "^2.1.322",
93
83
  "@types/react": "^19.1.0",
94
84
  "@types/react-dom": "^19.1.0",
95
85
  "consola": "^3.4.2",
@@ -112,7 +102,7 @@
112
102
  "react-chartjs-2": "^5.3.0"
113
103
  },
114
104
  "devDependencies": {
115
- "@djangocfg/typescript-config": "^2.1.320",
105
+ "@djangocfg/typescript-config": "^2.1.322",
116
106
  "@radix-ui/react-dropdown-menu": "^2.1.16",
117
107
  "@radix-ui/react-slot": "^1.2.4",
118
108
  "@types/node": "^24.7.2",
package/src/index.ts CHANGED
@@ -1,20 +1,11 @@
1
1
  // ============================================================================
2
- // @djangocfg/ui-nextjs - Main Export File
2
+ // @djangocfg/ui-nextjs
3
+ //
4
+ // Next-specific runtime: theme provider (next-themes), PWA install support,
5
+ // browser-storage hooks. UI primitives live in @djangocfg/ui-core.
3
6
  // ============================================================================
4
7
 
5
8
  'use client';
6
9
 
7
- // Re-export everything from components
8
- export * from './components';
9
-
10
- // Re-export hooks
11
10
  export * from './hooks';
12
-
13
- // Re-export blocks
14
- export * from './blocks';
15
-
16
- // Re-export animations
17
- export * from './animations';
18
-
19
- // Re-export theme
20
- export * from './theme';
11
+ export * from './theme';