@object-ui/types 0.3.0 → 0.3.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.
- package/README.md +19 -11
- package/dist/api-types.d.ts +7 -0
- package/dist/api-types.d.ts.map +1 -1
- package/dist/api-types.js +4 -6
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +4 -3
- package/dist/base.d.ts +7 -0
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +4 -6
- package/dist/complex.d.ts +68 -1
- package/dist/complex.d.ts.map +1 -1
- package/dist/complex.js +4 -5
- package/dist/crud.d.ts +7 -0
- package/dist/crud.d.ts.map +1 -1
- package/dist/crud.js +4 -6
- package/dist/data-display.d.ts +54 -2
- package/dist/data-display.d.ts.map +1 -1
- package/dist/data-display.js +4 -5
- package/dist/data.d.ts +16 -0
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +4 -6
- package/dist/disclosure.d.ts +70 -1
- package/dist/disclosure.d.ts.map +1 -1
- package/dist/disclosure.js +4 -5
- package/dist/feedback.d.ts +68 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +4 -5
- package/dist/field-types.d.ts +386 -0
- package/dist/field-types.d.ts.map +1 -0
- package/dist/field-types.js +8 -0
- package/dist/form.d.ts +123 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +4 -5
- package/dist/index.d.ts +21 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -37
- package/dist/layout.d.ts +66 -16
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +4 -6
- package/dist/navigation.d.ts +102 -2
- package/dist/navigation.d.ts.map +1 -1
- package/dist/navigation.js +4 -5
- package/dist/objectql.d.ts +484 -54
- package/dist/objectql.d.ts.map +1 -1
- package/dist/objectql.js +4 -6
- package/dist/overlay.d.ts +31 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +4 -5
- package/dist/registry.d.ts +7 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -0
- package/dist/zod/base.zod.d.ts +202 -0
- package/dist/zod/base.zod.d.ts.map +1 -0
- package/dist/zod/base.zod.js +198 -0
- package/dist/zod/complex.zod.d.ts +742 -0
- package/dist/zod/complex.zod.d.ts.map +1 -0
- package/dist/zod/complex.zod.js +233 -0
- package/dist/zod/data-display.zod.d.ts +996 -0
- package/dist/zod/data-display.zod.d.ts.map +1 -0
- package/dist/zod/data-display.zod.js +266 -0
- package/dist/zod/disclosure.zod.d.ts +267 -0
- package/dist/zod/disclosure.zod.d.ts.map +1 -0
- package/dist/zod/disclosure.zod.js +84 -0
- package/dist/zod/feedback.zod.d.ts +538 -0
- package/dist/zod/feedback.zod.d.ts.map +1 -0
- package/dist/zod/feedback.zod.js +127 -0
- package/dist/zod/form.zod.d.ts +1308 -0
- package/dist/zod/form.zod.d.ts.map +1 -0
- package/dist/zod/form.zod.js +406 -0
- package/dist/zod/index.zod.d.ts +3174 -0
- package/dist/zod/index.zod.d.ts.map +1 -0
- package/dist/zod/index.zod.js +106 -0
- package/dist/zod/layout.zod.d.ts +1048 -0
- package/dist/zod/layout.zod.d.ts.map +1 -0
- package/dist/zod/layout.zod.js +241 -0
- package/dist/zod/navigation.zod.d.ts +486 -0
- package/dist/zod/navigation.zod.d.ts.map +1 -0
- package/dist/zod/navigation.zod.js +142 -0
- package/dist/zod/objectql.zod.d.ts +1261 -0
- package/dist/zod/objectql.zod.d.ts.map +1 -0
- package/dist/zod/objectql.zod.js +248 -0
- package/dist/zod/overlay.zod.d.ts +691 -0
- package/dist/zod/overlay.zod.d.ts.map +1 -0
- package/dist/zod/overlay.zod.js +179 -0
- package/package.json +9 -1
- package/src/api-types.ts +8 -0
- package/src/app.ts +8 -0
- package/src/base.ts +8 -0
- package/src/complex.ts +69 -1
- package/src/crud.ts +8 -0
- package/src/data-display.ts +60 -2
- package/src/data.ts +18 -0
- package/src/disclosure.ts +74 -1
- package/src/feedback.ts +76 -2
- package/src/field-types.ts +465 -0
- package/src/form.ts +131 -1
- package/src/index.ts +91 -8
- package/src/layout.ts +70 -15
- package/src/navigation.ts +109 -2
- package/src/objectql.ts +555 -59
- package/src/overlay.ts +35 -1
- package/src/registry.ts +8 -0
- package/src/zod/README.md +329 -0
- package/src/zod/base.zod.ts +229 -0
- package/src/zod/complex.zod.ts +258 -0
- package/src/zod/data-display.zod.ts +290 -0
- package/src/zod/disclosure.zod.ts +92 -0
- package/src/zod/feedback.zod.ts +138 -0
- package/src/zod/form.zod.ts +434 -0
- package/src/zod/index.zod.ts +277 -0
- package/src/zod/layout.zod.ts +262 -0
- package/src/zod/navigation.zod.ts +159 -0
- package/src/zod/objectql.zod.ts +268 -0
- package/src/zod/overlay.zod.ts +196 -0
|
@@ -0,0 +1,277 @@
|
|
|
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
|
+
* @object-ui/types/zod - Zod Validation Schemas
|
|
11
|
+
*
|
|
12
|
+
* Complete Zod validation schemas for all ObjectUI components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ButtonSchema, InputSchema, FormSchema } from '@object-ui/types/zod';
|
|
19
|
+
*
|
|
20
|
+
* // Validate a schema
|
|
21
|
+
* const result = ButtonSchema.safeParse({
|
|
22
|
+
* type: 'button',
|
|
23
|
+
* label: 'Click Me',
|
|
24
|
+
* variant: 'primary',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* if (result.success) {
|
|
28
|
+
* console.log('Valid schema:', result.data);
|
|
29
|
+
* } else {
|
|
30
|
+
* console.error('Validation errors:', result.error);
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// Base Schema - Foundation
|
|
39
|
+
// ============================================================================
|
|
40
|
+
export {
|
|
41
|
+
BaseSchema,
|
|
42
|
+
SchemaNodeSchema,
|
|
43
|
+
ComponentInputSchema,
|
|
44
|
+
ComponentMetaSchema,
|
|
45
|
+
ComponentConfigSchema,
|
|
46
|
+
HTMLAttributesSchema,
|
|
47
|
+
EventHandlersSchema,
|
|
48
|
+
StylePropsSchema,
|
|
49
|
+
} from './base.zod';
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Layout Components - Structure & Organization
|
|
53
|
+
// ============================================================================
|
|
54
|
+
export {
|
|
55
|
+
DivSchema,
|
|
56
|
+
SpanSchema,
|
|
57
|
+
TextSchema,
|
|
58
|
+
ImageSchema,
|
|
59
|
+
IconSchema,
|
|
60
|
+
SeparatorSchema,
|
|
61
|
+
ContainerSchema,
|
|
62
|
+
FlexSchema,
|
|
63
|
+
StackSchema,
|
|
64
|
+
GridSchema,
|
|
65
|
+
CardSchema,
|
|
66
|
+
TabItemSchema,
|
|
67
|
+
TabsSchema,
|
|
68
|
+
ScrollAreaSchema,
|
|
69
|
+
ResizablePanelSchema,
|
|
70
|
+
ResizableSchema,
|
|
71
|
+
AspectRatioSchema,
|
|
72
|
+
PageSchema,
|
|
73
|
+
LayoutSchema,
|
|
74
|
+
} from './layout.zod';
|
|
75
|
+
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Form Components - User Input & Interaction
|
|
78
|
+
// ============================================================================
|
|
79
|
+
export {
|
|
80
|
+
SelectOptionSchema,
|
|
81
|
+
RadioOptionSchema,
|
|
82
|
+
ComboboxOptionSchema,
|
|
83
|
+
CommandItemSchema,
|
|
84
|
+
CommandGroupSchema,
|
|
85
|
+
ValidationRuleSchema,
|
|
86
|
+
FieldConditionSchema,
|
|
87
|
+
ButtonSchema,
|
|
88
|
+
InputSchema,
|
|
89
|
+
TextareaSchema,
|
|
90
|
+
SelectSchema,
|
|
91
|
+
CheckboxSchema,
|
|
92
|
+
RadioGroupSchema,
|
|
93
|
+
SwitchSchema,
|
|
94
|
+
ToggleSchema,
|
|
95
|
+
SliderSchema,
|
|
96
|
+
FileUploadSchema,
|
|
97
|
+
DatePickerSchema,
|
|
98
|
+
CalendarSchema,
|
|
99
|
+
InputOTPSchema,
|
|
100
|
+
ComboboxSchema,
|
|
101
|
+
LabelSchema,
|
|
102
|
+
CommandSchema,
|
|
103
|
+
FormFieldSchema,
|
|
104
|
+
FormSchema,
|
|
105
|
+
FormComponentSchema,
|
|
106
|
+
} from './form.zod';
|
|
107
|
+
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Data Display Components - Information Presentation
|
|
110
|
+
// ============================================================================
|
|
111
|
+
export {
|
|
112
|
+
AlertSchema,
|
|
113
|
+
StatisticSchema,
|
|
114
|
+
BadgeSchema,
|
|
115
|
+
AvatarSchema,
|
|
116
|
+
ListItemSchema,
|
|
117
|
+
ListSchema,
|
|
118
|
+
TableColumnSchema,
|
|
119
|
+
TableSchema,
|
|
120
|
+
DataTableSchema,
|
|
121
|
+
MarkdownSchema,
|
|
122
|
+
TreeNodeSchema,
|
|
123
|
+
TreeViewSchema,
|
|
124
|
+
ChartTypeSchema,
|
|
125
|
+
ChartSeriesSchema,
|
|
126
|
+
ChartSchema,
|
|
127
|
+
TimelineEventSchema,
|
|
128
|
+
TimelineSchema,
|
|
129
|
+
KbdSchema,
|
|
130
|
+
HtmlSchema,
|
|
131
|
+
DataDisplaySchema,
|
|
132
|
+
} from './data-display.zod';
|
|
133
|
+
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Feedback Components - Status & Progress Indication
|
|
136
|
+
// ============================================================================
|
|
137
|
+
export {
|
|
138
|
+
LoadingSchema,
|
|
139
|
+
ProgressSchema,
|
|
140
|
+
SkeletonSchema,
|
|
141
|
+
ToastSchema,
|
|
142
|
+
ToasterSchema,
|
|
143
|
+
SpinnerSchema,
|
|
144
|
+
EmptySchema,
|
|
145
|
+
SonnerSchema,
|
|
146
|
+
FeedbackSchema,
|
|
147
|
+
} from './feedback.zod';
|
|
148
|
+
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// Disclosure Components - Collapsible Content
|
|
151
|
+
// ============================================================================
|
|
152
|
+
export {
|
|
153
|
+
AccordionItemSchema,
|
|
154
|
+
AccordionSchema,
|
|
155
|
+
CollapsibleSchema,
|
|
156
|
+
ToggleGroupItemSchema,
|
|
157
|
+
ToggleGroupSchema,
|
|
158
|
+
DisclosureSchema,
|
|
159
|
+
} from './disclosure.zod';
|
|
160
|
+
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// Overlay Components - Modals & Popovers
|
|
163
|
+
// ============================================================================
|
|
164
|
+
export {
|
|
165
|
+
DialogSchema,
|
|
166
|
+
AlertDialogSchema,
|
|
167
|
+
SheetSchema,
|
|
168
|
+
DrawerSchema,
|
|
169
|
+
PopoverSchema,
|
|
170
|
+
TooltipSchema,
|
|
171
|
+
HoverCardSchema,
|
|
172
|
+
MenuItemSchema,
|
|
173
|
+
DropdownMenuSchema,
|
|
174
|
+
ContextMenuSchema,
|
|
175
|
+
MenubarMenuSchema,
|
|
176
|
+
MenubarSchema,
|
|
177
|
+
OverlaySchema,
|
|
178
|
+
} from './overlay.zod';
|
|
179
|
+
|
|
180
|
+
// ============================================================================
|
|
181
|
+
// Navigation Components - Menus & Navigation
|
|
182
|
+
// ============================================================================
|
|
183
|
+
export {
|
|
184
|
+
NavLinkSchema,
|
|
185
|
+
HeaderBarSchema,
|
|
186
|
+
SidebarSchema,
|
|
187
|
+
PaginationSchema,
|
|
188
|
+
NavigationMenuItemSchema,
|
|
189
|
+
NavigationMenuSchema,
|
|
190
|
+
ButtonGroupButtonSchema,
|
|
191
|
+
ButtonGroupSchema,
|
|
192
|
+
NavigationSchema,
|
|
193
|
+
} from './navigation.zod';
|
|
194
|
+
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Complex Components - Advanced/Composite Components
|
|
197
|
+
// ============================================================================
|
|
198
|
+
export {
|
|
199
|
+
KanbanCardSchema,
|
|
200
|
+
KanbanColumnSchema,
|
|
201
|
+
KanbanSchema,
|
|
202
|
+
CalendarViewModeSchema,
|
|
203
|
+
CalendarEventSchema,
|
|
204
|
+
CalendarViewSchema,
|
|
205
|
+
FilterOperatorSchema,
|
|
206
|
+
FilterConditionSchema,
|
|
207
|
+
FilterGroupSchema,
|
|
208
|
+
FilterFieldSchema,
|
|
209
|
+
FilterBuilderSchema,
|
|
210
|
+
CarouselItemSchema,
|
|
211
|
+
CarouselSchema,
|
|
212
|
+
ChatMessageSchema,
|
|
213
|
+
ChatbotSchema,
|
|
214
|
+
DashboardWidgetLayoutSchema,
|
|
215
|
+
DashboardWidgetSchema,
|
|
216
|
+
DashboardSchema,
|
|
217
|
+
ComplexSchema,
|
|
218
|
+
} from './complex.zod';
|
|
219
|
+
|
|
220
|
+
// ============================================================================
|
|
221
|
+
// ObjectQL Components - Smart Data Components
|
|
222
|
+
// ============================================================================
|
|
223
|
+
export {
|
|
224
|
+
HttpMethodSchema,
|
|
225
|
+
HttpRequestSchema,
|
|
226
|
+
ViewDataSchema,
|
|
227
|
+
ListColumnSchema,
|
|
228
|
+
SelectionConfigSchema,
|
|
229
|
+
PaginationConfigSchema,
|
|
230
|
+
SortConfigSchema,
|
|
231
|
+
ObjectGridSchema,
|
|
232
|
+
ObjectFormSchema,
|
|
233
|
+
ObjectViewSchema,
|
|
234
|
+
ObjectMapSchema,
|
|
235
|
+
ObjectGanttSchema,
|
|
236
|
+
ObjectCalendarSchema,
|
|
237
|
+
ObjectKanbanSchema,
|
|
238
|
+
ObjectChartSchema,
|
|
239
|
+
ListViewSchema,
|
|
240
|
+
ObjectQLComponentSchema,
|
|
241
|
+
} from './objectql.zod';
|
|
242
|
+
|
|
243
|
+
// ============================================================================
|
|
244
|
+
// Union Types - All Component Schemas
|
|
245
|
+
// ============================================================================
|
|
246
|
+
|
|
247
|
+
import { z } from 'zod';
|
|
248
|
+
import { LayoutSchema } from './layout.zod';
|
|
249
|
+
import { FormComponentSchema } from './form.zod';
|
|
250
|
+
import { DataDisplaySchema } from './data-display.zod';
|
|
251
|
+
import { FeedbackSchema } from './feedback.zod';
|
|
252
|
+
import { DisclosureSchema } from './disclosure.zod';
|
|
253
|
+
import { OverlaySchema } from './overlay.zod';
|
|
254
|
+
import { NavigationSchema } from './navigation.zod';
|
|
255
|
+
import { ComplexSchema } from './complex.zod';
|
|
256
|
+
import { ObjectQLComponentSchema } from './objectql.zod';
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Union of all component schemas.
|
|
260
|
+
* Use this for generic component rendering where the type is determined at runtime.
|
|
261
|
+
*/
|
|
262
|
+
export const AnyComponentSchema = z.union([
|
|
263
|
+
LayoutSchema,
|
|
264
|
+
FormComponentSchema,
|
|
265
|
+
DataDisplaySchema,
|
|
266
|
+
FeedbackSchema,
|
|
267
|
+
DisclosureSchema,
|
|
268
|
+
OverlaySchema,
|
|
269
|
+
NavigationSchema,
|
|
270
|
+
ComplexSchema,
|
|
271
|
+
ObjectQLComponentSchema,
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Version information
|
|
276
|
+
*/
|
|
277
|
+
export const SCHEMA_VERSION = '1.0.0';
|
|
@@ -0,0 +1,262 @@
|
|
|
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
|
+
* @object-ui/types/zod - Layout Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for layout and container components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/layout
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Div Schema - Basic HTML container
|
|
24
|
+
*/
|
|
25
|
+
export const DivSchema = BaseSchema.extend({
|
|
26
|
+
type: z.literal('div'),
|
|
27
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Span Schema - Inline text container
|
|
32
|
+
*/
|
|
33
|
+
export const SpanSchema = BaseSchema.extend({
|
|
34
|
+
type: z.literal('span'),
|
|
35
|
+
value: z.string().optional().describe('Text content'),
|
|
36
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Text Schema - Text display component
|
|
41
|
+
*/
|
|
42
|
+
export const TextSchema = BaseSchema.extend({
|
|
43
|
+
type: z.literal('text'),
|
|
44
|
+
value: z.string().optional().describe('Text content'),
|
|
45
|
+
variant: z.enum(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body', 'caption', 'overline'])
|
|
46
|
+
.optional()
|
|
47
|
+
.default('body')
|
|
48
|
+
.describe('Text variant/style'),
|
|
49
|
+
align: z.enum(['left', 'center', 'right', 'justify']).optional().describe('Text alignment'),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Image Schema - Image component
|
|
54
|
+
*/
|
|
55
|
+
export const ImageSchema = BaseSchema.extend({
|
|
56
|
+
type: z.literal('image'),
|
|
57
|
+
src: z.string().describe('Image source URL'),
|
|
58
|
+
alt: z.string().optional().describe('Alt text for accessibility'),
|
|
59
|
+
width: z.union([z.string(), z.number()]).optional().describe('Image width'),
|
|
60
|
+
height: z.union([z.string(), z.number()]).optional().describe('Image height'),
|
|
61
|
+
objectFit: z.enum(['contain', 'cover', 'fill', 'none', 'scale-down']).optional().describe('Object fit property'),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Icon Schema - Icon component (Lucide icons)
|
|
66
|
+
*/
|
|
67
|
+
export const IconSchema = BaseSchema.extend({
|
|
68
|
+
type: z.literal('icon'),
|
|
69
|
+
name: z.string().describe('Icon name (lucide-react)'),
|
|
70
|
+
size: z.number().optional().default(24).describe('Icon size in pixels'),
|
|
71
|
+
color: z.string().optional().describe('Icon color'),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Separator Schema - Divider component
|
|
76
|
+
*/
|
|
77
|
+
export const SeparatorSchema = BaseSchema.extend({
|
|
78
|
+
type: z.literal('separator'),
|
|
79
|
+
orientation: z.enum(['horizontal', 'vertical']).optional().default('horizontal').describe('Separator orientation'),
|
|
80
|
+
decorative: z.boolean().optional().describe('Whether decorative'),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Container Schema - Generic container component
|
|
85
|
+
*/
|
|
86
|
+
export const ContainerSchema = BaseSchema.extend({
|
|
87
|
+
type: z.literal('container'),
|
|
88
|
+
maxWidth: z.union([
|
|
89
|
+
z.enum(['sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', '7xl', 'full', 'screen']),
|
|
90
|
+
z.boolean(),
|
|
91
|
+
]).optional().default('lg').describe('Max width constraint'),
|
|
92
|
+
centered: z.boolean().optional().default(true).describe('Center the container'),
|
|
93
|
+
padding: z.number().optional().describe('Padding value'),
|
|
94
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Flex Schema - Flexbox layout component
|
|
99
|
+
*/
|
|
100
|
+
export const FlexSchema = BaseSchema.extend({
|
|
101
|
+
type: z.literal('flex'),
|
|
102
|
+
direction: z.enum(['row', 'col', 'row-reverse', 'col-reverse'])
|
|
103
|
+
.optional()
|
|
104
|
+
.default('row')
|
|
105
|
+
.describe('Flex direction'),
|
|
106
|
+
justify: z.enum(['start', 'end', 'center', 'between', 'around', 'evenly'])
|
|
107
|
+
.optional()
|
|
108
|
+
.default('start')
|
|
109
|
+
.describe('Justify content alignment'),
|
|
110
|
+
align: z.enum(['start', 'end', 'center', 'baseline', 'stretch'])
|
|
111
|
+
.optional()
|
|
112
|
+
.default('center')
|
|
113
|
+
.describe('Align items'),
|
|
114
|
+
gap: z.number().optional().default(2).describe('Gap between items (Tailwind scale 0-8)'),
|
|
115
|
+
wrap: z.boolean().optional().default(false).describe('Allow items to wrap'),
|
|
116
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Stack Schema - Vertical flex layout (shortcut)
|
|
121
|
+
*/
|
|
122
|
+
export const StackSchema = BaseSchema.extend({
|
|
123
|
+
type: z.literal('stack'),
|
|
124
|
+
direction: z.enum(['row', 'col', 'row-reverse', 'col-reverse']).optional(),
|
|
125
|
+
justify: z.enum(['start', 'end', 'center', 'between', 'around', 'evenly']).optional(),
|
|
126
|
+
align: z.enum(['start', 'end', 'center', 'baseline', 'stretch']).optional(),
|
|
127
|
+
gap: z.number().optional(),
|
|
128
|
+
wrap: z.boolean().optional(),
|
|
129
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Grid Schema - CSS Grid layout component
|
|
134
|
+
*/
|
|
135
|
+
export const GridSchema = BaseSchema.extend({
|
|
136
|
+
type: z.literal('grid'),
|
|
137
|
+
columns: z.union([
|
|
138
|
+
z.number(),
|
|
139
|
+
z.record(z.string(), z.number()),
|
|
140
|
+
]).optional().default(3).describe('Number of columns (responsive)'),
|
|
141
|
+
gap: z.number().optional().default(4).describe('Gap between items (Tailwind scale 0-8)'),
|
|
142
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Card Schema - Card component
|
|
147
|
+
*/
|
|
148
|
+
export const CardSchema = BaseSchema.extend({
|
|
149
|
+
type: z.literal('card'),
|
|
150
|
+
title: z.string().optional().describe('Card title'),
|
|
151
|
+
description: z.string().optional().describe('Card description'),
|
|
152
|
+
header: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Card header content'),
|
|
153
|
+
body: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Card body content'),
|
|
154
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Child components'),
|
|
155
|
+
footer: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Card footer content'),
|
|
156
|
+
variant: z.enum(['default', 'outline', 'ghost']).optional().default('default').describe('Card variant style'),
|
|
157
|
+
hoverable: z.boolean().optional().default(false).describe('Whether the card is hoverable'),
|
|
158
|
+
clickable: z.boolean().optional().default(false).describe('Whether the card is clickable'),
|
|
159
|
+
onClick: z.function().optional().describe('Click handler'),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Tab Item Schema
|
|
164
|
+
*/
|
|
165
|
+
export const TabItemSchema = z.object({
|
|
166
|
+
value: z.string().describe('Unique tab identifier'),
|
|
167
|
+
label: z.string().describe('Tab label'),
|
|
168
|
+
icon: z.string().optional().describe('Tab icon'),
|
|
169
|
+
disabled: z.boolean().optional().describe('Whether tab is disabled'),
|
|
170
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Tab content'),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Tabs Schema - Tabs component
|
|
175
|
+
*/
|
|
176
|
+
export const TabsSchema = BaseSchema.extend({
|
|
177
|
+
type: z.literal('tabs'),
|
|
178
|
+
defaultValue: z.string().optional().describe('Default active tab value'),
|
|
179
|
+
value: z.string().optional().describe('Controlled active tab value'),
|
|
180
|
+
orientation: z.enum(['horizontal', 'vertical']).optional().default('horizontal').describe('Tabs orientation'),
|
|
181
|
+
items: z.array(TabItemSchema).describe('Tab items configuration'),
|
|
182
|
+
onValueChange: z.function().optional().describe('Change handler'),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Scroll Area Schema
|
|
187
|
+
*/
|
|
188
|
+
export const ScrollAreaSchema = BaseSchema.extend({
|
|
189
|
+
type: z.literal('scroll-area'),
|
|
190
|
+
height: z.union([z.string(), z.number()]).optional().describe('Height of scroll container'),
|
|
191
|
+
width: z.union([z.string(), z.number()]).optional().describe('Width of scroll container'),
|
|
192
|
+
orientation: z.enum(['vertical', 'horizontal', 'both']).optional().default('vertical').describe('Scrollbar orientation'),
|
|
193
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Resizable Panel Schema
|
|
198
|
+
*/
|
|
199
|
+
export const ResizablePanelSchema = z.object({
|
|
200
|
+
id: z.string().describe('Unique panel identifier'),
|
|
201
|
+
defaultSize: z.number().optional().describe('Default size (percentage 0-100)'),
|
|
202
|
+
minSize: z.number().optional().describe('Minimum size (percentage 0-100)'),
|
|
203
|
+
maxSize: z.number().optional().describe('Maximum size (percentage 0-100)'),
|
|
204
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Panel content'),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Resizable Schema - Resizable panels component
|
|
209
|
+
*/
|
|
210
|
+
export const ResizableSchema = BaseSchema.extend({
|
|
211
|
+
type: z.literal('resizable'),
|
|
212
|
+
direction: z.enum(['horizontal', 'vertical']).optional().default('horizontal').describe('Direction of resizable panels'),
|
|
213
|
+
minHeight: z.union([z.string(), z.number()]).optional().describe('Minimum height'),
|
|
214
|
+
withHandle: z.boolean().optional().default(true).describe('Show resize handle'),
|
|
215
|
+
panels: z.array(ResizablePanelSchema).describe('Resizable panels'),
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Aspect Ratio Schema
|
|
220
|
+
*/
|
|
221
|
+
export const AspectRatioSchema = BaseSchema.extend({
|
|
222
|
+
type: z.literal('aspect-ratio'),
|
|
223
|
+
ratio: z.number().optional().default(16 / 9).describe('Aspect ratio (width / height)'),
|
|
224
|
+
image: z.string().optional().describe('Image URL to display'),
|
|
225
|
+
alt: z.string().optional().describe('Image alt text'),
|
|
226
|
+
body: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Child components (alternative to image)'),
|
|
227
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Child components'),
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Page Schema - Top-level page layout
|
|
232
|
+
*/
|
|
233
|
+
export const PageSchema = BaseSchema.extend({
|
|
234
|
+
type: z.literal('page'),
|
|
235
|
+
title: z.string().optional().describe('Page title'),
|
|
236
|
+
icon: z.string().optional().describe('Page icon (Lucide icon name)'),
|
|
237
|
+
description: z.string().optional().describe('Page description'),
|
|
238
|
+
body: z.array(SchemaNodeSchema).optional().describe('Main content array'),
|
|
239
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Alternative content prop'),
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Layout Schema Union - All layout component schemas
|
|
244
|
+
*/
|
|
245
|
+
export const LayoutSchema = z.union([
|
|
246
|
+
DivSchema,
|
|
247
|
+
SpanSchema,
|
|
248
|
+
TextSchema,
|
|
249
|
+
ImageSchema,
|
|
250
|
+
IconSchema,
|
|
251
|
+
SeparatorSchema,
|
|
252
|
+
ContainerSchema,
|
|
253
|
+
FlexSchema,
|
|
254
|
+
StackSchema,
|
|
255
|
+
GridSchema,
|
|
256
|
+
CardSchema,
|
|
257
|
+
TabsSchema,
|
|
258
|
+
ScrollAreaSchema,
|
|
259
|
+
ResizableSchema,
|
|
260
|
+
AspectRatioSchema,
|
|
261
|
+
PageSchema,
|
|
262
|
+
]);
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
* @object-ui/types/zod - Navigation Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for navigation components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/navigation
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Nav Link Schema
|
|
24
|
+
*/
|
|
25
|
+
export const NavLinkSchema: z.ZodType<any> = z.lazy(() =>
|
|
26
|
+
z.object({
|
|
27
|
+
label: z.string().describe('Link label'),
|
|
28
|
+
href: z.string().describe('Link URL'),
|
|
29
|
+
icon: z.string().optional().describe('Link icon'),
|
|
30
|
+
active: z.boolean().optional().describe('Whether link is active'),
|
|
31
|
+
disabled: z.boolean().optional().describe('Whether link is disabled'),
|
|
32
|
+
children: z.array(NavLinkSchema).optional().describe('Sub-navigation items'),
|
|
33
|
+
badge: z.union([z.string(), z.number()]).optional().describe('Badge content'),
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Header Bar Schema - Header/navigation bar component
|
|
39
|
+
*/
|
|
40
|
+
export const HeaderBarSchema = BaseSchema.extend({
|
|
41
|
+
type: z.literal('header-bar'),
|
|
42
|
+
title: z.string().optional().describe('Header title'),
|
|
43
|
+
logo: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Logo content'),
|
|
44
|
+
nav: z.array(NavLinkSchema).optional().describe('Navigation links'),
|
|
45
|
+
left: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Left content'),
|
|
46
|
+
center: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Center content'),
|
|
47
|
+
right: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Right content'),
|
|
48
|
+
sticky: z.boolean().optional().describe('Whether header is sticky'),
|
|
49
|
+
height: z.union([z.string(), z.number()]).optional().describe('Header height'),
|
|
50
|
+
variant: z.enum(['default', 'bordered', 'transparent']).optional().describe('Header variant'),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sidebar Schema - Sidebar component
|
|
55
|
+
*/
|
|
56
|
+
export const SidebarSchema = BaseSchema.extend({
|
|
57
|
+
type: z.literal('sidebar'),
|
|
58
|
+
title: z.string().optional().describe('Sidebar title'),
|
|
59
|
+
nav: z.array(NavLinkSchema).optional().describe('Navigation links'),
|
|
60
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Sidebar content'),
|
|
61
|
+
footer: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Sidebar footer'),
|
|
62
|
+
position: z.enum(['left', 'right']).optional().describe('Sidebar position'),
|
|
63
|
+
collapsible: z.boolean().optional().describe('Whether sidebar is collapsible'),
|
|
64
|
+
defaultCollapsed: z.boolean().optional().describe('Default collapsed state'),
|
|
65
|
+
collapsed: z.boolean().optional().describe('Controlled collapsed state'),
|
|
66
|
+
width: z.union([z.string(), z.number()]).optional().describe('Sidebar width'),
|
|
67
|
+
collapsedWidth: z.union([z.string(), z.number()]).optional().describe('Collapsed width'),
|
|
68
|
+
onCollapsedChange: z.function().optional().describe('Collapsed change handler'),
|
|
69
|
+
variant: z.enum(['default', 'bordered', 'floating']).optional().describe('Sidebar variant'),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Breadcrumb Item Schema
|
|
74
|
+
*/
|
|
75
|
+
export const BreadcrumbItemSchema = z.object({
|
|
76
|
+
label: z.string().describe('Breadcrumb label'),
|
|
77
|
+
href: z.string().optional().describe('Link URL'),
|
|
78
|
+
icon: z.string().optional().describe('Breadcrumb icon'),
|
|
79
|
+
onClick: z.function().optional().describe('Click handler'),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Breadcrumb Schema - Breadcrumb navigation
|
|
84
|
+
*/
|
|
85
|
+
export const BreadcrumbSchema = BaseSchema.extend({
|
|
86
|
+
type: z.literal('breadcrumb'),
|
|
87
|
+
items: z.array(BreadcrumbItemSchema).describe('Breadcrumb items'),
|
|
88
|
+
separator: z.string().optional().describe('Custom separator'),
|
|
89
|
+
maxItems: z.number().optional().describe('Maximum items to display'),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Pagination Schema - Pagination component
|
|
94
|
+
*/
|
|
95
|
+
export const PaginationSchema = BaseSchema.extend({
|
|
96
|
+
type: z.literal('pagination'),
|
|
97
|
+
page: z.number().optional().describe('Current page number'),
|
|
98
|
+
totalPages: z.number().describe('Total number of pages'),
|
|
99
|
+
siblings: z.number().optional().describe('Number of sibling pages to show'),
|
|
100
|
+
showFirstLast: z.boolean().optional().describe('Show first/last page buttons'),
|
|
101
|
+
showPrevNext: z.boolean().optional().describe('Show previous/next buttons'),
|
|
102
|
+
onPageChange: z.function().optional().describe('Page change handler'),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Navigation Menu Item Schema
|
|
107
|
+
*/
|
|
108
|
+
export const NavigationMenuItemSchema: z.ZodType<any> = z.lazy(() =>
|
|
109
|
+
z.object({
|
|
110
|
+
label: z.string().describe('Menu item label'),
|
|
111
|
+
href: z.string().optional().describe('Link URL'),
|
|
112
|
+
description: z.string().optional().describe('Item description'),
|
|
113
|
+
icon: z.string().optional().describe('Item icon'),
|
|
114
|
+
children: z.array(NavigationMenuItemSchema).optional().describe('Submenu items'),
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Navigation Menu Schema - Navigation menu component
|
|
120
|
+
*/
|
|
121
|
+
export const NavigationMenuSchema = BaseSchema.extend({
|
|
122
|
+
type: z.literal('navigation-menu'),
|
|
123
|
+
items: z.array(NavigationMenuItemSchema).optional().describe('Menu items'),
|
|
124
|
+
orientation: z.enum(['horizontal', 'vertical']).optional().describe('Menu orientation'),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Button Group Button Schema
|
|
129
|
+
*/
|
|
130
|
+
export const ButtonGroupButtonSchema = z.object({
|
|
131
|
+
label: z.string().describe('Button label'),
|
|
132
|
+
variant: z.enum(['default', 'secondary', 'destructive', 'outline', 'ghost', 'link']).optional(),
|
|
133
|
+
size: z.enum(['default', 'sm', 'lg', 'icon']).optional(),
|
|
134
|
+
disabled: z.boolean().optional().describe('Whether button is disabled'),
|
|
135
|
+
onClick: z.function().optional().describe('Click handler'),
|
|
136
|
+
className: z.string().optional().describe('Button class name'),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Button Group Schema - Button group component
|
|
141
|
+
*/
|
|
142
|
+
export const ButtonGroupSchema = BaseSchema.extend({
|
|
143
|
+
type: z.literal('button-group'),
|
|
144
|
+
buttons: z.array(ButtonGroupButtonSchema).optional().describe('Group buttons'),
|
|
145
|
+
variant: z.enum(['default', 'outline']).optional().describe('Button group variant'),
|
|
146
|
+
size: z.enum(['default', 'sm', 'lg']).optional().describe('Button group size'),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Navigation Schema Union - All navigation component schemas
|
|
151
|
+
*/
|
|
152
|
+
export const NavigationSchema = z.union([
|
|
153
|
+
HeaderBarSchema,
|
|
154
|
+
SidebarSchema,
|
|
155
|
+
BreadcrumbSchema,
|
|
156
|
+
PaginationSchema,
|
|
157
|
+
NavigationMenuSchema,
|
|
158
|
+
ButtonGroupSchema,
|
|
159
|
+
]);
|