@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,268 @@
|
|
|
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 - ObjectQL Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for ObjectQL-specific components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/objectql
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema } from './base.zod';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* HTTP Method Schema
|
|
24
|
+
*/
|
|
25
|
+
export const HttpMethodSchema = z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* HTTP Request Schema
|
|
29
|
+
*/
|
|
30
|
+
export const HttpRequestSchema = z.object({
|
|
31
|
+
url: z.string().describe('API endpoint URL'),
|
|
32
|
+
method: HttpMethodSchema.optional().describe('HTTP method'),
|
|
33
|
+
headers: z.record(z.string(), z.string()).optional().describe('Custom HTTP headers'),
|
|
34
|
+
params: z.record(z.string(), z.unknown()).optional().describe('Query parameters'),
|
|
35
|
+
body: z.union([z.record(z.string(), z.unknown()), z.string(), z.instanceof(FormData), z.instanceof(Blob)]).optional().describe('Request body'),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* View Data Source Schema
|
|
40
|
+
*/
|
|
41
|
+
export const ViewDataSchema = z.union([
|
|
42
|
+
z.object({
|
|
43
|
+
provider: z.literal('object'),
|
|
44
|
+
object: z.string().describe('Target object name'),
|
|
45
|
+
}),
|
|
46
|
+
z.object({
|
|
47
|
+
provider: z.literal('api'),
|
|
48
|
+
read: HttpRequestSchema.optional().describe('Read configuration'),
|
|
49
|
+
write: HttpRequestSchema.optional().describe('Write configuration'),
|
|
50
|
+
}),
|
|
51
|
+
z.object({
|
|
52
|
+
provider: z.literal('value'),
|
|
53
|
+
items: z.array(z.unknown()).describe('Static data array'),
|
|
54
|
+
}),
|
|
55
|
+
]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* List Column Schema
|
|
59
|
+
*/
|
|
60
|
+
export const ListColumnSchema = z.object({
|
|
61
|
+
field: z.string().describe('Field name'),
|
|
62
|
+
label: z.string().optional().describe('Display label'),
|
|
63
|
+
width: z.number().optional().describe('Column width'),
|
|
64
|
+
align: z.enum(['left', 'center', 'right']).optional().describe('Text alignment'),
|
|
65
|
+
hidden: z.boolean().optional().describe('Hide column by default'),
|
|
66
|
+
sortable: z.boolean().optional().describe('Allow sorting'),
|
|
67
|
+
resizable: z.boolean().optional().describe('Allow resizing'),
|
|
68
|
+
wrap: z.boolean().optional().describe('Allow text wrapping'),
|
|
69
|
+
type: z.string().optional().describe('Renderer type override'),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Selection Config Schema
|
|
74
|
+
*/
|
|
75
|
+
export const SelectionConfigSchema = z.object({
|
|
76
|
+
type: z.enum(['none', 'single', 'multiple']).optional().describe('Selection mode'),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Pagination Config Schema
|
|
81
|
+
*/
|
|
82
|
+
export const PaginationConfigSchema = z.object({
|
|
83
|
+
pageSize: z.number().optional().describe('Page size'),
|
|
84
|
+
pageSizeOptions: z.array(z.number()).optional().describe('Page size options'),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Sort Config Schema
|
|
89
|
+
*/
|
|
90
|
+
export const SortConfigSchema = z.object({
|
|
91
|
+
field: z.string().describe('Field to sort by'),
|
|
92
|
+
order: z.enum(['asc', 'desc']).describe('Sort order'),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* ObjectGrid Schema
|
|
97
|
+
*/
|
|
98
|
+
export const ObjectGridSchema = BaseSchema.extend({
|
|
99
|
+
type: z.literal('object-grid'),
|
|
100
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
101
|
+
data: ViewDataSchema.optional().describe('Data source configuration'),
|
|
102
|
+
columns: z.union([z.array(z.string()), z.array(ListColumnSchema)]).optional().describe('Columns configuration'),
|
|
103
|
+
filter: z.array(z.any()).optional().describe('Filter criteria'),
|
|
104
|
+
sort: z.union([z.string(), z.array(SortConfigSchema)]).optional().describe('Sort configuration'),
|
|
105
|
+
searchableFields: z.array(z.string()).optional().describe('Searchable fields'),
|
|
106
|
+
resizable: z.boolean().optional().describe('Enable column resizing'),
|
|
107
|
+
striped: z.boolean().optional().describe('Striped rows'),
|
|
108
|
+
bordered: z.boolean().optional().describe('Show borders'),
|
|
109
|
+
selection: SelectionConfigSchema.optional().describe('Selection configuration'),
|
|
110
|
+
pagination: PaginationConfigSchema.optional().describe('Pagination configuration'),
|
|
111
|
+
|
|
112
|
+
// Legacy fields
|
|
113
|
+
fields: z.array(z.string()).optional(),
|
|
114
|
+
staticData: z.array(z.any()).optional(),
|
|
115
|
+
selectable: z.union([z.boolean(), z.enum(['single', 'multiple'])]).optional(),
|
|
116
|
+
pageSize: z.number().optional(),
|
|
117
|
+
showSearch: z.boolean().optional(),
|
|
118
|
+
showFilters: z.boolean().optional(),
|
|
119
|
+
showPagination: z.boolean().optional(),
|
|
120
|
+
defaultSort: z.object({ field: z.string(), order: z.enum(['asc', 'desc']) }).optional(),
|
|
121
|
+
defaultFilters: z.record(z.string(), z.any()).optional(),
|
|
122
|
+
operators: z.record(z.string(), z.any()).optional(), // Missing in previous TS scan but common
|
|
123
|
+
rowActions: z.array(z.string()).optional(),
|
|
124
|
+
batchActions: z.array(z.string()).optional(),
|
|
125
|
+
editable: z.boolean().optional(),
|
|
126
|
+
keyboardNavigation: z.boolean().optional(),
|
|
127
|
+
frozenColumns: z.number().optional(),
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* ObjectForm Schema
|
|
132
|
+
*/
|
|
133
|
+
export const ObjectFormSchema = BaseSchema.extend({
|
|
134
|
+
type: z.literal('object-form'),
|
|
135
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
136
|
+
mode: z.enum(['create', 'edit', 'view']).describe('Form mode'),
|
|
137
|
+
recordId: z.union([z.string(), z.number()]).optional().describe('Record ID'),
|
|
138
|
+
title: z.string().optional().describe('Form title'),
|
|
139
|
+
description: z.string().optional().describe('Form description'),
|
|
140
|
+
fields: z.array(z.string()).optional().describe('Included fields'),
|
|
141
|
+
customFields: z.array(z.any()).optional().describe('Custom field configs'),
|
|
142
|
+
initialData: z.record(z.string(), z.any()).optional().describe('Initial data'),
|
|
143
|
+
groups: z.array(z.object({
|
|
144
|
+
title: z.string().optional(),
|
|
145
|
+
description: z.string().optional(),
|
|
146
|
+
fields: z.array(z.string()),
|
|
147
|
+
collapsible: z.boolean().optional(),
|
|
148
|
+
defaultCollapsed: z.boolean().optional(),
|
|
149
|
+
})).optional().describe('Field groups'),
|
|
150
|
+
layout: z.enum(['vertical', 'horizontal', 'inline', 'grid']).optional().describe('Form layout'),
|
|
151
|
+
columns: z.number().optional().describe('Grid columns'),
|
|
152
|
+
showSubmit: z.boolean().optional().describe('Show submit button'),
|
|
153
|
+
submitText: z.string().optional().describe('Submit button text'),
|
|
154
|
+
showCancel: z.boolean().optional().describe('Show cancel button'),
|
|
155
|
+
cancelText: z.string().optional().describe('Cancel button text'),
|
|
156
|
+
showReset: z.boolean().optional().describe('Show reset button'),
|
|
157
|
+
initialValues: z.record(z.string(), z.any()).optional().describe('Initial values'),
|
|
158
|
+
readOnly: z.boolean().optional().describe('Read-only mode'),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* ObjectView Schema
|
|
163
|
+
*/
|
|
164
|
+
export const ObjectViewSchema = BaseSchema.extend({
|
|
165
|
+
type: z.literal('object-view'),
|
|
166
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
167
|
+
title: z.string().optional().describe('View title'),
|
|
168
|
+
description: z.string().optional().describe('View description'),
|
|
169
|
+
layout: z.enum(['drawer', 'modal', 'page']).optional().describe('Layout mode'),
|
|
170
|
+
table: z.lazy(() => ObjectGridSchema.omit({ type: true, objectName: true }).partial()).optional().describe('Table config'),
|
|
171
|
+
form: z.lazy(() => ObjectFormSchema.omit({ type: true, objectName: true, mode: true }).partial()).optional().describe('Form config'),
|
|
172
|
+
showSearch: z.boolean().optional().describe('Show search'),
|
|
173
|
+
showFilters: z.boolean().optional().describe('Show filters'),
|
|
174
|
+
showCreate: z.boolean().optional().describe('Show create button'),
|
|
175
|
+
showRefresh: z.boolean().optional().describe('Show refresh button'),
|
|
176
|
+
operations: z.object({
|
|
177
|
+
create: z.boolean().optional(),
|
|
178
|
+
read: z.boolean().optional(),
|
|
179
|
+
update: z.boolean().optional(),
|
|
180
|
+
delete: z.boolean().optional(),
|
|
181
|
+
}).optional().describe('Enabled operations'),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* ListView Schema
|
|
186
|
+
*/
|
|
187
|
+
export const ListViewSchema = BaseSchema.extend({
|
|
188
|
+
type: z.literal('list-view'),
|
|
189
|
+
objectName: z.string().describe('Object Name'),
|
|
190
|
+
viewType: z.enum(['grid', 'kanban', 'calendar', 'gantt', 'map', 'chart']).optional().describe('View Type'),
|
|
191
|
+
fields: z.array(z.string()).optional().describe('Fields to fetch'),
|
|
192
|
+
filters: z.array(z.union([z.array(z.any()), z.string()])).optional().describe('Filter conditions'),
|
|
193
|
+
sort: z.array(SortConfigSchema).optional().describe('Sort order'),
|
|
194
|
+
options: z.record(z.string(), z.any()).optional().describe('Component overrides'),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* ObjectMap Schema
|
|
199
|
+
*/
|
|
200
|
+
export const ObjectMapSchema = BaseSchema.extend({
|
|
201
|
+
type: z.literal('object-map'),
|
|
202
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
203
|
+
locationField: z.string().optional().describe('Location field'),
|
|
204
|
+
titleField: z.string().optional().describe('Title field'),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* ObjectGantt Schema
|
|
209
|
+
*/
|
|
210
|
+
export const ObjectGanttSchema = BaseSchema.extend({
|
|
211
|
+
type: z.literal('object-gantt'),
|
|
212
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
213
|
+
startDateField: z.string().optional().describe('Start date field'),
|
|
214
|
+
endDateField: z.string().optional().describe('End date field'),
|
|
215
|
+
titleField: z.string().optional().describe('Title field'),
|
|
216
|
+
dependencyField: z.string().optional().describe('Dependency field'),
|
|
217
|
+
progressField: z.string().optional().describe('Progress field'),
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* ObjectCalendar Schema
|
|
222
|
+
*/
|
|
223
|
+
export const ObjectCalendarSchema = BaseSchema.extend({
|
|
224
|
+
type: z.literal('object-calendar'),
|
|
225
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
226
|
+
startDateField: z.string().optional().describe('Start date field'),
|
|
227
|
+
endDateField: z.string().optional().describe('End date field'),
|
|
228
|
+
titleField: z.string().optional().describe('Title field'),
|
|
229
|
+
defaultView: z.enum(['month', 'week', 'day', 'agenda']).optional().describe('Default view'),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* ObjectKanban Schema
|
|
234
|
+
*/
|
|
235
|
+
export const ObjectKanbanSchema = BaseSchema.extend({
|
|
236
|
+
type: z.literal('object-kanban'),
|
|
237
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
238
|
+
groupField: z.string().describe('Group field'),
|
|
239
|
+
titleField: z.string().optional().describe('Title field'),
|
|
240
|
+
cardFields: z.array(z.string()).optional().describe('Card fields'),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* ObjectChart Schema
|
|
245
|
+
*/
|
|
246
|
+
export const ObjectChartSchema = BaseSchema.extend({
|
|
247
|
+
type: z.literal('object-chart'),
|
|
248
|
+
objectName: z.string().describe('ObjectQL object name'),
|
|
249
|
+
chartType: z.enum(['bar', 'line', 'pie', 'area', 'scatter']).describe('Chart type'),
|
|
250
|
+
xAxisField: z.string().describe('X axis field'),
|
|
251
|
+
yAxisFields: z.array(z.string()).optional().describe('Y axis fields'),
|
|
252
|
+
aggregation: z.enum(['cardinality', 'sum', 'avg', 'min', 'max']).optional().describe('Aggregation'),
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* ObjectQL Component Schema Union
|
|
257
|
+
*/
|
|
258
|
+
export const ObjectQLComponentSchema = z.union([
|
|
259
|
+
ObjectGridSchema,
|
|
260
|
+
ObjectFormSchema,
|
|
261
|
+
ObjectViewSchema,
|
|
262
|
+
ObjectMapSchema,
|
|
263
|
+
ObjectGanttSchema,
|
|
264
|
+
ObjectCalendarSchema,
|
|
265
|
+
ObjectKanbanSchema,
|
|
266
|
+
ObjectChartSchema,
|
|
267
|
+
ListViewSchema,
|
|
268
|
+
]);
|
|
@@ -0,0 +1,196 @@
|
|
|
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 - Overlay Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for overlay, modal, and popup components.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* @module zod/overlay
|
|
16
|
+
* @packageDocumentation
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Dialog Schema - Dialog/modal component
|
|
24
|
+
*/
|
|
25
|
+
export const DialogSchema = BaseSchema.extend({
|
|
26
|
+
type: z.literal('dialog'),
|
|
27
|
+
title: z.string().optional().describe('Dialog title'),
|
|
28
|
+
description: z.string().optional().describe('Dialog description'),
|
|
29
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog content'),
|
|
30
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog trigger'),
|
|
31
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
32
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
33
|
+
footer: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog footer'),
|
|
34
|
+
modal: z.boolean().optional().describe('Whether dialog is modal'),
|
|
35
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Alert Dialog Schema - Alert dialog component
|
|
40
|
+
*/
|
|
41
|
+
export const AlertDialogSchema = BaseSchema.extend({
|
|
42
|
+
type: z.literal('alert-dialog'),
|
|
43
|
+
title: z.string().optional().describe('Alert dialog title'),
|
|
44
|
+
description: z.string().optional().describe('Alert dialog description'),
|
|
45
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog trigger'),
|
|
46
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
47
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
48
|
+
cancelLabel: z.string().optional().describe('Cancel button label'),
|
|
49
|
+
confirmLabel: z.string().optional().describe('Confirm button label'),
|
|
50
|
+
confirmVariant: z.enum(['default', 'destructive']).optional().describe('Confirm button variant'),
|
|
51
|
+
onConfirm: z.function().optional().describe('Confirm handler'),
|
|
52
|
+
onCancel: z.function().optional().describe('Cancel handler'),
|
|
53
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Sheet Schema - Sheet/side panel component
|
|
58
|
+
*/
|
|
59
|
+
export const SheetSchema = BaseSchema.extend({
|
|
60
|
+
type: z.literal('sheet'),
|
|
61
|
+
title: z.string().optional().describe('Sheet title'),
|
|
62
|
+
description: z.string().optional().describe('Sheet description'),
|
|
63
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Sheet content'),
|
|
64
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Sheet trigger'),
|
|
65
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
66
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
67
|
+
side: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Sheet position'),
|
|
68
|
+
footer: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Sheet footer'),
|
|
69
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Drawer Schema - Drawer component
|
|
74
|
+
*/
|
|
75
|
+
export const DrawerSchema = BaseSchema.extend({
|
|
76
|
+
type: z.literal('drawer'),
|
|
77
|
+
title: z.string().optional().describe('Drawer title'),
|
|
78
|
+
description: z.string().optional().describe('Drawer description'),
|
|
79
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Drawer content'),
|
|
80
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Drawer trigger'),
|
|
81
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
82
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
83
|
+
direction: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Drawer direction'),
|
|
84
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Popover Schema - Popover component
|
|
89
|
+
*/
|
|
90
|
+
export const PopoverSchema = BaseSchema.extend({
|
|
91
|
+
type: z.literal('popover'),
|
|
92
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Popover content'),
|
|
93
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Popover trigger'),
|
|
94
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
95
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
96
|
+
side: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Popover side'),
|
|
97
|
+
align: z.enum(['start', 'center', 'end']).optional().describe('Popover alignment'),
|
|
98
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Tooltip Schema - Tooltip component
|
|
103
|
+
*/
|
|
104
|
+
export const TooltipSchema = BaseSchema.extend({
|
|
105
|
+
type: z.literal('tooltip'),
|
|
106
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Tooltip content'),
|
|
107
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Tooltip children'),
|
|
108
|
+
side: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Tooltip side'),
|
|
109
|
+
align: z.enum(['start', 'center', 'end']).optional().describe('Tooltip alignment'),
|
|
110
|
+
delayDuration: z.number().optional().describe('Delay before showing (ms)'),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Hover Card Schema - Hover card component
|
|
115
|
+
*/
|
|
116
|
+
export const HoverCardSchema = BaseSchema.extend({
|
|
117
|
+
type: z.literal('hover-card'),
|
|
118
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Hover card content'),
|
|
119
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Hover card trigger'),
|
|
120
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
121
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
122
|
+
side: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Hover card side'),
|
|
123
|
+
openDelay: z.number().optional().describe('Delay before opening (ms)'),
|
|
124
|
+
closeDelay: z.number().optional().describe('Delay before closing (ms)'),
|
|
125
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Menu Item Schema
|
|
130
|
+
*/
|
|
131
|
+
export const MenuItemSchema: z.ZodType<any> = z.lazy(() =>
|
|
132
|
+
z.object({
|
|
133
|
+
label: z.string().describe('Menu item label'),
|
|
134
|
+
icon: z.string().optional().describe('Menu item icon'),
|
|
135
|
+
disabled: z.boolean().optional().describe('Whether item is disabled'),
|
|
136
|
+
onClick: z.function().optional().describe('Click handler'),
|
|
137
|
+
shortcut: z.string().optional().describe('Keyboard shortcut'),
|
|
138
|
+
children: z.array(MenuItemSchema).optional().describe('Submenu items'),
|
|
139
|
+
separator: z.boolean().optional().describe('Whether this is a separator'),
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Dropdown Menu Schema - Dropdown menu component
|
|
145
|
+
*/
|
|
146
|
+
export const DropdownMenuSchema = BaseSchema.extend({
|
|
147
|
+
type: z.literal('dropdown-menu'),
|
|
148
|
+
items: z.array(MenuItemSchema).describe('Menu items'),
|
|
149
|
+
trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Menu trigger'),
|
|
150
|
+
defaultOpen: z.boolean().optional().describe('Default open state'),
|
|
151
|
+
open: z.boolean().optional().describe('Controlled open state'),
|
|
152
|
+
side: z.enum(['top', 'right', 'bottom', 'left']).optional().describe('Menu side'),
|
|
153
|
+
align: z.enum(['start', 'center', 'end']).optional().describe('Menu alignment'),
|
|
154
|
+
onOpenChange: z.function().optional().describe('Open change handler'),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Context Menu Schema - Context menu component
|
|
159
|
+
*/
|
|
160
|
+
export const ContextMenuSchema = BaseSchema.extend({
|
|
161
|
+
type: z.literal('context-menu'),
|
|
162
|
+
items: z.array(MenuItemSchema).describe('Menu items'),
|
|
163
|
+
children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Context menu children'),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Menubar Menu Schema
|
|
168
|
+
*/
|
|
169
|
+
export const MenubarMenuSchema = z.object({
|
|
170
|
+
label: z.string().describe('Menu label'),
|
|
171
|
+
items: z.array(MenuItemSchema).describe('Menu items'),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Menubar Schema - Menubar component
|
|
176
|
+
*/
|
|
177
|
+
export const MenubarSchema = BaseSchema.extend({
|
|
178
|
+
type: z.literal('menubar'),
|
|
179
|
+
menus: z.array(MenubarMenuSchema).optional().describe('Menubar menus'),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Overlay Schema Union - All overlay component schemas
|
|
184
|
+
*/
|
|
185
|
+
export const OverlaySchema = z.union([
|
|
186
|
+
DialogSchema,
|
|
187
|
+
AlertDialogSchema,
|
|
188
|
+
SheetSchema,
|
|
189
|
+
DrawerSchema,
|
|
190
|
+
PopoverSchema,
|
|
191
|
+
TooltipSchema,
|
|
192
|
+
HoverCardSchema,
|
|
193
|
+
DropdownMenuSchema,
|
|
194
|
+
ContextMenuSchema,
|
|
195
|
+
MenubarSchema,
|
|
196
|
+
]);
|