@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.
Files changed (115) hide show
  1. package/README.md +19 -11
  2. package/dist/api-types.d.ts +7 -0
  3. package/dist/api-types.d.ts.map +1 -1
  4. package/dist/api-types.js +4 -6
  5. package/dist/app.d.ts +7 -0
  6. package/dist/app.d.ts.map +1 -1
  7. package/dist/app.js +4 -3
  8. package/dist/base.d.ts +7 -0
  9. package/dist/base.d.ts.map +1 -1
  10. package/dist/base.js +4 -6
  11. package/dist/complex.d.ts +68 -1
  12. package/dist/complex.d.ts.map +1 -1
  13. package/dist/complex.js +4 -5
  14. package/dist/crud.d.ts +7 -0
  15. package/dist/crud.d.ts.map +1 -1
  16. package/dist/crud.js +4 -6
  17. package/dist/data-display.d.ts +54 -2
  18. package/dist/data-display.d.ts.map +1 -1
  19. package/dist/data-display.js +4 -5
  20. package/dist/data.d.ts +16 -0
  21. package/dist/data.d.ts.map +1 -1
  22. package/dist/data.js +4 -6
  23. package/dist/disclosure.d.ts +70 -1
  24. package/dist/disclosure.d.ts.map +1 -1
  25. package/dist/disclosure.js +4 -5
  26. package/dist/feedback.d.ts +68 -1
  27. package/dist/feedback.d.ts.map +1 -1
  28. package/dist/feedback.js +4 -5
  29. package/dist/field-types.d.ts +386 -0
  30. package/dist/field-types.d.ts.map +1 -0
  31. package/dist/field-types.js +8 -0
  32. package/dist/form.d.ts +123 -1
  33. package/dist/form.d.ts.map +1 -1
  34. package/dist/form.js +4 -5
  35. package/dist/index.d.ts +21 -13
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +4 -37
  38. package/dist/layout.d.ts +66 -16
  39. package/dist/layout.d.ts.map +1 -1
  40. package/dist/layout.js +4 -6
  41. package/dist/navigation.d.ts +102 -2
  42. package/dist/navigation.d.ts.map +1 -1
  43. package/dist/navigation.js +4 -5
  44. package/dist/objectql.d.ts +484 -54
  45. package/dist/objectql.d.ts.map +1 -1
  46. package/dist/objectql.js +4 -6
  47. package/dist/overlay.d.ts +31 -1
  48. package/dist/overlay.d.ts.map +1 -1
  49. package/dist/overlay.js +4 -5
  50. package/dist/registry.d.ts +7 -0
  51. package/dist/registry.d.ts.map +1 -1
  52. package/dist/registry.js +7 -0
  53. package/dist/zod/base.zod.d.ts +202 -0
  54. package/dist/zod/base.zod.d.ts.map +1 -0
  55. package/dist/zod/base.zod.js +198 -0
  56. package/dist/zod/complex.zod.d.ts +742 -0
  57. package/dist/zod/complex.zod.d.ts.map +1 -0
  58. package/dist/zod/complex.zod.js +233 -0
  59. package/dist/zod/data-display.zod.d.ts +996 -0
  60. package/dist/zod/data-display.zod.d.ts.map +1 -0
  61. package/dist/zod/data-display.zod.js +266 -0
  62. package/dist/zod/disclosure.zod.d.ts +267 -0
  63. package/dist/zod/disclosure.zod.d.ts.map +1 -0
  64. package/dist/zod/disclosure.zod.js +84 -0
  65. package/dist/zod/feedback.zod.d.ts +538 -0
  66. package/dist/zod/feedback.zod.d.ts.map +1 -0
  67. package/dist/zod/feedback.zod.js +127 -0
  68. package/dist/zod/form.zod.d.ts +1308 -0
  69. package/dist/zod/form.zod.d.ts.map +1 -0
  70. package/dist/zod/form.zod.js +406 -0
  71. package/dist/zod/index.zod.d.ts +3174 -0
  72. package/dist/zod/index.zod.d.ts.map +1 -0
  73. package/dist/zod/index.zod.js +106 -0
  74. package/dist/zod/layout.zod.d.ts +1048 -0
  75. package/dist/zod/layout.zod.d.ts.map +1 -0
  76. package/dist/zod/layout.zod.js +241 -0
  77. package/dist/zod/navigation.zod.d.ts +486 -0
  78. package/dist/zod/navigation.zod.d.ts.map +1 -0
  79. package/dist/zod/navigation.zod.js +142 -0
  80. package/dist/zod/objectql.zod.d.ts +1261 -0
  81. package/dist/zod/objectql.zod.d.ts.map +1 -0
  82. package/dist/zod/objectql.zod.js +248 -0
  83. package/dist/zod/overlay.zod.d.ts +691 -0
  84. package/dist/zod/overlay.zod.d.ts.map +1 -0
  85. package/dist/zod/overlay.zod.js +179 -0
  86. package/package.json +9 -1
  87. package/src/api-types.ts +8 -0
  88. package/src/app.ts +8 -0
  89. package/src/base.ts +8 -0
  90. package/src/complex.ts +69 -1
  91. package/src/crud.ts +8 -0
  92. package/src/data-display.ts +60 -2
  93. package/src/data.ts +18 -0
  94. package/src/disclosure.ts +74 -1
  95. package/src/feedback.ts +76 -2
  96. package/src/field-types.ts +465 -0
  97. package/src/form.ts +131 -1
  98. package/src/index.ts +91 -8
  99. package/src/layout.ts +70 -15
  100. package/src/navigation.ts +109 -2
  101. package/src/objectql.ts +555 -59
  102. package/src/overlay.ts +35 -1
  103. package/src/registry.ts +8 -0
  104. package/src/zod/README.md +329 -0
  105. package/src/zod/base.zod.ts +229 -0
  106. package/src/zod/complex.zod.ts +258 -0
  107. package/src/zod/data-display.zod.ts +290 -0
  108. package/src/zod/disclosure.zod.ts +92 -0
  109. package/src/zod/feedback.zod.ts +138 -0
  110. package/src/zod/form.zod.ts +434 -0
  111. package/src/zod/index.zod.ts +277 -0
  112. package/src/zod/layout.zod.ts +262 -0
  113. package/src/zod/navigation.zod.ts +159 -0
  114. package/src/zod/objectql.zod.ts +268 -0
  115. package/src/zod/overlay.zod.ts +196 -0
