@object-ui/types 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +17 -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/blocks.d.ts +332 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +8 -0
- 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 +181 -3
- 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-protocol.d.ts +1268 -0
- package/dist/data-protocol.d.ts.map +1 -0
- package/dist/data-protocol.js +8 -0
- package/dist/data.d.ts +22 -1
- 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 +728 -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 +48 -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 +491 -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/plugin-scope.d.ts +194 -0
- package/dist/plugin-scope.d.ts.map +1 -0
- package/dist/plugin-scope.js +8 -0
- package/dist/registry.d.ts +7 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +7 -0
- package/dist/reports.d.ts +336 -0
- package/dist/reports.d.ts.map +1 -0
- package/dist/reports.js +8 -0
- package/dist/theme.d.ts +289 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +8 -0
- package/dist/ui-action.d.ts +175 -0
- package/dist/ui-action.d.ts.map +1 -0
- package/dist/ui-action.js +8 -0
- package/dist/views.d.ts +417 -0
- package/dist/views.d.ts.map +1 -0
- package/dist/views.js +8 -0
- package/dist/zod/app.zod.d.ts +120 -0
- package/dist/zod/app.zod.d.ts.map +1 -0
- package/dist/zod/app.zod.js +60 -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/blocks.zod.d.ts +834 -0
- package/dist/zod/blocks.zod.d.ts.map +1 -0
- package/dist/zod/blocks.zod.js +145 -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/crud.zod.d.ts +598 -0
- package/dist/zod/crud.zod.d.ts.map +1 -0
- package/dist/zod/crud.zod.js +230 -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 +4985 -0
- package/dist/zod/index.zod.d.ts.map +1 -0
- package/dist/zod/index.zod.js +183 -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/dist/zod/reports.zod.d.ts +1628 -0
- package/dist/zod/reports.zod.d.ts.map +1 -0
- package/dist/zod/reports.zod.js +152 -0
- package/dist/zod/theme.zod.d.ts +611 -0
- package/dist/zod/theme.zod.d.ts.map +1 -0
- package/dist/zod/theme.zod.js +130 -0
- package/dist/zod/views.zod.d.ts +675 -0
- package/dist/zod/views.zod.d.ts.map +1 -0
- package/dist/zod/views.zod.js +159 -0
- package/package.json +9 -1
- package/src/__tests__/namespace-exports.test.ts +80 -0
- package/src/__tests__/phase2-schemas.test.ts +639 -0
- package/src/api-types.ts +8 -0
- package/src/app.ts +20 -0
- package/src/base.ts +8 -0
- package/src/blocks.ts +405 -0
- package/src/complex.ts +69 -1
- package/src/crud.ts +185 -3
- package/src/data-display.ts +60 -2
- package/src/data-protocol.ts +1679 -0
- package/src/data.ts +21 -1
- package/src/disclosure.ts +74 -1
- package/src/feedback.ts +76 -2
- package/src/field-types.ts +846 -0
- package/src/form.ts +131 -1
- package/src/index.ts +305 -8
- package/src/layout.ts +70 -15
- package/src/navigation.ts +109 -2
- package/src/objectql.ts +563 -59
- package/src/overlay.ts +35 -1
- package/src/plugin-scope.ts +210 -0
- package/src/registry.ts +8 -0
- package/src/reports.ts +408 -0
- package/src/theme.ts +351 -0
- package/src/ui-action.ts +276 -0
- package/src/views.ts +429 -0
- package/src/zod/README.md +329 -0
- package/src/zod/app.zod.ts +72 -0
- package/src/zod/base.zod.ts +229 -0
- package/src/zod/blocks.zod.ts +170 -0
- package/src/zod/complex.zod.ts +258 -0
- package/src/zod/crud.zod.ts +259 -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 +425 -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
- package/src/zod/reports.zod.ts +183 -0
- package/src/zod/theme.zod.ts +155 -0
- package/src/zod/views.zod.ts +182 -0
|
@@ -0,0 +1,259 @@
|
|
|
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 - CRUD Component Zod Validators
|
|
11
|
+
*
|
|
12
|
+
* Zod validation schemas for CRUD operations.
|
|
13
|
+
* Following @objectstack/spec UI specification format.
|
|
14
|
+
*
|
|
15
|
+
* Enhanced in Phase 2 with ajax, confirm, dialog actions, chaining, and conditional execution.
|
|
16
|
+
*
|
|
17
|
+
* @module zod/crud
|
|
18
|
+
* @packageDocumentation
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { BaseSchema, SchemaNodeSchema } from './base.zod.js';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Action Execution Mode Schema
|
|
26
|
+
*/
|
|
27
|
+
export const ActionExecutionModeSchema = z.enum(['sequential', 'parallel']).describe('Action execution mode for chaining');
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Action Callback Schema
|
|
31
|
+
*/
|
|
32
|
+
export const ActionCallbackSchema = z.object({
|
|
33
|
+
type: z.enum(['toast', 'message', 'redirect', 'reload', 'custom', 'ajax', 'dialog']).describe('Callback type'),
|
|
34
|
+
message: z.string().optional().describe('Message to display'),
|
|
35
|
+
url: z.string().optional().describe('Redirect URL'),
|
|
36
|
+
api: z.string().optional().describe('API endpoint for ajax callback'),
|
|
37
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().describe('HTTP method for ajax callback'),
|
|
38
|
+
dialog: SchemaNodeSchema.optional().describe('Dialog schema to open'),
|
|
39
|
+
handler: z.string().optional().describe('Custom callback handler expression'),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Action Condition Schema
|
|
44
|
+
*/
|
|
45
|
+
export const ActionConditionSchema: z.ZodType<any> = z.lazy(() => z.object({
|
|
46
|
+
expression: z.string().describe('Condition expression'),
|
|
47
|
+
then: z.union([ActionSchema, z.array(ActionSchema)]).optional().describe('Action to execute if condition is true'),
|
|
48
|
+
else: z.union([ActionSchema, z.array(ActionSchema)]).optional().describe('Action to execute if condition is false'),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Action Schema - Enhanced with Phase 2 features
|
|
53
|
+
*/
|
|
54
|
+
export const ActionSchema: z.ZodType<any> = z.lazy(() => BaseSchema.extend({
|
|
55
|
+
type: z.literal('action'),
|
|
56
|
+
label: z.string().describe('Action label'),
|
|
57
|
+
level: z.enum(['primary', 'secondary', 'success', 'warning', 'danger', 'info', 'default']).optional().default('default').describe('Action type/level'),
|
|
58
|
+
icon: z.string().optional().describe('Icon to display (lucide-react icon name)'),
|
|
59
|
+
variant: z.enum(['default', 'outline', 'ghost', 'link']).optional().describe('Action variant'),
|
|
60
|
+
disabled: z.boolean().optional().describe('Whether action is disabled'),
|
|
61
|
+
actionType: z.enum(['button', 'link', 'dropdown', 'ajax', 'confirm', 'dialog']).optional().describe('Action type'),
|
|
62
|
+
api: z.string().optional().describe('API endpoint to call (for ajax actions)'),
|
|
63
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().default('POST').describe('HTTP method'),
|
|
64
|
+
data: z.any().optional().describe('Request body/data'),
|
|
65
|
+
headers: z.record(z.string(), z.string()).optional().describe('Request headers'),
|
|
66
|
+
confirm: z.object({
|
|
67
|
+
title: z.string().optional().describe('Confirmation title'),
|
|
68
|
+
message: z.string().optional().describe('Confirmation message'),
|
|
69
|
+
confirmText: z.string().optional().describe('Confirm button text'),
|
|
70
|
+
cancelText: z.string().optional().describe('Cancel button text'),
|
|
71
|
+
confirmVariant: z.enum(['default', 'destructive', 'outline', 'secondary', 'ghost']).optional().describe('Confirm button variant'),
|
|
72
|
+
}).optional().describe('Confirmation dialog configuration (for confirm actions)'),
|
|
73
|
+
confirmText: z.string().optional().describe('Legacy confirmation message (deprecated - use confirm object instead)'),
|
|
74
|
+
dialog: z.object({
|
|
75
|
+
title: z.string().optional().describe('Dialog title'),
|
|
76
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog content'),
|
|
77
|
+
size: z.enum(['sm', 'default', 'lg', 'xl', 'full']).optional().describe('Dialog size'),
|
|
78
|
+
actions: z.array(ActionSchema).optional().describe('Dialog actions'),
|
|
79
|
+
}).optional().describe('Dialog configuration (for dialog actions)'),
|
|
80
|
+
successMessage: z.string().optional().describe('Success message after execution'),
|
|
81
|
+
errorMessage: z.string().optional().describe('Error message on failure'),
|
|
82
|
+
onSuccess: ActionCallbackSchema.optional().describe('Success callback'),
|
|
83
|
+
onFailure: ActionCallbackSchema.optional().describe('Failure callback'),
|
|
84
|
+
chain: z.array(ActionSchema).optional().describe('Action chaining - actions to execute after this one'),
|
|
85
|
+
chainMode: ActionExecutionModeSchema.optional().default('sequential').describe('Chain execution mode'),
|
|
86
|
+
condition: ActionConditionSchema.optional().describe('Conditional execution'),
|
|
87
|
+
reload: z.boolean().optional().default(true).describe('Whether to reload data after action'),
|
|
88
|
+
close: z.boolean().optional().default(true).describe('Whether to close dialog/modal after action'),
|
|
89
|
+
onClick: z.any().optional().describe('Custom click handler'),
|
|
90
|
+
redirect: z.string().optional().describe('Redirect URL after success'),
|
|
91
|
+
tracking: z.object({
|
|
92
|
+
enabled: z.boolean().optional().describe('Enable tracking'),
|
|
93
|
+
event: z.string().optional().describe('Event name'),
|
|
94
|
+
metadata: z.record(z.string(), z.any()).optional().describe('Additional metadata'),
|
|
95
|
+
}).optional().describe('Action logging/tracking'),
|
|
96
|
+
timeout: z.number().optional().describe('Timeout in milliseconds'),
|
|
97
|
+
retry: z.object({
|
|
98
|
+
maxAttempts: z.number().optional().describe('Maximum retry attempts'),
|
|
99
|
+
delay: z.number().optional().describe('Delay between retries (in ms)'),
|
|
100
|
+
}).optional().describe('Retry configuration'),
|
|
101
|
+
}));
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* CRUD Operation Schema
|
|
105
|
+
*/
|
|
106
|
+
export const CRUDOperationSchema = z.object({
|
|
107
|
+
type: z.enum(['create', 'read', 'update', 'delete', 'export', 'import', 'custom']).describe('Operation type'),
|
|
108
|
+
label: z.string().optional().describe('Operation label'),
|
|
109
|
+
icon: z.string().optional().describe('Operation icon'),
|
|
110
|
+
enabled: z.boolean().optional().default(true).describe('Whether operation is enabled'),
|
|
111
|
+
api: z.string().optional().describe('API endpoint for this operation'),
|
|
112
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH']).optional().describe('HTTP method'),
|
|
113
|
+
confirmText: z.string().optional().describe('Confirmation message'),
|
|
114
|
+
successMessage: z.string().optional().describe('Success message'),
|
|
115
|
+
visibleOn: z.string().optional().describe('Visibility condition'),
|
|
116
|
+
disabledOn: z.string().optional().describe('Disabled condition'),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* CRUD Filter Schema
|
|
121
|
+
*/
|
|
122
|
+
export const CRUDFilterSchema = z.object({
|
|
123
|
+
name: z.string().describe('Filter name (field name)'),
|
|
124
|
+
label: z.string().optional().describe('Filter label'),
|
|
125
|
+
type: z.enum(['input', 'select', 'date-picker', 'date-range', 'number-range']).optional().describe('Filter type'),
|
|
126
|
+
operator: z.enum(['equals', 'contains', 'startsWith', 'endsWith', 'gt', 'gte', 'lt', 'lte', 'between', 'in']).optional().default('equals').describe('Filter operator'),
|
|
127
|
+
options: z.array(z.object({ label: z.string(), value: z.union([z.string(), z.number()]) })).optional().describe('Options for select filter'),
|
|
128
|
+
placeholder: z.string().optional().describe('Placeholder text'),
|
|
129
|
+
defaultValue: z.any().optional().describe('Default value'),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* CRUD Toolbar Schema
|
|
134
|
+
*/
|
|
135
|
+
export const CRUDToolbarSchema = z.object({
|
|
136
|
+
showCreate: z.boolean().optional().default(true).describe('Show create button'),
|
|
137
|
+
showRefresh: z.boolean().optional().default(true).describe('Show refresh button'),
|
|
138
|
+
showExport: z.boolean().optional().default(false).describe('Show export button'),
|
|
139
|
+
showImport: z.boolean().optional().default(false).describe('Show import button'),
|
|
140
|
+
showFilter: z.boolean().optional().default(true).describe('Show filter toggle'),
|
|
141
|
+
showSearch: z.boolean().optional().default(true).describe('Show search box'),
|
|
142
|
+
actions: z.array(ActionSchema).optional().describe('Custom actions'),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* CRUD Pagination Schema
|
|
147
|
+
*/
|
|
148
|
+
export const CRUDPaginationSchema = z.object({
|
|
149
|
+
enabled: z.boolean().optional().default(true).describe('Whether pagination is enabled'),
|
|
150
|
+
pageSize: z.number().optional().default(10).describe('Default page size'),
|
|
151
|
+
pageSizeOptions: z.array(z.number()).optional().default([10, 20, 50, 100]).describe('Page size options'),
|
|
152
|
+
showTotal: z.boolean().optional().default(true).describe('Show total count'),
|
|
153
|
+
showSizeChanger: z.boolean().optional().default(true).describe('Show page size selector'),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* CRUD Schema
|
|
158
|
+
*/
|
|
159
|
+
export const CRUDSchema = BaseSchema.extend({
|
|
160
|
+
type: z.literal('crud'),
|
|
161
|
+
title: z.string().optional().describe('CRUD title'),
|
|
162
|
+
resource: z.string().optional().describe('Resource name (singular)'),
|
|
163
|
+
api: z.string().optional().describe('API endpoint for list/search'),
|
|
164
|
+
columns: z.array(z.any()).describe('Table columns configuration'),
|
|
165
|
+
fields: z.array(z.any()).optional().describe('Form fields for create/edit'),
|
|
166
|
+
operations: z.record(z.string(), z.union([z.boolean(), CRUDOperationSchema])).optional().describe('Enabled operations'),
|
|
167
|
+
toolbar: CRUDToolbarSchema.optional().describe('Toolbar configuration'),
|
|
168
|
+
filters: z.array(CRUDFilterSchema).optional().describe('Filter configuration'),
|
|
169
|
+
pagination: CRUDPaginationSchema.optional().describe('Pagination configuration'),
|
|
170
|
+
defaultSort: z.string().optional().describe('Default sort field'),
|
|
171
|
+
defaultSortOrder: z.enum(['asc', 'desc']).optional().default('asc').describe('Default sort order'),
|
|
172
|
+
selectable: z.union([z.boolean(), z.enum(['single', 'multiple'])]).optional().describe('Row selection mode'),
|
|
173
|
+
batchActions: z.array(ActionSchema).optional().describe('Batch actions for selected rows'),
|
|
174
|
+
rowActions: z.array(ActionSchema).optional().describe('Row actions (displayed in each row)'),
|
|
175
|
+
emptyState: SchemaNodeSchema.optional().describe('Custom empty state'),
|
|
176
|
+
loading: z.boolean().optional().default(true).describe('Whether to show loading state'),
|
|
177
|
+
loadingComponent: SchemaNodeSchema.optional().describe('Custom loading component'),
|
|
178
|
+
mode: z.enum(['table', 'grid', 'list', 'kanban']).optional().default('table').describe('Table layout mode'),
|
|
179
|
+
gridColumns: z.number().optional().default(3).describe('Grid columns (for grid mode)'),
|
|
180
|
+
cardTemplate: SchemaNodeSchema.optional().describe('Card template (for grid/list mode)'),
|
|
181
|
+
kanbanColumns: z.array(z.object({
|
|
182
|
+
id: z.string(),
|
|
183
|
+
title: z.string(),
|
|
184
|
+
color: z.string().optional(),
|
|
185
|
+
})).optional().describe('Kanban columns (for kanban mode)'),
|
|
186
|
+
kanbanGroupField: z.string().optional().describe('Kanban group field'),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Detail Schema
|
|
191
|
+
*/
|
|
192
|
+
export const DetailSchema = BaseSchema.extend({
|
|
193
|
+
type: z.literal('detail'),
|
|
194
|
+
title: z.string().optional().describe('Detail title'),
|
|
195
|
+
api: z.string().optional().describe('API endpoint to fetch detail data'),
|
|
196
|
+
resourceId: z.union([z.string(), z.number()]).optional().describe('Resource ID to display'),
|
|
197
|
+
groups: z.array(z.object({
|
|
198
|
+
title: z.string().optional(),
|
|
199
|
+
description: z.string().optional(),
|
|
200
|
+
fields: z.array(z.object({
|
|
201
|
+
name: z.string(),
|
|
202
|
+
label: z.string().optional(),
|
|
203
|
+
type: z.enum(['text', 'image', 'link', 'badge', 'date', 'datetime', 'json', 'html', 'custom']).optional(),
|
|
204
|
+
format: z.string().optional(),
|
|
205
|
+
render: SchemaNodeSchema.optional(),
|
|
206
|
+
})),
|
|
207
|
+
})).optional().describe('Field groups for organized display'),
|
|
208
|
+
actions: z.array(ActionSchema).optional().describe('Actions available in detail view'),
|
|
209
|
+
tabs: z.array(z.object({
|
|
210
|
+
key: z.string(),
|
|
211
|
+
label: z.string(),
|
|
212
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]),
|
|
213
|
+
})).optional().describe('Tabs for additional content'),
|
|
214
|
+
showBack: z.boolean().optional().default(true).describe('Show back button'),
|
|
215
|
+
onBack: z.any().optional().describe('Custom back action'),
|
|
216
|
+
loading: z.boolean().optional().default(true).describe('Whether to show loading state'),
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* CRUD Dialog Schema
|
|
221
|
+
*/
|
|
222
|
+
export const CRUDDialogSchema = BaseSchema.extend({
|
|
223
|
+
type: z.literal('crud-dialog'),
|
|
224
|
+
title: z.string().optional().describe('Dialog title'),
|
|
225
|
+
description: z.string().optional().describe('Dialog description'),
|
|
226
|
+
content: z.union([SchemaNodeSchema, z.array(SchemaNodeSchema)]).optional().describe('Dialog content'),
|
|
227
|
+
size: z.enum(['sm', 'default', 'lg', 'xl', 'full']).optional().default('default').describe('Dialog size'),
|
|
228
|
+
actions: z.array(ActionSchema).optional().describe('Dialog actions/buttons'),
|
|
229
|
+
open: z.boolean().optional().describe('Whether dialog is open'),
|
|
230
|
+
onClose: z.any().optional().describe('Close handler'),
|
|
231
|
+
closeOnOutsideClick: z.boolean().optional().default(true).describe('Whether clicking outside closes dialog'),
|
|
232
|
+
closeOnEscape: z.boolean().optional().default(true).describe('Whether pressing Escape closes dialog'),
|
|
233
|
+
showClose: z.boolean().optional().default(true).describe('Show close button'),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Union of all CRUD schemas
|
|
238
|
+
*/
|
|
239
|
+
export const CRUDComponentSchema = z.union([
|
|
240
|
+
ActionSchema,
|
|
241
|
+
CRUDSchema,
|
|
242
|
+
DetailSchema,
|
|
243
|
+
CRUDDialogSchema,
|
|
244
|
+
]);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Export type inference helpers
|
|
248
|
+
*/
|
|
249
|
+
export type ActionExecutionModeSchemaType = z.infer<typeof ActionExecutionModeSchema>;
|
|
250
|
+
export type ActionCallbackSchemaType = z.infer<typeof ActionCallbackSchema>;
|
|
251
|
+
export type ActionConditionSchemaType = z.infer<typeof ActionConditionSchema>;
|
|
252
|
+
export type ActionSchemaType = z.infer<typeof ActionSchema>;
|
|
253
|
+
export type CRUDOperationSchemaType = z.infer<typeof CRUDOperationSchema>;
|
|
254
|
+
export type CRUDFilterSchemaType = z.infer<typeof CRUDFilterSchema>;
|
|
255
|
+
export type CRUDToolbarSchemaType = z.infer<typeof CRUDToolbarSchema>;
|
|
256
|
+
export type CRUDPaginationSchemaType = z.infer<typeof CRUDPaginationSchema>;
|
|
257
|
+
export type CRUDSchemaType = z.infer<typeof CRUDSchema>;
|
|
258
|
+
export type DetailSchemaType = z.infer<typeof DetailSchema>;
|
|
259
|
+
export type CRUDDialogSchemaType = z.infer<typeof CRUDDialogSchema>;
|
|
@@ -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.js';
|
|
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.js';
|
|
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
|
+
]);
|