@object-ui/components 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/.turbo/turbo-build.log +12 -12
  2. package/CHANGELOG.md +28 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +19610 -19344
  5. package/dist/index.umd.cjs +29 -29
  6. package/dist/src/custom/index.d.ts +2 -0
  7. package/dist/src/custom/view-skeleton.d.ts +37 -0
  8. package/dist/src/custom/view-states.d.ts +33 -0
  9. package/package.json +17 -17
  10. package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +811 -0
  11. package/src/__tests__/__snapshots__/snapshot.test.tsx.snap +327 -0
  12. package/src/__tests__/accessibility.test.tsx +137 -0
  13. package/src/__tests__/api-consistency.test.tsx +596 -0
  14. package/src/__tests__/color-contrast.test.tsx +212 -0
  15. package/src/__tests__/edge-cases.test.tsx +285 -0
  16. package/src/__tests__/snapshot-critical.test.tsx +317 -0
  17. package/src/__tests__/snapshot.test.tsx +205 -0
  18. package/src/__tests__/wcag-audit.test.tsx +493 -0
  19. package/src/custom/index.ts +2 -0
  20. package/src/custom/view-skeleton.tsx +243 -0
  21. package/src/custom/view-states.tsx +153 -0
  22. package/src/renderers/complex/data-table.tsx +28 -13
  23. package/src/renderers/complex/resizable.tsx +20 -17
  24. package/src/renderers/data-display/list.tsx +1 -1
  25. package/src/renderers/data-display/table.tsx +1 -1
  26. package/src/renderers/data-display/tree-view.tsx +2 -1
  27. package/src/renderers/form/form.tsx +10 -6
  28. package/src/renderers/layout/aspect-ratio.tsx +1 -1
  29. package/src/stories-json/Accessibility.mdx +297 -0
  30. package/src/stories-json/EdgeCases.stories.tsx +160 -0
  31. package/src/stories-json/GettingStarted.mdx +89 -0
  32. package/src/stories-json/Introduction.mdx +127 -0
  33. package/src/ui/slider.tsx +6 -2
  34. package/src/stories/Introduction.mdx +0 -61
