@djangocfg/layouts 1.0.6 → 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/package.json +5 -5
- package/src/layouts/AppLayout/AppLayout.tsx +132 -28
- package/src/layouts/AppLayout/components/ErrorBoundary.tsx +99 -0
- package/src/layouts/AppLayout/components/PageProgress.tsx +28 -11
- package/src/layouts/AppLayout/components/index.ts +1 -0
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthContext.tsx +1 -1
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthHelp.tsx +5 -5
- package/src/layouts/AppLayout/layouts/AuthLayout/AuthLayout.tsx +2 -2
- package/src/layouts/AppLayout/layouts/AuthLayout/IdentifierForm.tsx +2 -2
- package/src/layouts/AppLayout/layouts/PrivateLayout/components/DashboardHeader.tsx +1 -1
- package/src/layouts/AppLayout/layouts/PublicLayout/components/Footer.tsx +1 -1
- package/src/layouts/AppLayout/layouts/PublicLayout/components/MobileMenu.tsx +53 -36
- package/src/layouts/AppLayout/layouts/PublicLayout/components/Navigation.tsx +64 -52
- package/src/layouts/AppLayout/types/config.ts +22 -0
- package/src/layouts/ErrorLayout/ErrorLayout.tsx +169 -0
- package/src/layouts/ErrorLayout/errorConfig.tsx +152 -0
- package/src/layouts/ErrorLayout/index.ts +8 -0
- package/src/layouts/UILayout/README.md +267 -0
- package/src/layouts/UILayout/REFACTORING.md +331 -0
- package/src/layouts/UILayout/UIGuideApp.tsx +18 -0
- package/src/layouts/UILayout/UIGuideLanding.tsx +198 -0
- package/src/layouts/UILayout/UIGuideView.tsx +61 -0
- package/src/layouts/UILayout/UILayout.tsx +122 -0
- package/src/layouts/UILayout/components/AutoComponentDemo.tsx +77 -0
- package/src/layouts/UILayout/components/CategoryRenderer.tsx +45 -0
- package/src/layouts/UILayout/components/Header.tsx +114 -0
- package/src/layouts/UILayout/components/MobileOverlay.tsx +33 -0
- package/src/layouts/UILayout/components/Sidebar.tsx +195 -0
- package/src/layouts/UILayout/components/TailwindGuideRenderer.tsx +138 -0
- package/src/layouts/UILayout/config/ai-export.config.ts +80 -0
- package/src/layouts/UILayout/config/categories.config.tsx +114 -0
- package/src/layouts/UILayout/config/components/blocks.config.tsx +233 -0
- package/src/layouts/UILayout/config/components/data.config.tsx +308 -0
- package/src/layouts/UILayout/config/components/feedback.config.tsx +246 -0
- package/src/layouts/UILayout/config/components/forms.config.tsx +171 -0
- package/src/layouts/UILayout/config/components/hooks.config.tsx +131 -0
- package/src/layouts/UILayout/config/components/index.ts +69 -0
- package/src/layouts/UILayout/config/components/layout.config.tsx +133 -0
- package/src/layouts/UILayout/config/components/navigation.config.tsx +244 -0
- package/src/layouts/UILayout/config/components/overlay.config.tsx +561 -0
- package/src/layouts/UILayout/config/components/specialized.config.tsx +125 -0
- package/src/layouts/UILayout/config/components/types.ts +14 -0
- package/src/layouts/UILayout/config/index.ts +42 -0
- package/src/layouts/UILayout/config/tailwind.config.ts +77 -0
- package/src/layouts/UILayout/constants.ts +23 -0
- package/src/layouts/UILayout/context/ShowcaseContext.tsx +53 -0
- package/src/layouts/UILayout/context/index.ts +1 -0
- package/src/layouts/UILayout/index.ts +64 -0
- package/src/layouts/UILayout/types.ts +13 -0
- package/src/layouts/index.ts +5 -1
- package/src/snippets/Chat/types.ts +3 -4
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback Components Configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import {
|
|
7
|
+
Alert,
|
|
8
|
+
AlertDescription,
|
|
9
|
+
AlertTitle,
|
|
10
|
+
Progress,
|
|
11
|
+
Badge,
|
|
12
|
+
Avatar,
|
|
13
|
+
AvatarFallback,
|
|
14
|
+
AvatarImage,
|
|
15
|
+
Button,
|
|
16
|
+
useToast,
|
|
17
|
+
} from '@djangocfg/ui';
|
|
18
|
+
import type { ComponentConfig } from './types';
|
|
19
|
+
|
|
20
|
+
// Toast Preview Component
|
|
21
|
+
function ToastPreview() {
|
|
22
|
+
const { toast } = useToast();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="p-4 border rounded-md bg-muted/30">
|
|
26
|
+
<p className="text-sm text-muted-foreground mb-3">
|
|
27
|
+
Toast is a hook-based component. Click buttons to trigger toasts:
|
|
28
|
+
</p>
|
|
29
|
+
<div className="space-x-2">
|
|
30
|
+
<Button
|
|
31
|
+
onClick={() => {
|
|
32
|
+
toast({
|
|
33
|
+
title: "Success!",
|
|
34
|
+
description: "Your changes have been saved.",
|
|
35
|
+
});
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
Show Toast
|
|
39
|
+
</Button>
|
|
40
|
+
<Button
|
|
41
|
+
variant="destructive"
|
|
42
|
+
onClick={() => {
|
|
43
|
+
toast({
|
|
44
|
+
variant: "destructive",
|
|
45
|
+
title: "Error!",
|
|
46
|
+
description: "Something went wrong.",
|
|
47
|
+
});
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
Show Error Toast
|
|
51
|
+
</Button>
|
|
52
|
+
</div>
|
|
53
|
+
<p className="text-xs text-muted-foreground mt-3">
|
|
54
|
+
✓ Toaster is globally available via AppLayout
|
|
55
|
+
</p>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const FEEDBACK_COMPONENTS: ComponentConfig[] = [
|
|
61
|
+
{
|
|
62
|
+
name: 'Toast',
|
|
63
|
+
category: 'feedback',
|
|
64
|
+
description: 'Toast notifications for user feedback',
|
|
65
|
+
importPath: `import { useToast, Button } from '@djangocfg/ui';`,
|
|
66
|
+
example: `function Component() {
|
|
67
|
+
const { toast } = useToast();
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className="space-x-2">
|
|
71
|
+
<Button
|
|
72
|
+
onClick={() => {
|
|
73
|
+
toast({
|
|
74
|
+
title: "Success!",
|
|
75
|
+
description: "Your changes have been saved.",
|
|
76
|
+
});
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
Show Toast
|
|
80
|
+
</Button>
|
|
81
|
+
<Button
|
|
82
|
+
variant="destructive"
|
|
83
|
+
onClick={() => {
|
|
84
|
+
toast({
|
|
85
|
+
variant: "destructive",
|
|
86
|
+
title: "Error!",
|
|
87
|
+
description: "Something went wrong.",
|
|
88
|
+
});
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
Show Error Toast
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}`,
|
|
96
|
+
preview: <ToastPreview />,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'Alert',
|
|
100
|
+
category: 'feedback',
|
|
101
|
+
description: 'Alert messages for important information',
|
|
102
|
+
importPath: `import { Alert, AlertDescription, AlertTitle } from '@djangocfg/ui';`,
|
|
103
|
+
example: `<div className="space-y-4">
|
|
104
|
+
<Alert>
|
|
105
|
+
<AlertTitle>Heads up!</AlertTitle>
|
|
106
|
+
<AlertDescription>
|
|
107
|
+
You can add components to your app using the cli.
|
|
108
|
+
</AlertDescription>
|
|
109
|
+
</Alert>
|
|
110
|
+
|
|
111
|
+
<Alert variant="destructive">
|
|
112
|
+
<AlertTitle>Error</AlertTitle>
|
|
113
|
+
<AlertDescription>
|
|
114
|
+
Your session has expired. Please log in again.
|
|
115
|
+
</AlertDescription>
|
|
116
|
+
</Alert>
|
|
117
|
+
</div>`,
|
|
118
|
+
preview: (
|
|
119
|
+
<div className="space-y-4">
|
|
120
|
+
<Alert>
|
|
121
|
+
<AlertTitle>Heads up!</AlertTitle>
|
|
122
|
+
<AlertDescription>
|
|
123
|
+
You can add components to your app using the cli.
|
|
124
|
+
</AlertDescription>
|
|
125
|
+
</Alert>
|
|
126
|
+
|
|
127
|
+
<Alert variant="destructive">
|
|
128
|
+
<AlertTitle>Error</AlertTitle>
|
|
129
|
+
<AlertDescription>
|
|
130
|
+
Your session has expired. Please log in again.
|
|
131
|
+
</AlertDescription>
|
|
132
|
+
</Alert>
|
|
133
|
+
</div>
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'Progress',
|
|
138
|
+
category: 'feedback',
|
|
139
|
+
description: 'Progress bar for showing completion status',
|
|
140
|
+
importPath: `import { Progress } from '@djangocfg/ui';`,
|
|
141
|
+
example: `<div className="space-y-4 max-w-md">
|
|
142
|
+
<div>
|
|
143
|
+
<div className="flex justify-between mb-2">
|
|
144
|
+
<span className="text-sm">25%</span>
|
|
145
|
+
</div>
|
|
146
|
+
<Progress value={25} />
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div>
|
|
150
|
+
<div className="flex justify-between mb-2">
|
|
151
|
+
<span className="text-sm">50%</span>
|
|
152
|
+
</div>
|
|
153
|
+
<Progress value={50} />
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div>
|
|
157
|
+
<div className="flex justify-between mb-2">
|
|
158
|
+
<span className="text-sm">75%</span>
|
|
159
|
+
</div>
|
|
160
|
+
<Progress value={75} />
|
|
161
|
+
</div>
|
|
162
|
+
</div>`,
|
|
163
|
+
preview: (
|
|
164
|
+
<div className="space-y-4 max-w-md">
|
|
165
|
+
<div>
|
|
166
|
+
<div className="flex justify-between mb-2">
|
|
167
|
+
<span className="text-sm">25%</span>
|
|
168
|
+
</div>
|
|
169
|
+
<Progress value={25} />
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div>
|
|
173
|
+
<div className="flex justify-between mb-2">
|
|
174
|
+
<span className="text-sm">50%</span>
|
|
175
|
+
</div>
|
|
176
|
+
<Progress value={50} />
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div>
|
|
180
|
+
<div className="flex justify-between mb-2">
|
|
181
|
+
<span className="text-sm">75%</span>
|
|
182
|
+
</div>
|
|
183
|
+
<Progress value={75} />
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'Badge',
|
|
190
|
+
category: 'feedback',
|
|
191
|
+
description: 'Status badges for labels and categories',
|
|
192
|
+
importPath: `import { Badge } from '@djangocfg/ui';`,
|
|
193
|
+
example: `<div className="flex gap-2 flex-wrap">
|
|
194
|
+
<Badge>Default</Badge>
|
|
195
|
+
<Badge variant="secondary">Secondary</Badge>
|
|
196
|
+
<Badge variant="destructive">Destructive</Badge>
|
|
197
|
+
<Badge variant="outline">Outline</Badge>
|
|
198
|
+
</div>`,
|
|
199
|
+
preview: (
|
|
200
|
+
<div className="flex gap-2 flex-wrap">
|
|
201
|
+
<Badge>Default</Badge>
|
|
202
|
+
<Badge variant="secondary">Secondary</Badge>
|
|
203
|
+
<Badge variant="destructive">Destructive</Badge>
|
|
204
|
+
<Badge variant="outline">Outline</Badge>
|
|
205
|
+
</div>
|
|
206
|
+
),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'Avatar',
|
|
210
|
+
category: 'feedback',
|
|
211
|
+
description: 'User avatar with fallback support',
|
|
212
|
+
importPath: `import { Avatar, AvatarFallback, AvatarImage } from '@djangocfg/ui';`,
|
|
213
|
+
example: `<div className="flex gap-4">
|
|
214
|
+
<Avatar>
|
|
215
|
+
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
|
|
216
|
+
<AvatarFallback>CN</AvatarFallback>
|
|
217
|
+
</Avatar>
|
|
218
|
+
|
|
219
|
+
<Avatar>
|
|
220
|
+
<AvatarImage src="/nonexistent.png" alt="@user" />
|
|
221
|
+
<AvatarFallback>JD</AvatarFallback>
|
|
222
|
+
</Avatar>
|
|
223
|
+
|
|
224
|
+
<Avatar>
|
|
225
|
+
<AvatarFallback>AB</AvatarFallback>
|
|
226
|
+
</Avatar>
|
|
227
|
+
</div>`,
|
|
228
|
+
preview: (
|
|
229
|
+
<div className="flex gap-4">
|
|
230
|
+
<Avatar>
|
|
231
|
+
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
|
|
232
|
+
<AvatarFallback>CN</AvatarFallback>
|
|
233
|
+
</Avatar>
|
|
234
|
+
|
|
235
|
+
<Avatar>
|
|
236
|
+
<AvatarImage src="/nonexistent.png" alt="@user" />
|
|
237
|
+
<AvatarFallback>JD</AvatarFallback>
|
|
238
|
+
</Avatar>
|
|
239
|
+
|
|
240
|
+
<Avatar>
|
|
241
|
+
<AvatarFallback>AB</AvatarFallback>
|
|
242
|
+
</Avatar>
|
|
243
|
+
</div>
|
|
244
|
+
),
|
|
245
|
+
},
|
|
246
|
+
];
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form Components Configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
Input,
|
|
9
|
+
Checkbox,
|
|
10
|
+
Label,
|
|
11
|
+
RadioGroup,
|
|
12
|
+
RadioGroupItem,
|
|
13
|
+
Select,
|
|
14
|
+
SelectContent,
|
|
15
|
+
SelectItem,
|
|
16
|
+
SelectTrigger,
|
|
17
|
+
SelectValue,
|
|
18
|
+
Textarea,
|
|
19
|
+
Switch,
|
|
20
|
+
Slider,
|
|
21
|
+
} from '@djangocfg/ui';
|
|
22
|
+
import type { ComponentConfig } from './types';
|
|
23
|
+
|
|
24
|
+
export const FORM_COMPONENTS: ComponentConfig[] = [
|
|
25
|
+
{
|
|
26
|
+
name: 'Button',
|
|
27
|
+
category: 'forms',
|
|
28
|
+
description: 'Interactive button with multiple variants and sizes',
|
|
29
|
+
importPath: "import { Button } from '@djangocfg/ui';",
|
|
30
|
+
example: `<Button variant="default">Click me</Button>
|
|
31
|
+
<Button variant="destructive">Delete</Button>
|
|
32
|
+
<Button variant="outline">Outline</Button>
|
|
33
|
+
<Button variant="ghost">Ghost</Button>
|
|
34
|
+
<Button size="sm">Small</Button>
|
|
35
|
+
<Button size="lg">Large</Button>`,
|
|
36
|
+
preview: (
|
|
37
|
+
<div className="flex flex-wrap gap-3">
|
|
38
|
+
<Button variant="default">Click me</Button>
|
|
39
|
+
<Button variant="destructive">Delete</Button>
|
|
40
|
+
<Button variant="outline">Outline</Button>
|
|
41
|
+
<Button variant="ghost">Ghost</Button>
|
|
42
|
+
<Button size="sm">Small</Button>
|
|
43
|
+
<Button size="lg">Large</Button>
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Input',
|
|
49
|
+
category: 'forms',
|
|
50
|
+
description: 'Text input field with validation support',
|
|
51
|
+
importPath: "import { Input } from '@djangocfg/ui';",
|
|
52
|
+
example: `<Input type="text" placeholder="Enter text..." />
|
|
53
|
+
<Input type="email" placeholder="Email" />
|
|
54
|
+
<Input type="password" placeholder="Password" disabled />`,
|
|
55
|
+
preview: (
|
|
56
|
+
<div className="space-y-3 max-w-sm">
|
|
57
|
+
<Input type="text" placeholder="Enter text..." />
|
|
58
|
+
<Input type="email" placeholder="Email" />
|
|
59
|
+
<Input type="password" placeholder="Password" disabled />
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Checkbox',
|
|
65
|
+
category: 'forms',
|
|
66
|
+
description: 'Checkbox with label support',
|
|
67
|
+
importPath: "import { Checkbox, Label } from '@djangocfg/ui';",
|
|
68
|
+
example: `<div className="flex items-center gap-2">
|
|
69
|
+
<Checkbox id="terms" />
|
|
70
|
+
<Label htmlFor="terms">Accept terms and conditions</Label>
|
|
71
|
+
</div>`,
|
|
72
|
+
preview: (
|
|
73
|
+
<div className="flex items-center gap-2">
|
|
74
|
+
<Checkbox id="terms" />
|
|
75
|
+
<Label htmlFor="terms">Accept terms and conditions</Label>
|
|
76
|
+
</div>
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'RadioGroup',
|
|
81
|
+
category: 'forms',
|
|
82
|
+
description: 'Radio button group for single selection',
|
|
83
|
+
importPath: "import { RadioGroup, RadioGroupItem, Label } from '@djangocfg/ui';",
|
|
84
|
+
example: `<RadioGroup defaultValue="option1">
|
|
85
|
+
<div className="flex items-center gap-2">
|
|
86
|
+
<RadioGroupItem value="option1" id="opt1" />
|
|
87
|
+
<Label htmlFor="opt1">Option 1</Label>
|
|
88
|
+
</div>
|
|
89
|
+
<div className="flex items-center gap-2">
|
|
90
|
+
<RadioGroupItem value="option2" id="opt2" />
|
|
91
|
+
<Label htmlFor="opt2">Option 2</Label>
|
|
92
|
+
</div>
|
|
93
|
+
</RadioGroup>`,
|
|
94
|
+
preview: (
|
|
95
|
+
<RadioGroup defaultValue="option1">
|
|
96
|
+
<div className="flex items-center gap-2">
|
|
97
|
+
<RadioGroupItem value="option1" id="opt1" />
|
|
98
|
+
<Label htmlFor="opt1">Option 1</Label>
|
|
99
|
+
</div>
|
|
100
|
+
<div className="flex items-center gap-2">
|
|
101
|
+
<RadioGroupItem value="option2" id="opt2" />
|
|
102
|
+
<Label htmlFor="opt2">Option 2</Label>
|
|
103
|
+
</div>
|
|
104
|
+
</RadioGroup>
|
|
105
|
+
),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'Select',
|
|
109
|
+
category: 'forms',
|
|
110
|
+
description: 'Dropdown select component',
|
|
111
|
+
importPath: "import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@djangocfg/ui';",
|
|
112
|
+
example: `<Select>
|
|
113
|
+
<SelectTrigger className="w-[200px]">
|
|
114
|
+
<SelectValue placeholder="Select option" />
|
|
115
|
+
</SelectTrigger>
|
|
116
|
+
<SelectContent>
|
|
117
|
+
<SelectItem value="1">Option 1</SelectItem>
|
|
118
|
+
<SelectItem value="2">Option 2</SelectItem>
|
|
119
|
+
<SelectItem value="3">Option 3</SelectItem>
|
|
120
|
+
</SelectContent>
|
|
121
|
+
</Select>`,
|
|
122
|
+
preview: (
|
|
123
|
+
<Select>
|
|
124
|
+
<SelectTrigger className="w-[200px]">
|
|
125
|
+
<SelectValue placeholder="Select option" />
|
|
126
|
+
</SelectTrigger>
|
|
127
|
+
<SelectContent>
|
|
128
|
+
<SelectItem value="1">Option 1</SelectItem>
|
|
129
|
+
<SelectItem value="2">Option 2</SelectItem>
|
|
130
|
+
<SelectItem value="3">Option 3</SelectItem>
|
|
131
|
+
</SelectContent>
|
|
132
|
+
</Select>
|
|
133
|
+
),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'Textarea',
|
|
137
|
+
category: 'forms',
|
|
138
|
+
description: 'Multi-line text input',
|
|
139
|
+
importPath: "import { Textarea } from '@djangocfg/ui';",
|
|
140
|
+
example: `<Textarea placeholder="Enter your message..." rows={4} />`,
|
|
141
|
+
preview: (
|
|
142
|
+
<Textarea placeholder="Enter your message..." rows={4} className="max-w-sm" />
|
|
143
|
+
),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'Switch',
|
|
147
|
+
category: 'forms',
|
|
148
|
+
description: 'Toggle switch component',
|
|
149
|
+
importPath: "import { Switch, Label } from '@djangocfg/ui';",
|
|
150
|
+
example: `<div className="flex items-center gap-2">
|
|
151
|
+
<Switch id="notifications" />
|
|
152
|
+
<Label htmlFor="notifications">Enable notifications</Label>
|
|
153
|
+
</div>`,
|
|
154
|
+
preview: (
|
|
155
|
+
<div className="flex items-center gap-2">
|
|
156
|
+
<Switch id="notifications" />
|
|
157
|
+
<Label htmlFor="notifications">Enable notifications</Label>
|
|
158
|
+
</div>
|
|
159
|
+
),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'Slider',
|
|
163
|
+
category: 'forms',
|
|
164
|
+
description: 'Range slider input',
|
|
165
|
+
importPath: "import { Slider } from '@djangocfg/ui';",
|
|
166
|
+
example: `<Slider defaultValue={[50]} max={100} step={1} className="w-[200px]" />`,
|
|
167
|
+
preview: (
|
|
168
|
+
<Slider defaultValue={[50]} max={100} step={1} className="w-[200px]" />
|
|
169
|
+
),
|
|
170
|
+
},
|
|
171
|
+
];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks Configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ComponentConfig } from './types';
|
|
7
|
+
|
|
8
|
+
export const HOOKS: ComponentConfig[] = [
|
|
9
|
+
{
|
|
10
|
+
name: 'useMediaQuery',
|
|
11
|
+
category: 'hooks',
|
|
12
|
+
description: 'Responsive media query hook',
|
|
13
|
+
importPath: "import { useMediaQuery } from '@djangocfg/ui';",
|
|
14
|
+
example: `const isMobile = useMediaQuery('(max-width: 768px)');
|
|
15
|
+
const isDesktop = useMediaQuery('(min-width: 1024px)');
|
|
16
|
+
|
|
17
|
+
return isMobile ? <MobileView /> : <DesktopView />;`,
|
|
18
|
+
preview: (
|
|
19
|
+
<div className="p-4 border rounded-md">
|
|
20
|
+
<code className="text-sm">
|
|
21
|
+
useMediaQuery('(max-width: 768px)')
|
|
22
|
+
</code>
|
|
23
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
24
|
+
Returns boolean based on media query match
|
|
25
|
+
</p>
|
|
26
|
+
</div>
|
|
27
|
+
),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'useTheme',
|
|
31
|
+
category: 'hooks',
|
|
32
|
+
description: 'Theme management hook',
|
|
33
|
+
importPath: "import { useTheme } from '@djangocfg/ui';",
|
|
34
|
+
example: `const theme = useTheme(); // Returns 'light' | 'dark'
|
|
35
|
+
|
|
36
|
+
// Toggle theme manually
|
|
37
|
+
document.documentElement.classList.toggle('dark');`,
|
|
38
|
+
preview: (
|
|
39
|
+
<div className="p-4 border rounded-md">
|
|
40
|
+
<code className="text-sm">
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
</code>
|
|
43
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
44
|
+
Returns current theme: 'light' | 'dark'
|
|
45
|
+
</p>
|
|
46
|
+
</div>
|
|
47
|
+
),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'useCopy',
|
|
51
|
+
category: 'hooks',
|
|
52
|
+
description: 'Copy to clipboard hook',
|
|
53
|
+
importPath: "import { useCopy } from '@djangocfg/ui';",
|
|
54
|
+
example: `const { copyToClipboard } = useCopy();
|
|
55
|
+
const [copied, setCopied] = useState(false);
|
|
56
|
+
|
|
57
|
+
const handleCopy = async () => {
|
|
58
|
+
await copyToClipboard('text to copy');
|
|
59
|
+
setCopied(true);
|
|
60
|
+
};`,
|
|
61
|
+
preview: (
|
|
62
|
+
<div className="p-4 border rounded-md">
|
|
63
|
+
<code className="text-sm">
|
|
64
|
+
copyToClipboard(text)
|
|
65
|
+
</code>
|
|
66
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
67
|
+
Copy text to clipboard programmatically
|
|
68
|
+
</p>
|
|
69
|
+
</div>
|
|
70
|
+
),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'useCountdown',
|
|
74
|
+
category: 'hooks',
|
|
75
|
+
description: 'Countdown timer hook',
|
|
76
|
+
importPath: "import { useCountdown } from '@djangocfg/ui';",
|
|
77
|
+
example: `const targetDate = new Date('2025-12-31').toISOString();
|
|
78
|
+
const countdown = useCountdown(targetDate);
|
|
79
|
+
|
|
80
|
+
// Returns: { days, hours, minutes, seconds, isExpired }`,
|
|
81
|
+
preview: (
|
|
82
|
+
<div className="p-4 border rounded-md">
|
|
83
|
+
<code className="text-sm">
|
|
84
|
+
useCountdown(isoDateString)
|
|
85
|
+
</code>
|
|
86
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
87
|
+
Returns countdown object with days, hours, minutes, seconds
|
|
88
|
+
</p>
|
|
89
|
+
</div>
|
|
90
|
+
),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'useDebounce',
|
|
94
|
+
category: 'hooks',
|
|
95
|
+
description: 'Debounce value changes',
|
|
96
|
+
importPath: "import { useDebounce } from '@djangocfg/ui';",
|
|
97
|
+
example: `const [search, setSearch] = useState('');
|
|
98
|
+
const debouncedSearch = useDebounce(search, 500);
|
|
99
|
+
|
|
100
|
+
// debouncedSearch updates 500ms after last change`,
|
|
101
|
+
preview: (
|
|
102
|
+
<div className="p-4 border rounded-md">
|
|
103
|
+
<code className="text-sm">
|
|
104
|
+
useDebounce(value, delay)
|
|
105
|
+
</code>
|
|
106
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
107
|
+
Debounces value changes with specified delay
|
|
108
|
+
</p>
|
|
109
|
+
</div>
|
|
110
|
+
),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'useIsMobile',
|
|
114
|
+
category: 'hooks',
|
|
115
|
+
description: 'Check if device is mobile',
|
|
116
|
+
importPath: "import { useIsMobile } from '@djangocfg/ui';",
|
|
117
|
+
example: `const isMobile = useIsMobile(); // Boolean
|
|
118
|
+
|
|
119
|
+
return isMobile ? <MobileMenu /> : <DesktopMenu />;`,
|
|
120
|
+
preview: (
|
|
121
|
+
<div className="p-4 border rounded-md">
|
|
122
|
+
<code className="text-sm">
|
|
123
|
+
const isMobile = useIsMobile();
|
|
124
|
+
</code>
|
|
125
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
126
|
+
Returns true if viewport width {'<'} 768px
|
|
127
|
+
</p>
|
|
128
|
+
</div>
|
|
129
|
+
),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Components Configuration Index
|
|
3
|
+
* Aggregates all component configs from separate files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type { ComponentConfig } from './types';
|
|
7
|
+
export { FORM_COMPONENTS } from './forms.config';
|
|
8
|
+
export { LAYOUT_COMPONENTS } from './layout.config';
|
|
9
|
+
export { NAVIGATION_COMPONENTS } from './navigation.config';
|
|
10
|
+
export { OVERLAY_COMPONENTS } from './overlay.config';
|
|
11
|
+
export { FEEDBACK_COMPONENTS } from './feedback.config';
|
|
12
|
+
export { DATA_COMPONENTS } from './data.config';
|
|
13
|
+
export { SPECIALIZED_COMPONENTS } from './specialized.config';
|
|
14
|
+
export { BLOCKS } from './blocks.config';
|
|
15
|
+
export { HOOKS } from './hooks.config';
|
|
16
|
+
|
|
17
|
+
import { FORM_COMPONENTS } from './forms.config';
|
|
18
|
+
import { LAYOUT_COMPONENTS } from './layout.config';
|
|
19
|
+
import { NAVIGATION_COMPONENTS } from './navigation.config';
|
|
20
|
+
import { OVERLAY_COMPONENTS } from './overlay.config';
|
|
21
|
+
import { FEEDBACK_COMPONENTS } from './feedback.config';
|
|
22
|
+
import { DATA_COMPONENTS } from './data.config';
|
|
23
|
+
import { SPECIALIZED_COMPONENTS } from './specialized.config';
|
|
24
|
+
import { BLOCKS } from './blocks.config';
|
|
25
|
+
import { HOOKS } from './hooks.config';
|
|
26
|
+
import type { ComponentConfig } from './types';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* All components aggregated from category configs
|
|
30
|
+
*/
|
|
31
|
+
export const COMPONENTS_CONFIG: ComponentConfig[] = [
|
|
32
|
+
...FORM_COMPONENTS,
|
|
33
|
+
...LAYOUT_COMPONENTS,
|
|
34
|
+
...NAVIGATION_COMPONENTS,
|
|
35
|
+
...OVERLAY_COMPONENTS,
|
|
36
|
+
...FEEDBACK_COMPONENTS,
|
|
37
|
+
...DATA_COMPONENTS,
|
|
38
|
+
...SPECIALIZED_COMPONENTS,
|
|
39
|
+
...BLOCKS,
|
|
40
|
+
...HOOKS,
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get components by category
|
|
45
|
+
*/
|
|
46
|
+
export function getComponentsByCategory(category: string): ComponentConfig[] {
|
|
47
|
+
return COMPONENTS_CONFIG.filter(comp => comp.category === category);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get component by name
|
|
52
|
+
*/
|
|
53
|
+
export function getComponentByName(name: string): ComponentConfig | undefined {
|
|
54
|
+
return COMPONENTS_CONFIG.find(comp => comp.name === name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get all categories
|
|
59
|
+
*/
|
|
60
|
+
export function getAllCategories(): string[] {
|
|
61
|
+
return [...new Set(COMPONENTS_CONFIG.map(comp => comp.category))];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get component count by category
|
|
66
|
+
*/
|
|
67
|
+
export function getComponentCount(category: string): number {
|
|
68
|
+
return COMPONENTS_CONFIG.filter(comp => comp.category === category).length;
|
|
69
|
+
}
|