@object-ui/types 0.3.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/LICENSE +21 -0
- package/README.md +304 -0
- package/dist/api-types.d.ts +451 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/api-types.js +10 -0
- package/dist/app.d.ts +120 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +7 -0
- package/dist/base.d.ts +360 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +10 -0
- package/dist/complex.d.ts +433 -0
- package/dist/complex.d.ts.map +1 -0
- package/dist/complex.js +9 -0
- package/dist/crud.d.ts +457 -0
- package/dist/crud.d.ts.map +1 -0
- package/dist/crud.js +10 -0
- package/dist/data-display.d.ts +599 -0
- package/dist/data-display.d.ts.map +1 -0
- package/dist/data-display.js +9 -0
- package/dist/data.d.ts +295 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +10 -0
- package/dist/disclosure.d.ts +107 -0
- package/dist/disclosure.d.ts.map +1 -0
- package/dist/disclosure.js +9 -0
- package/dist/feedback.d.ts +159 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +9 -0
- package/dist/form.d.ts +932 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +9 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/layout.d.ts +418 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +10 -0
- package/dist/navigation.d.ts +224 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +9 -0
- package/dist/objectql.d.ts +254 -0
- package/dist/objectql.d.ts.map +1 -0
- package/dist/objectql.js +10 -0
- package/dist/overlay.d.ts +396 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/overlay.js +9 -0
- package/dist/registry.d.ts +85 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +1 -0
- package/package.json +82 -0
- package/src/api-types.ts +464 -0
- package/src/app.ts +138 -0
- package/src/base.ts +416 -0
- package/src/complex.ts +465 -0
- package/src/crud.ts +467 -0
- package/src/data-display.ts +630 -0
- package/src/data.ts +341 -0
- package/src/disclosure.ts +113 -0
- package/src/feedback.ts +170 -0
- package/src/form.ts +954 -0
- package/src/index.ts +350 -0
- package/src/layout.ts +451 -0
- package/src/navigation.ts +235 -0
- package/src/objectql.ts +301 -0
- package/src/overlay.ts +418 -0
- package/src/registry.ts +182 -0
package/src/base.ts
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @object-ui/types - Base Schema Types
|
|
3
|
+
*
|
|
4
|
+
* The foundational type definitions for the Object UI schema protocol.
|
|
5
|
+
* These types define the universal interface for all UI components.
|
|
6
|
+
*
|
|
7
|
+
* @module base
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Base schema interface that all component schemas extend.
|
|
13
|
+
* This is the fundamental building block of the Object UI protocol.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const schema: BaseSchema = {
|
|
18
|
+
* type: 'text',
|
|
19
|
+
* id: 'greeting',
|
|
20
|
+
* className: 'text-lg font-bold',
|
|
21
|
+
* data: { message: 'Hello World' }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface BaseSchema {
|
|
26
|
+
/**
|
|
27
|
+
* Component type identifier. Determines which renderer to use.
|
|
28
|
+
* @example 'input', 'button', 'form', 'grid'
|
|
29
|
+
*/
|
|
30
|
+
type: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Unique identifier for the component instance.
|
|
34
|
+
* Used for state management, event handling, and React keys.
|
|
35
|
+
*/
|
|
36
|
+
id?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Human-readable name for the component.
|
|
40
|
+
* Used for form field names, labels, and debugging.
|
|
41
|
+
*/
|
|
42
|
+
name?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Display label for the component.
|
|
46
|
+
* Often used in forms, cards, and other UI elements.
|
|
47
|
+
*/
|
|
48
|
+
label?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Descriptive text providing additional context.
|
|
52
|
+
* Typically rendered as help text below the component.
|
|
53
|
+
*/
|
|
54
|
+
description?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Placeholder text for input components.
|
|
58
|
+
* Provides hints about expected input format or content.
|
|
59
|
+
*/
|
|
60
|
+
placeholder?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Tailwind CSS classes to apply to the component.
|
|
64
|
+
* This is the primary styling mechanism in Object UI.
|
|
65
|
+
* @example 'bg-blue-500 text-white p-4 rounded-lg'
|
|
66
|
+
*/
|
|
67
|
+
className?: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Inline CSS styles as a JavaScript object.
|
|
71
|
+
* Use sparingly - prefer className with Tailwind.
|
|
72
|
+
* @example { backgroundColor: '#fff', padding: '16px' }
|
|
73
|
+
*/
|
|
74
|
+
style?: Record<string, string | number>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Arbitrary data attached to the component.
|
|
78
|
+
* Can be used for custom properties, state, or context.
|
|
79
|
+
*/
|
|
80
|
+
data?: any;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Child components or content.
|
|
84
|
+
* Can be a single component, array of components, or primitive values.
|
|
85
|
+
*/
|
|
86
|
+
body?: SchemaNode | SchemaNode[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Alternative name for children (React-style).
|
|
90
|
+
* Some components use 'children' instead of 'body'.
|
|
91
|
+
*/
|
|
92
|
+
children?: SchemaNode | SchemaNode[];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Controls whether the component is visible.
|
|
96
|
+
* When false, component is not rendered (display: none).
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
visible?: boolean;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Expression for conditional visibility.
|
|
103
|
+
* Evaluated against the current data context.
|
|
104
|
+
* @example "${data.role === 'admin'}"
|
|
105
|
+
*/
|
|
106
|
+
visibleOn?: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Controls whether the component is hidden (but still rendered).
|
|
110
|
+
* When true, component is rendered but not visible (visibility: hidden).
|
|
111
|
+
* @default false
|
|
112
|
+
*/
|
|
113
|
+
hidden?: boolean;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Expression for conditional hiding.
|
|
117
|
+
* @example "${!data.isActive}"
|
|
118
|
+
*/
|
|
119
|
+
hiddenOn?: string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Controls whether the component is disabled.
|
|
123
|
+
* Applies to interactive components like buttons and inputs.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
disabled?: boolean;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Expression for conditional disabling.
|
|
130
|
+
* @example "${data.status === 'locked'}"
|
|
131
|
+
*/
|
|
132
|
+
disabledOn?: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Test ID for automated testing.
|
|
136
|
+
* Rendered as data-testid attribute.
|
|
137
|
+
*/
|
|
138
|
+
testId?: string;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Accessibility label for screen readers.
|
|
142
|
+
* Rendered as aria-label attribute.
|
|
143
|
+
*/
|
|
144
|
+
ariaLabel?: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Additional properties specific to the component type.
|
|
148
|
+
* This index signature allows type-specific extensions.
|
|
149
|
+
*/
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A schema node can be a full schema object or a primitive value.
|
|
155
|
+
* This union type supports both structured components and simple content.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const nodes: SchemaNode[] = [
|
|
160
|
+
* { type: 'text', value: 'Hello' },
|
|
161
|
+
* 'Plain string',
|
|
162
|
+
* { type: 'button', label: 'Click' }
|
|
163
|
+
* ]
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export type SchemaNode = BaseSchema | string | number | boolean | null | undefined;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Component renderer function type.
|
|
170
|
+
* Accepts a schema and returns a rendered component.
|
|
171
|
+
* Framework-agnostic - can be React, Vue, or any other renderer.
|
|
172
|
+
*/
|
|
173
|
+
export interface ComponentRendererProps<TSchema extends BaseSchema = BaseSchema> {
|
|
174
|
+
/**
|
|
175
|
+
* The schema object to render
|
|
176
|
+
*/
|
|
177
|
+
schema: TSchema;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Additional properties passed to the renderer
|
|
181
|
+
*/
|
|
182
|
+
[key: string]: any;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Input field configuration for component metadata.
|
|
187
|
+
* Describes what properties a component accepts in the designer/editor.
|
|
188
|
+
*/
|
|
189
|
+
export interface ComponentInput {
|
|
190
|
+
/**
|
|
191
|
+
* Property name (must match schema property)
|
|
192
|
+
*/
|
|
193
|
+
name: string;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Input control type
|
|
197
|
+
*/
|
|
198
|
+
type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'color' | 'date' | 'code' | 'file' | 'slot';
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Display label in the editor
|
|
202
|
+
*/
|
|
203
|
+
label?: string;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Default value for new instances
|
|
207
|
+
*/
|
|
208
|
+
defaultValue?: any;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Whether this property is required
|
|
212
|
+
*/
|
|
213
|
+
required?: boolean;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Enum options (for type='enum')
|
|
217
|
+
*/
|
|
218
|
+
enum?: string[] | { label: string; value: any }[];
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Help text or description
|
|
222
|
+
*/
|
|
223
|
+
description?: string;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Whether this is an advanced/expert option
|
|
227
|
+
*/
|
|
228
|
+
advanced?: boolean;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Specific input type (e.g., 'email', 'password' for string)
|
|
232
|
+
*/
|
|
233
|
+
inputType?: string;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Minimum value (for number/date)
|
|
237
|
+
*/
|
|
238
|
+
min?: number;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Maximum value (for number/date)
|
|
242
|
+
*/
|
|
243
|
+
max?: number;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Step value (for number)
|
|
247
|
+
*/
|
|
248
|
+
step?: number;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Placeholder text
|
|
252
|
+
*/
|
|
253
|
+
placeholder?: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Component metadata for registration and designer integration.
|
|
258
|
+
* Describes the component's capabilities, defaults, and documentation.
|
|
259
|
+
*/
|
|
260
|
+
export interface ComponentMeta {
|
|
261
|
+
/**
|
|
262
|
+
* Display name in designer/palette
|
|
263
|
+
*/
|
|
264
|
+
label?: string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Icon name or SVG string
|
|
268
|
+
*/
|
|
269
|
+
icon?: string;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Category for grouping (e.g., 'Layout', 'Form', 'Data Display')
|
|
273
|
+
*/
|
|
274
|
+
category?: string;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Configurable properties
|
|
278
|
+
*/
|
|
279
|
+
inputs?: ComponentInput[];
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Default property values for new instances
|
|
283
|
+
*/
|
|
284
|
+
defaultProps?: Record<string, any>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Default children for container components
|
|
288
|
+
*/
|
|
289
|
+
defaultChildren?: SchemaNode[];
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Example configurations for documentation
|
|
293
|
+
*/
|
|
294
|
+
examples?: Record<string, any>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Whether the component can have children
|
|
298
|
+
*/
|
|
299
|
+
isContainer?: boolean;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Whether the component can be resized in the designer
|
|
303
|
+
*/
|
|
304
|
+
resizable?: boolean;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Resize constraints (which dimensions can be resized)
|
|
308
|
+
*/
|
|
309
|
+
resizeConstraints?: {
|
|
310
|
+
width?: boolean;
|
|
311
|
+
height?: boolean;
|
|
312
|
+
minWidth?: number;
|
|
313
|
+
maxWidth?: number;
|
|
314
|
+
minHeight?: number;
|
|
315
|
+
maxHeight?: number;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Tags for search/filtering
|
|
320
|
+
*/
|
|
321
|
+
tags?: string[];
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Description for documentation
|
|
325
|
+
*/
|
|
326
|
+
description?: string;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Complete component configuration combining renderer and metadata.
|
|
331
|
+
*/
|
|
332
|
+
export interface ComponentConfig extends ComponentMeta {
|
|
333
|
+
/**
|
|
334
|
+
* Unique component type identifier
|
|
335
|
+
*/
|
|
336
|
+
type: string;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The component renderer (framework-specific)
|
|
340
|
+
*/
|
|
341
|
+
component: any;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Common HTML attributes that can be applied to components
|
|
346
|
+
*/
|
|
347
|
+
export interface HTMLAttributes {
|
|
348
|
+
id?: string;
|
|
349
|
+
className?: string;
|
|
350
|
+
style?: Record<string, any>;
|
|
351
|
+
title?: string;
|
|
352
|
+
role?: string;
|
|
353
|
+
'aria-label'?: string;
|
|
354
|
+
'aria-describedby'?: string;
|
|
355
|
+
'data-testid'?: string;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Event handler types
|
|
360
|
+
*/
|
|
361
|
+
export interface EventHandlers {
|
|
362
|
+
onClick?: (event?: any) => void | Promise<void>;
|
|
363
|
+
onChange?: (value: any, event?: any) => void | Promise<void>;
|
|
364
|
+
onSubmit?: (data: any, event?: any) => void | Promise<void>;
|
|
365
|
+
onFocus?: (event?: any) => void;
|
|
366
|
+
onBlur?: (event?: any) => void;
|
|
367
|
+
onKeyDown?: (event?: any) => void;
|
|
368
|
+
onKeyUp?: (event?: any) => void;
|
|
369
|
+
onMouseEnter?: (event?: any) => void;
|
|
370
|
+
onMouseLeave?: (event?: any) => void;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Common style properties using Tailwind's semantic naming
|
|
375
|
+
*/
|
|
376
|
+
export interface StyleProps {
|
|
377
|
+
/**
|
|
378
|
+
* Padding (Tailwind scale: 0-96)
|
|
379
|
+
*/
|
|
380
|
+
padding?: number | string;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Margin (Tailwind scale: 0-96)
|
|
384
|
+
*/
|
|
385
|
+
margin?: number | string;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Gap between flex/grid items (Tailwind scale: 0-96)
|
|
389
|
+
*/
|
|
390
|
+
gap?: number | string;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Background color
|
|
394
|
+
*/
|
|
395
|
+
backgroundColor?: string;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Text color
|
|
399
|
+
*/
|
|
400
|
+
textColor?: string;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Border width
|
|
404
|
+
*/
|
|
405
|
+
borderWidth?: number | string;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Border color
|
|
409
|
+
*/
|
|
410
|
+
borderColor?: string;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Border radius
|
|
414
|
+
*/
|
|
415
|
+
borderRadius?: number | string;
|
|
416
|
+
}
|