@@ -0,0 +1,258 @@
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 - Complex Component Zod Validators
11
+ *
12
+ * Zod validation schemas for advanced/composite components.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/complex
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema, SchemaNodeSchema } from './base.zod';
21
+
22
+ /**
23
+ * Kanban Card Schema
24
+ */
25
+ export const KanbanCardSchema = z.object({
26
+ id: z.string().describe('Card ID'),
27
+ title: z.string().describe('Card title'),
28
+ description: z.string().optional().describe('Card description'),
29
+ labels: z.array(z.string()).optional().describe('Card labels'),
30
+ assignees: z.array(z.string()).optional().describe('Card assignees'),
31
+ dueDate: z.union([z.string(), z.date()]).optional().describe('Due date'),
32
+ priority: z.enum(['low', 'medium', 'high', 'critical']).optional().describe('Card priority'),
33
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Custom content'),
34
+ data: z.any().optional().describe('Custom card data'),
35
+ });
36
+
37
+ /**
38
+ * Kanban Column Schema
39
+ */
40
+ export const KanbanColumnSchema = z.object({
41
+ id: z.string().describe('Column ID'),
42
+ title: z.string().describe('Column title'),
43
+ items: z.array(KanbanCardSchema).describe('Column cards'),
44
+ color: z.string().optional().describe('Column color'),
45
+ limit: z.number().optional().describe('Card limit'),
46
+ collapsed: z.boolean().optional().describe('Whether column is collapsed'),
47
+ });
48
+
49
+ /**
50
+ * Kanban Schema - Kanban board component
51
+ */
52
+ export const KanbanSchema = BaseSchema.extend({
53
+ type: z.literal('kanban'),
54
+ columns: z.array(KanbanColumnSchema).describe('Kanban columns'),
55
+ draggable: z.boolean().optional().describe('Whether cards are draggable'),
56
+ onCardMove: z.function().optional().describe('Card move handler'),
57
+ onCardClick: z.function().optional().describe('Card click handler'),
58
+ onColumnAdd: z.function().optional().describe('Column add handler'),
59
+ onCardAdd: z.function().optional().describe('Card add handler'),
60
+ });
61
+
62
+ /**
63
+ * Calendar View Mode
64
+ */
65
+ export const CalendarViewModeSchema = z.enum(['month', 'week', 'day', 'agenda']);
66
+
67
+ /**
68
+ * Calendar Event Schema
69
+ */
70
+ export const CalendarEventSchema = z.object({
71
+ id: z.string().describe('Event ID'),
72
+ title: z.string().describe('Event title'),
73
+ description: z.string().optional().describe('Event description'),
74
+ start: z.union([z.string(), z.date()]).describe('Event start time'),
75
+ end: z.union([z.string(), z.date()]).describe('Event end time'),
76
+ allDay: z.boolean().optional().describe('Whether event is all-day'),
77
+ color: z.string().optional().describe('Event color'),
78
+ data: z.any().optional().describe('Custom event data'),
79
+ });
80
+
81
+ /**
82
+ * Calendar View Schema - Calendar component
83
+ */
84
+ export const CalendarViewSchema = BaseSchema.extend({
85
+ type: z.literal('calendar-view'),
86
+ events: z.array(CalendarEventSchema).describe('Calendar events'),
87
+ defaultView: CalendarViewModeSchema.optional().describe('Default view mode'),
88
+ view: CalendarViewModeSchema.optional().describe('Controlled view mode'),
89
+ defaultDate: z.union([z.string(), z.date()]).optional().describe('Default date'),
90
+ date: z.union([z.string(), z.date()]).optional().describe('Controlled date'),
91
+ views: z.array(CalendarViewModeSchema).optional().describe('Available views'),
92
+ editable: z.boolean().optional().describe('Whether events are editable'),
93
+ onEventClick: z.function().optional().describe('Event click handler'),
94
+ onEventCreate: z.function().optional().describe('Event create handler'),
95
+ onEventUpdate: z.function().optional().describe('Event update handler'),
96
+ onDateChange: z.function().optional().describe('Date change handler'),
97
+ onViewChange: z.function().optional().describe('View change handler'),
98
+ });
99
+
100
+ /**
101
+ * Filter Operator Enum
102
+ */
103
+ export const FilterOperatorSchema = z.enum([
104
+ 'equals',
105
+ 'not_equals',
106
+ 'contains',
107
+ 'not_contains',
108
+ 'starts_with',
109
+ 'ends_with',
110
+ 'greater_than',
111
+ 'greater_than_or_equal',
112
+ 'less_than',
113
+ 'less_than_or_equal',
114
+ 'in',
115
+ 'not_in',
116
+ 'is_null',
117
+ 'is_not_null',
118
+ ]);
119
+
120
+ /**
121
+ * Filter Condition Schema
122
+ */
123
+ export const FilterConditionSchema: z.ZodType<any> = z.lazy(() =>
124
+ z.object({
125
+ field: z.string().describe('Field name'),
126
+ operator: FilterOperatorSchema.describe('Filter operator'),
127
+ value: z.any().optional().describe('Filter value'),
128
+ })
129
+ );
130
+
131
+ /**
132
+ * Filter Group Schema
133
+ */
134
+ export const FilterGroupSchema: z.ZodType<any> = z.lazy(() =>
135
+ z.object({
136
+ operator: z.enum(['and', 'or']).describe('Group operator'),
137
+ conditions: z.array(z.union([FilterConditionSchema, FilterGroupSchema])).describe('Conditions or sub-groups'),
138
+ })
139
+ );
140
+
141
+ /**
142
+ * Filter Field Schema
143
+ */
144
+ export const FilterFieldSchema = z.object({
145
+ name: z.string().describe('Field name'),
146
+ label: z.string().describe('Field label'),
147
+ type: z.enum(['string', 'number', 'date', 'boolean', 'select']).describe('Field type'),
148
+ operators: z.array(FilterOperatorSchema).optional().describe('Available operators'),
149
+ options: z.array(z.object({
150
+ label: z.string(),
151
+ value: z.any(),
152
+ })).optional().describe('Options for select type'),
153
+ });
154
+
155
+ /**
156
+ * Filter Builder Schema - Filter builder component
157
+ */
158
+ export const FilterBuilderSchema = BaseSchema.extend({
159
+ type: z.literal('filter-builder'),
160
+ fields: z.array(FilterFieldSchema).describe('Available filter fields'),
161
+ defaultValue: z.union([FilterConditionSchema, FilterGroupSchema]).optional().describe('Default filter value'),
162
+ value: z.union([FilterConditionSchema, FilterGroupSchema]).optional().describe('Controlled filter value'),
163
+ onChange: z.function().optional().describe('Change handler'),
164
+ allowGroups: z.boolean().optional().describe('Allow grouped conditions'),
165
+ maxDepth: z.number().optional().describe('Maximum nesting depth'),
166
+ });
167
+
168
+ /**
169
+ * Carousel Item Schema
170
+ */
171
+ export const CarouselItemSchema = z.object({
172
+ id: z.string().optional().describe('Item ID'),
173
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Item content'),
174
+ });
175
+
176
+ /**
177
+ * Carousel Schema - Carousel component
178
+ */
179
+ export const CarouselSchema = BaseSchema.extend({
180
+ type: z.literal('carousel'),
181
+ items: z.array(CarouselItemSchema).describe('Carousel items'),
182
+ autoPlay: z.number().optional().describe('Auto-play interval (ms)'),
183
+ showArrows: z.boolean().optional().describe('Show navigation arrows'),
184
+ showDots: z.boolean().optional().describe('Show navigation dots'),
185
+ loop: z.boolean().optional().describe('Enable infinite loop'),
186
+ itemsPerView: z.number().optional().describe('Items per view'),
187
+ gap: z.number().optional().describe('Gap between items'),
188
+ onSlideChange: z.function().optional().describe('Slide change handler'),
189
+ });
190
+
191
+ /**
192
+ * Chat Message Schema
193
+ */
194
+ export const ChatMessageSchema = z.object({
195
+ id: z.string().describe('Message ID'),
196
+ role: z.enum(['user', 'assistant', 'system']).describe('Message role'),
197
+ content: z.string().describe('Message content'),
198
+ timestamp: z.union([z.string(), z.date()]).optional().describe('Message timestamp'),
199
+ metadata: z.record(z.string(), z.any()).optional().describe('Custom metadata'),
200
+ });
201
+
202
+ /**
203
+ * Chatbot Schema - Chatbot component
204
+ */
205
+ export const ChatbotSchema = BaseSchema.extend({
206
+ type: z.literal('chatbot'),
207
+ messages: z.array(ChatMessageSchema).describe('Chat messages'),
208
+ placeholder: z.string().optional().describe('Input placeholder'),
209
+ loading: z.boolean().optional().describe('Whether chat is loading'),
210
+ onSendMessage: z.function().optional().describe('Send message handler'),
211
+ showAvatars: z.boolean().optional().describe('Show user avatars'),
212
+ userAvatar: z.string().optional().describe('User avatar URL'),
213
+ assistantAvatar: z.string().optional().describe('Assistant avatar URL'),
214
+ markdown: z.boolean().optional().describe('Enable markdown rendering'),
215
+ height: z.union([z.string(), z.number()]).optional().describe('Chatbot height'),
216
+ });
217
+
218
+ /**
219
+ * Dashboard Widget Layout Schema
220
+ */
221
+ export const DashboardWidgetLayoutSchema = z.object({
222
+ x: z.number().describe('Grid x position'),
223
+ y: z.number().describe('Grid y position'),
224
+ w: z.number().describe('Grid width'),
225
+ h: z.number().describe('Grid height'),
226
+ });
227
+
228
+ /**
229
+ * Dashboard Widget Schema
230
+ */
231
+ export const DashboardWidgetSchema = z.object({
232
+ id: z.string().describe('Widget ID'),
233
+ title: z.string().optional().describe('Widget Title'),
234
+ component: SchemaNodeSchema.describe('Widget Component'),
235
+ layout: DashboardWidgetLayoutSchema.optional().describe('Widget Layout'),
236
+ });
237
+
238
+ /**
239
+ * Dashboard Schema - Dashboard component
240
+ */
241
+ export const DashboardSchema = BaseSchema.extend({
242
+ type: z.literal('dashboard'),
243
+ columns: z.number().optional().describe('Number of columns'),
244
+ gap: z.number().optional().describe('Grid gap'),
245
+ widgets: z.array(DashboardWidgetSchema).describe('Dashboard widgets'),
246
+ });
247
+
248
+ /**
249
+ * Complex Schema Union - All complex component schemas
250
+ */
251
+ export const ComplexSchema = z.union([
252
+ KanbanSchema,
253
+ CalendarViewSchema,
254
+ FilterBuilderSchema,
255
+ CarouselSchema,
256
+ ChatbotSchema,
257
+ DashboardSchema,
258
+ ]);
@@ -0,0 +1,290 @@
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 - Data Display Component Zod Validators
11
+ *
12
+ * Zod validation schemas for data display and information presentation components.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/data-display
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema, SchemaNodeSchema } from './base.zod';
21
+
22
+ /**
23
+ * Alert Schema - Alert/notification component
24
+ */
25
+ export const AlertSchema = BaseSchema.extend({
26
+ type: z.literal('alert'),
27
+ title: z.string().optional().describe('Alert title'),
28
+ description: z.string().optional().describe('Alert description'),
29
+ variant: z.enum(['default', 'destructive']).optional().describe('Alert variant'),
30
+ icon: z.string().optional().describe('Alert icon'),
31
+ dismissible: z.boolean().optional().describe('Whether alert can be dismissed'),
32
+ onDismiss: z.function().optional().describe('Dismiss handler'),
33
+ children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
34
+ });
35
+
36
+ /**
37
+ * Statistic Schema - Statistic display component
38
+ */
39
+ export const StatisticSchema = BaseSchema.extend({
40
+ type: z.literal('statistic'),
41
+ label: z.string().optional().describe('Statistic label'),
42
+ value: z.union([z.string(), z.number()]).describe('Statistic value'),
43
+ trend: z.enum(['up', 'down', 'neutral']).optional().describe('Trend indicator'),
44
+ description: z.string().optional().describe('Description text'),
45
+ icon: z.string().optional().describe('Statistic icon'),
46
+ });
47
+
48
+ /**
49
+ * Badge Schema - Badge/tag component
50
+ */
51
+ export const BadgeSchema = BaseSchema.extend({
52
+ type: z.literal('badge'),
53
+ label: z.string().optional().describe('Badge label'),
54
+ variant: z.enum(['default', 'secondary', 'destructive', 'outline']).optional().describe('Badge variant'),
55
+ icon: z.string().optional().describe('Badge icon'),
56
+ children: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional(),
57
+ });
58
+
59
+ /**
60
+ * Avatar Schema - Avatar/profile picture component
61
+ */
62
+ export const AvatarSchema = BaseSchema.extend({
63
+ type: z.literal('avatar'),
64
+ src: z.string().optional().describe('Image source URL'),
65
+ alt: z.string().optional().describe('Alt text'),
66
+ fallback: z.string().optional().describe('Fallback text/initials'),
67
+ size: z.enum(['sm', 'default', 'lg', 'xl']).optional().describe('Avatar size'),
68
+ shape: z.enum(['circle', 'square']).optional().describe('Avatar shape'),
69
+ });
70
+
71
+ /**
72
+ * List Item Schema
73
+ */
74
+ export const ListItemSchema = z.object({
75
+ id: z.string().optional().describe('Item ID'),
76
+ label: z.string().optional().describe('Item label'),
77
+ description: z.string().optional().describe('Item description'),
78
+ icon: z.string().optional().describe('Item icon'),
79
+ avatar: z.string().optional().describe('Item avatar URL'),
80
+ disabled: z.boolean().optional().describe('Whether item is disabled'),
81
+ onClick: z.function().optional().describe('Click handler'),
82
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Custom content'),
83
+ });
84
+
85
+ /**
86
+ * List Schema - List component
87
+ */
88
+ export const ListSchema = BaseSchema.extend({
89
+ type: z.literal('list'),
90
+ items: z.array(ListItemSchema).describe('List items'),
91
+ ordered: z.boolean().optional().describe('Whether list is ordered'),
92
+ dividers: z.boolean().optional().describe('Show dividers between items'),
93
+ dense: z.boolean().optional().describe('Dense spacing'),
94
+ });
95
+
96
+ /**
97
+ * Table Column Schema
98
+ */
99
+ export const TableColumnSchema = z.object({
100
+ header: z.string().describe('Column header text'),
101
+ accessorKey: z.string().describe('Data accessor key'),
102
+ className: z.string().optional().describe('Column class name'),
103
+ cellClassName: z.string().optional().describe('Cell class name'),
104
+ width: z.union([z.string(), z.number()]).optional().describe('Column width'),
105
+ minWidth: z.union([z.string(), z.number()]).optional().describe('Minimum width'),
106
+ align: z.enum(['left', 'center', 'right']).optional().describe('Column alignment'),
107
+ fixed: z.enum(['left', 'right']).optional().describe('Fixed column position'),
108
+ type: z.string().optional().describe('Column type'),
109
+ sortable: z.boolean().optional().describe('Whether column is sortable'),
110
+ filterable: z.boolean().optional().describe('Whether column is filterable'),
111
+ resizable: z.boolean().optional().describe('Whether column is resizable'),
112
+ cell: z.function().optional().describe('Custom cell renderer'),
113
+ });
114
+
115
+ /**
116
+ * Table Schema - Simple table component
117
+ */
118
+ export const TableSchema = BaseSchema.extend({
119
+ type: z.literal('table'),
120
+ caption: z.string().optional().describe('Table caption'),
121
+ columns: z.array(TableColumnSchema).describe('Table columns'),
122
+ data: z.array(z.any()).describe('Table data'),
123
+ footer: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Table footer'),
124
+ hoverable: z.boolean().optional().describe('Highlight rows on hover'),
125
+ striped: z.boolean().optional().describe('Striped rows'),
126
+ });
127
+
128
+ /**
129
+ * Data Table Schema - Advanced data table with features
130
+ */
131
+ export const DataTableSchema = BaseSchema.extend({
132
+ type: z.literal('data-table'),
133
+ caption: z.string().optional().describe('Table caption'),
134
+ toolbar: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Toolbar content'),
135
+ columns: z.array(TableColumnSchema).describe('Table columns'),
136
+ data: z.array(z.any()).describe('Table data'),
137
+ pagination: z.boolean().optional().describe('Enable pagination'),
138
+ pageSize: z.number().optional().describe('Default page size'),
139
+ searchable: z.boolean().optional().describe('Enable search'),
140
+ selectable: z.boolean().optional().describe('Enable row selection'),
141
+ sortable: z.boolean().optional().describe('Enable sorting'),
142
+ exportable: z.boolean().optional().describe('Enable data export'),
143
+ rowActions: z.array(z.any()).optional().describe('Row action buttons'),
144
+ resizableColumns: z.boolean().optional().describe('Allow column resizing'),
145
+ reorderableColumns: z.boolean().optional().describe('Allow column reordering'),
146
+ onRowEdit: z.function().optional().describe('Row edit handler'),
147
+ onRowDelete: z.function().optional().describe('Row delete handler'),
148
+ onSelectionChange: z.function().optional().describe('Selection change handler'),
149
+ onColumnsReorder: z.function().optional().describe('Column reorder handler'),
150
+ });
151
+
152
+ /**
153
+ * Markdown Schema - Markdown content renderer
154
+ */
155
+ export const MarkdownSchema = BaseSchema.extend({
156
+ type: z.literal('markdown'),
157
+ content: z.string().describe('Markdown content'),
158
+ sanitize: z.boolean().optional().describe('Sanitize HTML'),
159
+ components: z.record(z.string(), z.any()).optional().describe('Custom component overrides'),
160
+ });
161
+
162
+ /**
163
+ * Tree Node Schema
164
+ */
165
+ export const TreeNodeSchema: z.ZodType<any> = z.lazy(() =>
166
+ z.object({
167
+ id: z.string().describe('Node ID'),
168
+ label: z.string().describe('Node label'),
169
+ icon: z.string().optional().describe('Node icon'),
170
+ defaultExpanded: z.boolean().optional().describe('Default expanded state'),
171
+ selectable: z.boolean().optional().describe('Whether node is selectable'),
172
+ children: z.array(TreeNodeSchema).optional().describe('Child nodes'),
173
+ data: z.any().optional().describe('Custom node data'),
174
+ })
175
+ );
176
+
177
+ /**
178
+ * Tree View Schema - Tree/hierarchical view component
179
+ */
180
+ export const TreeViewSchema = BaseSchema.extend({
181
+ type: z.literal('tree-view'),
182
+ data: z.array(TreeNodeSchema).describe('Tree data'),
183
+ defaultExpandedIds: z.array(z.string()).optional().describe('Default expanded node IDs'),
184
+ defaultSelectedIds: z.array(z.string()).optional().describe('Default selected node IDs'),
185
+ expandedIds: z.array(z.string()).optional().describe('Controlled expanded node IDs'),
186
+ selectedIds: z.array(z.string()).optional().describe('Controlled selected node IDs'),
187
+ multiSelect: z.boolean().optional().describe('Allow multiple selection'),
188
+ showLines: z.boolean().optional().describe('Show connecting lines'),
189
+ onSelectChange: z.function().optional().describe('Selection change handler'),
190
+ onExpandChange: z.function().optional().describe('Expand change handler'),
191
+ });
192
+
193
+ /**
194
+ * Chart Type Enum
195
+ */
196
+ export const ChartTypeSchema = z.enum([
197
+ 'line',
198
+ 'bar',
199
+ 'area',
200
+ 'pie',
201
+ 'donut',
202
+ 'radar',
203
+ 'scatter',
204
+ ]);
205
+
206
+ /**
207
+ * Chart Series Schema
208
+ */
209
+ export const ChartSeriesSchema = z.object({
210
+ name: z.string().describe('Series name'),
211
+ data: z.array(z.number()).describe('Series data points'),
212
+ color: z.string().optional().describe('Series color'),
213
+ });
214
+
215
+ /**
216
+ * Chart Schema - Chart/graph component
217
+ */
218
+ export const ChartSchema = BaseSchema.extend({
219
+ type: z.literal('chart'),
220
+ chartType: ChartTypeSchema.describe('Chart type'),
221
+ title: z.string().optional().describe('Chart title'),
222
+ description: z.string().optional().describe('Chart description'),
223
+ categories: z.array(z.string()).optional().describe('X-axis categories'),
224
+ series: z.array(ChartSeriesSchema).describe('Chart data series'),
225
+ height: z.union([z.string(), z.number()]).optional().describe('Chart height'),
226
+ width: z.union([z.string(), z.number()]).optional().describe('Chart width'),
227
+ showLegend: z.boolean().optional().describe('Show legend'),
228
+ showGrid: z.boolean().optional().describe('Show grid lines'),
229
+ animate: z.boolean().optional().describe('Enable animations'),
230
+ config: z.record(z.string(), z.any()).optional().describe('Additional chart configuration'),
231
+ });
232
+
233
+ /**
234
+ * Timeline Event Schema
235
+ */
236
+ export const TimelineEventSchema = z.object({
237
+ id: z.string().optional().describe('Event ID'),
238
+ title: z.string().describe('Event title'),
239
+ description: z.string().optional().describe('Event description'),
240
+ date: z.union([z.string(), z.date()]).describe('Event date'),
241
+ icon: z.string().optional().describe('Event icon'),
242
+ color: z.string().optional().describe('Event color'),
243
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Custom content'),
244
+ });
245
+
246
+ /**
247
+ * Timeline Schema - Timeline component
248
+ */
249
+ export const TimelineSchema = BaseSchema.extend({
250
+ type: z.literal('timeline'),
251
+ events: z.array(TimelineEventSchema).describe('Timeline events'),
252
+ orientation: z.enum(['vertical', 'horizontal']).optional().describe('Timeline orientation'),
253
+ position: z.enum(['left', 'right', 'alternate']).optional().describe('Event position'),
254
+ });
255
+
256
+ /**
257
+ * Keyboard Key Schema - Keyboard key display
258
+ */
259
+ export const KbdSchema = BaseSchema.extend({
260
+ type: z.literal('kbd'),
261
+ label: z.string().optional().describe('Key label'),
262
+ keys: z.union([z.string(), z.array(z.string())]).optional().describe('Key(s) to display'),
263
+ });
264
+
265
+ /**
266
+ * HTML Schema - Raw HTML renderer
267
+ */
268
+ export const HtmlSchema = BaseSchema.extend({
269
+ type: z.literal('html'),
270
+ html: z.string().describe('HTML content'),
271
+ });
272
+
273
+ /**
274
+ * Data Display Schema Union - All data display component schemas
275
+ */
276
+ export const DataDisplaySchema = z.union([
277
+ AlertSchema,
278
+ StatisticSchema,
279
+ BadgeSchema,
280
+ AvatarSchema,
281
+ ListSchema,
282
+ TableSchema,
283
+ DataTableSchema,
284
+ MarkdownSchema,
285
+ TreeViewSchema,
286
+ ChartSchema,
287
+ TimelineSchema,
288
+ KbdSchema,
289
+ HtmlSchema,
290
+ ]);
@@ -0,0 +1,92 @@
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 - Disclosure Component Zod Validators
11
+ *
12
+ * Zod validation schemas for collapsible/disclosure components.
13
+ * Following @objectstack/spec UI specification format.
14
+ *
15
+ * @module zod/disclosure
16
+ * @packageDocumentation
17
+ */
18
+
19
+ import { z } from 'zod';
20
+ import { BaseSchema, SchemaNodeSchema } from './base.zod';
21
+
22
+ /**
23
+ * Accordion Item Schema
24
+ */
25
+ export const AccordionItemSchema = z.object({
26
+ value: z.string().describe('Unique accordion item identifier'),
27
+ title: z.string().describe('Accordion item title'),
28
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Accordion item content'),
29
+ disabled: z.boolean().optional().describe('Whether item is disabled'),
30
+ icon: z.string().optional().describe('Item icon'),
31
+ });
32
+
33
+ /**
34
+ * Accordion Schema - Accordion component
35
+ */
36
+ export const AccordionSchema = BaseSchema.extend({
37
+ type: z.literal('accordion'),
38
+ items: z.array(AccordionItemSchema).describe('Accordion items'),
39
+ accordionType: z.enum(['single', 'multiple']).optional().describe('Accordion type'),
40
+ collapsible: z.boolean().optional().describe('Whether items can be collapsed'),
41
+ defaultValue: z.union([z.string(), z.array(z.string())]).optional().describe('Default open item(s)'),
42
+ value: z.union([z.string(), z.array(z.string())]).optional().describe('Controlled open item(s)'),
43
+ onValueChange: z.function().optional().describe('Value change handler'),
44
+ variant: z.enum(['default', 'bordered', 'separated']).optional().describe('Accordion variant'),
45
+ });
46
+
47
+ /**
48
+ * Collapsible Schema - Collapsible component
49
+ */
50
+ export const CollapsibleSchema = BaseSchema.extend({
51
+ type: z.literal('collapsible'),
52
+ trigger: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Trigger content'),
53
+ content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).describe('Collapsible content'),
54
+ defaultOpen: z.boolean().optional().describe('Default open state'),
55
+ open: z.boolean().optional().describe('Controlled open state'),
56
+ disabled: z.boolean().optional().describe('Whether collapsible is disabled'),
57
+ onOpenChange: z.function().optional().describe('Open change handler'),
58
+ });
59
+
60
+ /**
61
+ * Toggle Group Item Schema
62
+ */
63
+ export const ToggleGroupItemSchema = z.object({
64
+ value: z.string().describe('Item value'),
65
+ label: z.string().describe('Item label'),
66
+ icon: z.string().optional().describe('Item icon'),
67
+ disabled: z.boolean().optional().describe('Whether item is disabled'),
68
+ });
69
+
70
+ /**
71
+ * Toggle Group Schema - Toggle group component
72
+ */
73
+ export const ToggleGroupSchema = BaseSchema.extend({
74
+ type: z.literal('toggle-group'),
75
+ selectionType: z.enum(['single', 'multiple']).optional().describe('Selection type'),
76
+ variant: z.enum(['default', 'outline']).optional().describe('Toggle group variant'),
77
+ size: z.enum(['default', 'sm', 'lg']).optional().describe('Toggle group size'),
78
+ items: z.array(ToggleGroupItemSchema).optional().describe('Toggle group items'),
79
+ defaultValue: z.union([z.string(), z.array(z.string())]).optional().describe('Default value(s)'),
80
+ value: z.union([z.string(), z.array(z.string())]).optional().describe('Controlled value(s)'),
81
+ disabled: z.boolean().optional().describe('Whether toggle group is disabled'),
82
+ onValueChange: z.function().optional().describe('Value change handler'),
83
+ });
84
+
85
+ /**
86
+ * Disclosure Schema Union - All disclosure component schemas
87
+ */
88
+ export const DisclosureSchema = z.union([
89
+ AccordionSchema,
90
+ CollapsibleSchema,
91
+ ToggleGroupSchema,
92
+ ]);