@@ -0,0 +1,317 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * Snapshot Tests — Additional Critical UI Components
11
+ *
12
+ * Captures render snapshots of Alert, Dialog, Tabs, Accordion, Avatar,
13
+ * Progress, Tooltip, Breadcrumb, Separator, and Skeleton to detect
14
+ * unintended visual regressions.
15
+ */
16
+
17
+ import { describe, it, expect } from 'vitest';
18
+ import { render } from '@testing-library/react';
19
+ import React from 'react';
20
+ import {
21
+ Alert,
22
+ AlertTitle,
23
+ AlertDescription,
24
+ Dialog,
25
+ DialogTrigger,
26
+ DialogContent,
27
+ DialogHeader,
28
+ DialogFooter,
29
+ DialogTitle,
30
+ DialogDescription,
31
+ Tabs,
32
+ TabsList,
33
+ TabsTrigger,
34
+ TabsContent,
35
+ Accordion,
36
+ AccordionItem,
37
+ AccordionTrigger,
38
+ AccordionContent,
39
+ Avatar,
40
+ AvatarImage,
41
+ AvatarFallback,
42
+ Progress,
43
+ TooltipProvider,
44
+ Tooltip,
45
+ TooltipTrigger,
46
+ Breadcrumb,
47
+ BreadcrumbList,
48
+ BreadcrumbItem,
49
+ BreadcrumbLink,
50
+ BreadcrumbPage,
51
+ BreadcrumbSeparator,
52
+ Separator,
53
+ Skeleton,
54
+ } from '@object-ui/components';
55
+
56
+ // ─── Alert Snapshots ────────────────────────────────────────────────────
57
+
58
+ describe('Alert snapshots', () => {
59
+ it('renders default alert with title and description', () => {
60
+ const { container } = render(
61
+ <Alert>
62
+ <AlertTitle>Heads up!</AlertTitle>
63
+ <AlertDescription>
64
+ You can add components to your app using the CLI.
65
+ </AlertDescription>
66
+ </Alert>,
67
+ );
68
+ expect(container.firstChild).toMatchSnapshot();
69
+ });
70
+
71
+ it('renders destructive alert with title and description', () => {
72
+ const { container } = render(
73
+ <Alert variant="destructive">
74
+ <AlertTitle>Error</AlertTitle>
75
+ <AlertDescription>
76
+ Your session has expired. Please log in again.
77
+ </AlertDescription>
78
+ </Alert>,
79
+ );
80
+ expect(container.firstChild).toMatchSnapshot();
81
+ });
82
+ });
83
+
84
+ // ─── Dialog Snapshots ───────────────────────────────────────────────────
85
+
86
+ describe('Dialog snapshots', () => {
87
+ it('renders open dialog structure', () => {
88
+ const { baseElement } = render(
89
+ <Dialog open>
90
+ <DialogTrigger>Open</DialogTrigger>
91
+ <DialogContent>
92
+ <DialogHeader>
93
+ <DialogTitle>Edit Profile</DialogTitle>
94
+ <DialogDescription>
95
+ Make changes to your profile here.
96
+ </DialogDescription>
97
+ </DialogHeader>
98
+ <p>Dialog body content</p>
99
+ <DialogFooter>
100
+ <button type="submit">Save changes</button>
101
+ </DialogFooter>
102
+ </DialogContent>
103
+ </Dialog>,
104
+ );
105
+ expect(baseElement).toMatchSnapshot();
106
+ });
107
+ });
108
+
109
+ // ─── Tabs Snapshots ─────────────────────────────────────────────────────
110
+
111
+ describe('Tabs snapshots', () => {
112
+ it('renders tabs with multiple panels', () => {
113
+ const { container } = render(
114
+ <Tabs defaultValue="account">
115
+ <TabsList>
116
+ <TabsTrigger value="account">Account</TabsTrigger>
117
+ <TabsTrigger value="password">Password</TabsTrigger>
118
+ <TabsTrigger value="settings">Settings</TabsTrigger>
119
+ </TabsList>
120
+ <TabsContent value="account">Account settings here.</TabsContent>
121
+ <TabsContent value="password">Change your password.</TabsContent>
122
+ <TabsContent value="settings">App settings here.</TabsContent>
123
+ </Tabs>,
124
+ );
125
+ expect(container.firstChild).toMatchSnapshot();
126
+ });
127
+
128
+ it('renders tabs with second tab active', () => {
129
+ const { container } = render(
130
+ <Tabs defaultValue="password">
131
+ <TabsList>
132
+ <TabsTrigger value="account">Account</TabsTrigger>
133
+ <TabsTrigger value="password">Password</TabsTrigger>
134
+ </TabsList>
135
+ <TabsContent value="account">Account settings.</TabsContent>
136
+ <TabsContent value="password">Password settings.</TabsContent>
137
+ </Tabs>,
138
+ );
139
+ expect(container.firstChild).toMatchSnapshot();
140
+ });
141
+ });
142
+
143
+ // ─── Accordion Snapshots ────────────────────────────────────────────────
144
+
145
+ describe('Accordion snapshots', () => {
146
+ it('renders accordion with multiple items', () => {
147
+ const { container } = render(
148
+ <Accordion type="single" collapsible>
149
+ <AccordionItem value="item-1">
150
+ <AccordionTrigger>Is it accessible?</AccordionTrigger>
151
+ <AccordionContent>
152
+ Yes. It adheres to the WAI-ARIA design pattern.
153
+ </AccordionContent>
154
+ </AccordionItem>
155
+ <AccordionItem value="item-2">
156
+ <AccordionTrigger>Is it styled?</AccordionTrigger>
157
+ <AccordionContent>
158
+ Yes. It comes with default styles that match the design system.
159
+ </AccordionContent>
160
+ </AccordionItem>
161
+ <AccordionItem value="item-3">
162
+ <AccordionTrigger>Is it animated?</AccordionTrigger>
163
+ <AccordionContent>
164
+ Yes. It uses CSS animations for smooth transitions.
165
+ </AccordionContent>
166
+ </AccordionItem>
167
+ </Accordion>,
168
+ );
169
+ expect(container.firstChild).toMatchSnapshot();
170
+ });
171
+
172
+ it('renders accordion with first item expanded', () => {
173
+ const { container } = render(
174
+ <Accordion type="single" defaultValue="item-1">
175
+ <AccordionItem value="item-1">
176
+ <AccordionTrigger>Section One</AccordionTrigger>
177
+ <AccordionContent>Content for section one.</AccordionContent>
178
+ </AccordionItem>
179
+ <AccordionItem value="item-2">
180
+ <AccordionTrigger>Section Two</AccordionTrigger>
181
+ <AccordionContent>Content for section two.</AccordionContent>
182
+ </AccordionItem>
183
+ </Accordion>,
184
+ );
185
+ expect(container.firstChild).toMatchSnapshot();
186
+ });
187
+ });
188
+
189
+ // ─── Avatar Snapshots ───────────────────────────────────────────────────
190
+
191
+ describe('Avatar snapshots', () => {
192
+ it('renders avatar with image and fallback', () => {
193
+ const { container } = render(
194
+ <Avatar>
195
+ <AvatarImage src="https://example.com/avatar.png" alt="User avatar" />
196
+ <AvatarFallback>JD</AvatarFallback>
197
+ </Avatar>,
198
+ );
199
+ expect(container.firstChild).toMatchSnapshot();
200
+ });
201
+
202
+ it('renders avatar with fallback only', () => {
203
+ const { container } = render(
204
+ <Avatar>
205
+ <AvatarFallback>AB</AvatarFallback>
206
+ </Avatar>,
207
+ );
208
+ expect(container.firstChild).toMatchSnapshot();
209
+ });
210
+ });
211
+
212
+ // ─── Progress Snapshots ─────────────────────────────────────────────────
213
+
214
+ describe('Progress snapshots', () => {
215
+ it('renders progress at 0%', () => {
216
+ const { container } = render(<Progress value={0} />);
217
+ expect(container.firstChild).toMatchSnapshot();
218
+ });
219
+
220
+ it('renders progress at 50%', () => {
221
+ const { container } = render(<Progress value={50} />);
222
+ expect(container.firstChild).toMatchSnapshot();
223
+ });
224
+
225
+ it('renders progress at 100%', () => {
226
+ const { container } = render(<Progress value={100} />);
227
+ expect(container.firstChild).toMatchSnapshot();
228
+ });
229
+ });
230
+
231
+ // ─── Tooltip Snapshots ──────────────────────────────────────────────────
232
+
233
+ describe('Tooltip snapshots', () => {
234
+ it('renders tooltip trigger', () => {
235
+ const { container } = render(
236
+ <TooltipProvider>
237
+ <Tooltip>
238
+ <TooltipTrigger asChild>
239
+ <button>Hover me</button>
240
+ </TooltipTrigger>
241
+ </Tooltip>
242
+ </TooltipProvider>,
243
+ );
244
+ expect(container.firstChild).toMatchSnapshot();
245
+ });
246
+ });
247
+
248
+ // ─── Breadcrumb Snapshots ───────────────────────────────────────────────
249
+
250
+ describe('Breadcrumb snapshots', () => {
251
+ it('renders multi-level breadcrumb', () => {
252
+ const { container } = render(
253
+ <Breadcrumb>
254
+ <BreadcrumbList>
255
+ <BreadcrumbItem>
256
+ <BreadcrumbLink href="/">Home</BreadcrumbLink>
257
+ </BreadcrumbItem>
258
+ <BreadcrumbSeparator />
259
+ <BreadcrumbItem>
260
+ <BreadcrumbLink href="/products">Products</BreadcrumbLink>
261
+ </BreadcrumbItem>
262
+ <BreadcrumbSeparator />
263
+ <BreadcrumbItem>
264
+ <BreadcrumbPage>Current Page</BreadcrumbPage>
265
+ </BreadcrumbItem>
266
+ </BreadcrumbList>
267
+ </Breadcrumb>,
268
+ );
269
+ expect(container.firstChild).toMatchSnapshot();
270
+ });
271
+ });
272
+
273
+ // ─── Separator Snapshots ────────────────────────────────────────────────
274
+
275
+ describe('Separator snapshots', () => {
276
+ it('renders horizontal separator', () => {
277
+ const { container } = render(<Separator />);
278
+ expect(container.firstChild).toMatchSnapshot();
279
+ });
280
+
281
+ it('renders vertical separator', () => {
282
+ const { container } = render(<Separator orientation="vertical" />);
283
+ expect(container.firstChild).toMatchSnapshot();
284
+ });
285
+ });
286
+
287
+ // ─── Skeleton Snapshots ─────────────────────────────────────────────────
288
+
289
+ describe('Skeleton snapshots', () => {
290
+ it('renders default skeleton', () => {
291
+ const { container } = render(<Skeleton />);
292
+ expect(container.firstChild).toMatchSnapshot();
293
+ });
294
+
295
+ it('renders skeleton with text line dimensions', () => {
296
+ const { container } = render(<Skeleton className="h-4 w-[250px]" />);
297
+ expect(container.firstChild).toMatchSnapshot();
298
+ });
299
+
300
+ it('renders skeleton with circular avatar dimensions', () => {
301
+ const { container } = render(<Skeleton className="h-12 w-12 rounded-full" />);
302
+ expect(container.firstChild).toMatchSnapshot();
303
+ });
304
+
305
+ it('renders skeleton loading card layout', () => {
306
+ const { container } = render(
307
+ <div className="flex flex-col space-y-3">
308
+ <Skeleton className="h-[125px] w-[250px] rounded-xl" />
309
+ <div className="space-y-2">
310
+ <Skeleton className="h-4 w-[250px]" />
311
+ <Skeleton className="h-4 w-[200px]" />
312
+ </div>
313
+ </div>,
314
+ );
315
+ expect(container.firstChild).toMatchSnapshot();
316
+ });
317
+ });
@@ -0,0 +1,205 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ /**
10
+ * Snapshot Tests — Critical UI Components
11
+ *
12
+ * Captures render snapshots of Button, Badge, Card, Empty, and Spinner
13
+ * with all major variant permutations to detect unintended visual regressions.
14
+ */
15
+
16
+ import { describe, it, expect } from 'vitest';
17
+ import { render } from '@testing-library/react';
18
+ import React from 'react';
19
+ import {
20
+ Button,
21
+ Badge,
22
+ Card,
23
+ CardHeader,
24
+ CardTitle,
25
+ CardDescription,
26
+ CardContent,
27
+ CardFooter,
28
+ Empty,
29
+ EmptyHeader,
30
+ EmptyTitle,
31
+ EmptyDescription,
32
+ EmptyMedia,
33
+ EmptyContent,
34
+ Spinner,
35
+ } from '../index';
36
+
37
+ // ─── Button Snapshots ───────────────────────────────────────────────────
38
+
39
+ describe('Button snapshots', () => {
40
+ const variants = ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'] as const;
41
+
42
+ variants.forEach((variant) => {
43
+ it(`renders variant="${variant}"`, () => {
44
+ const { container } = render(
45
+ <Button variant={variant}>Click me</Button>,
46
+ );
47
+ expect(container.firstChild).toMatchSnapshot();
48
+ });
49
+ });
50
+
51
+ it('renders disabled state', () => {
52
+ const { container } = render(<Button disabled>Disabled</Button>);
53
+ expect(container.firstChild).toMatchSnapshot();
54
+ });
55
+
56
+ it('renders size="sm"', () => {
57
+ const { container } = render(<Button size="sm">Small</Button>);
58
+ expect(container.firstChild).toMatchSnapshot();
59
+ });
60
+
61
+ it('renders size="lg"', () => {
62
+ const { container } = render(<Button size="lg">Large</Button>);
63
+ expect(container.firstChild).toMatchSnapshot();
64
+ });
65
+
66
+ it('renders size="icon"', () => {
67
+ const { container } = render(
68
+ <Button size="icon" aria-label="Icon button">
69
+
70
+ </Button>,
71
+ );
72
+ expect(container.firstChild).toMatchSnapshot();
73
+ });
74
+ });
75
+
76
+ // ─── Badge Snapshots ────────────────────────────────────────────────────
77
+
78
+ describe('Badge snapshots', () => {
79
+ const variants = ['default', 'secondary', 'destructive', 'outline'] as const;
80
+
81
+ variants.forEach((variant) => {
82
+ it(`renders variant="${variant}"`, () => {
83
+ const { container } = render(
84
+ <Badge variant={variant}>Label</Badge>,
85
+ );
86
+ expect(container.firstChild).toMatchSnapshot();
87
+ });
88
+ });
89
+
90
+ it('renders with custom className', () => {
91
+ const { container } = render(
92
+ <Badge className="custom-class">Custom</Badge>,
93
+ );
94
+ expect(container.firstChild).toMatchSnapshot();
95
+ });
96
+ });
97
+
98
+ // ─── Card Snapshots ─────────────────────────────────────────────────────
99
+
100
+ describe('Card snapshots', () => {
101
+ it('renders with header, content, and footer', () => {
102
+ const { container } = render(
103
+ <Card>
104
+ <CardHeader>
105
+ <CardTitle>Card Title</CardTitle>
106
+ <CardDescription>A brief description</CardDescription>
107
+ </CardHeader>
108
+ <CardContent>
109
+ <p>Card body content</p>
110
+ </CardContent>
111
+ <CardFooter>
112
+ <Button>Action</Button>
113
+ </CardFooter>
114
+ </Card>,
115
+ );
116
+ expect(container.firstChild).toMatchSnapshot();
117
+ });
118
+
119
+ it('renders header-only card', () => {
120
+ const { container } = render(
121
+ <Card>
122
+ <CardHeader>
123
+ <CardTitle>Minimal Card</CardTitle>
124
+ </CardHeader>
125
+ </Card>,
126
+ );
127
+ expect(container.firstChild).toMatchSnapshot();
128
+ });
129
+
130
+ it('renders content-only card', () => {
131
+ const { container } = render(
132
+ <Card>
133
+ <CardContent>Just content</CardContent>
134
+ </Card>,
135
+ );
136
+ expect(container.firstChild).toMatchSnapshot();
137
+ });
138
+
139
+ it('renders with custom className', () => {
140
+ const { container } = render(
141
+ <Card className="w-96 shadow-lg">
142
+ <CardContent>Styled card</CardContent>
143
+ </Card>,
144
+ );
145
+ expect(container.firstChild).toMatchSnapshot();
146
+ });
147
+ });
148
+
149
+ // ─── Empty State Snapshots ──────────────────────────────────────────────
150
+
151
+ describe('Empty state snapshots', () => {
152
+ it('renders full empty state with media, title, description, and content', () => {
153
+ const { container } = render(
154
+ <Empty>
155
+ <EmptyHeader>
156
+ <EmptyMedia variant="icon">
157
+ <span>📭</span>
158
+ </EmptyMedia>
159
+ <EmptyTitle>No results found</EmptyTitle>
160
+ <EmptyDescription>
161
+ Try adjusting your search or filter criteria.
162
+ </EmptyDescription>
163
+ </EmptyHeader>
164
+ <EmptyContent>
165
+ <Button variant="outline">Clear filters</Button>
166
+ </EmptyContent>
167
+ </Empty>,
168
+ );
169
+ expect(container.firstChild).toMatchSnapshot();
170
+ });
171
+
172
+ it('renders minimal empty state with title only', () => {
173
+ const { container } = render(
174
+ <Empty>
175
+ <EmptyHeader>
176
+ <EmptyTitle>Nothing here yet</EmptyTitle>
177
+ </EmptyHeader>
178
+ </Empty>,
179
+ );
180
+ expect(container.firstChild).toMatchSnapshot();
181
+ });
182
+
183
+ it('renders empty media with default variant', () => {
184
+ const { container } = render(
185
+ <EmptyMedia>
186
+ <span>🔍</span>
187
+ </EmptyMedia>,
188
+ );
189
+ expect(container.firstChild).toMatchSnapshot();
190
+ });
191
+ });
192
+
193
+ // ─── Spinner Snapshots ──────────────────────────────────────────────────
194
+
195
+ describe('Spinner snapshots', () => {
196
+ it('renders default spinner', () => {
197
+ const { container } = render(<Spinner />);
198
+ expect(container.firstChild).toMatchSnapshot();
199
+ });
200
+
201
+ it('renders with custom className', () => {
202
+ const { container } = render(<Spinner className="h-8 w-8" />);
203
+ expect(container.firstChild).toMatchSnapshot();
204
+ });
205
+ });