@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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +304 -0
  3. package/dist/api-types.d.ts +451 -0
  4. package/dist/api-types.d.ts.map +1 -0
  5. package/dist/api-types.js +10 -0
  6. package/dist/app.d.ts +120 -0
  7. package/dist/app.d.ts.map +1 -0
  8. package/dist/app.js +7 -0
  9. package/dist/base.d.ts +360 -0
  10. package/dist/base.d.ts.map +1 -0
  11. package/dist/base.js +10 -0
  12. package/dist/complex.d.ts +433 -0
  13. package/dist/complex.d.ts.map +1 -0
  14. package/dist/complex.js +9 -0
  15. package/dist/crud.d.ts +457 -0
  16. package/dist/crud.d.ts.map +1 -0
  17. package/dist/crud.js +10 -0
  18. package/dist/data-display.d.ts +599 -0
  19. package/dist/data-display.d.ts.map +1 -0
  20. package/dist/data-display.js +9 -0
  21. package/dist/data.d.ts +295 -0
  22. package/dist/data.d.ts.map +1 -0
  23. package/dist/data.js +10 -0
  24. package/dist/disclosure.d.ts +107 -0
  25. package/dist/disclosure.d.ts.map +1 -0
  26. package/dist/disclosure.js +9 -0
  27. package/dist/feedback.d.ts +159 -0
  28. package/dist/feedback.d.ts.map +1 -0
  29. package/dist/feedback.js +9 -0
  30. package/dist/form.d.ts +932 -0
  31. package/dist/form.d.ts.map +1 -0
  32. package/dist/form.js +9 -0
  33. package/dist/index.d.ts +108 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +48 -0
  36. package/dist/layout.d.ts +418 -0
  37. package/dist/layout.d.ts.map +1 -0
  38. package/dist/layout.js +10 -0
  39. package/dist/navigation.d.ts +224 -0
  40. package/dist/navigation.d.ts.map +1 -0
  41. package/dist/navigation.js +9 -0
  42. package/dist/objectql.d.ts +254 -0
  43. package/dist/objectql.d.ts.map +1 -0
  44. package/dist/objectql.js +10 -0
  45. package/dist/overlay.d.ts +396 -0
  46. package/dist/overlay.d.ts.map +1 -0
  47. package/dist/overlay.js +9 -0
  48. package/dist/registry.d.ts +85 -0
  49. package/dist/registry.d.ts.map +1 -0
  50. package/dist/registry.js +1 -0
  51. package/package.json +82 -0
  52. package/src/api-types.ts +464 -0
  53. package/src/app.ts +138 -0
  54. package/src/base.ts +416 -0
  55. package/src/complex.ts +465 -0
  56. package/src/crud.ts +467 -0
  57. package/src/data-display.ts +630 -0
  58. package/src/data.ts +341 -0
  59. package/src/disclosure.ts +113 -0
  60. package/src/feedback.ts +170 -0
  61. package/src/form.ts +954 -0
  62. package/src/index.ts +350 -0
  63. package/src/layout.ts +451 -0
  64. package/src/navigation.ts +235 -0
  65. package/src/objectql.ts +301 -0
  66. package/src/overlay.ts +418 -0
  67. package/src/registry.ts +182 -0
@@ -0,0 +1,464 @@
1
+ /**
2
+ * @object-ui/types - API and Event Schemas
3
+ *
4
+ * Type definitions for API integration and event handling.
5
+ * These schemas enable dynamic API calls and event-driven interactions.
6
+ *
7
+ * @module api
8
+ * @packageDocumentation
9
+ */
10
+
11
+ import type { BaseSchema } from './base';
12
+
13
+ /**
14
+ * HTTP Method types
15
+ */
16
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
+
18
+ /**
19
+ * API request configuration
20
+ */
21
+ export interface APIRequest {
22
+ /**
23
+ * API endpoint URL
24
+ * Supports variable substitution: "/api/users/${userId}"
25
+ */
26
+ url: string;
27
+ /**
28
+ * HTTP method
29
+ * @default 'GET'
30
+ */
31
+ method?: HTTPMethod;
32
+ /**
33
+ * Request headers
34
+ */
35
+ headers?: Record<string, string>;
36
+ /**
37
+ * Request body data
38
+ * For POST, PUT, PATCH requests
39
+ */
40
+ data?: any;
41
+ /**
42
+ * Query parameters
43
+ */
44
+ params?: Record<string, any>;
45
+ /**
46
+ * Request timeout in milliseconds
47
+ */
48
+ timeout?: number;
49
+ /**
50
+ * Whether to send credentials (cookies)
51
+ * @default false
52
+ */
53
+ withCredentials?: boolean;
54
+ /**
55
+ * Data transformation function
56
+ * Transform request data before sending
57
+ */
58
+ transformRequest?: string;
59
+ /**
60
+ * Response transformation function
61
+ * Transform response data after receiving
62
+ */
63
+ transformResponse?: string;
64
+ }
65
+
66
+ /**
67
+ * API configuration for components
68
+ */
69
+ export interface APIConfig {
70
+ /**
71
+ * API request configuration
72
+ */
73
+ request?: APIRequest;
74
+ /**
75
+ * Success handler
76
+ * JavaScript expression or function name
77
+ */
78
+ onSuccess?: string;
79
+ /**
80
+ * Error handler
81
+ * JavaScript expression or function name
82
+ */
83
+ onError?: string;
84
+ /**
85
+ * Loading indicator
86
+ * Whether to show loading state during request
87
+ * @default true
88
+ */
89
+ showLoading?: boolean;
90
+ /**
91
+ * Success message to display
92
+ */
93
+ successMessage?: string;
94
+ /**
95
+ * Error message to display
96
+ */
97
+ errorMessage?: string;
98
+ /**
99
+ * Whether to reload data after success
100
+ * @default false
101
+ */
102
+ reload?: boolean;
103
+ /**
104
+ * Whether to redirect after success
105
+ */
106
+ redirect?: string;
107
+ /**
108
+ * Whether to close dialog/modal after success
109
+ * @default false
110
+ */
111
+ close?: boolean;
112
+ /**
113
+ * Retry configuration
114
+ */
115
+ retry?: {
116
+ /**
117
+ * Maximum retry attempts
118
+ */
119
+ maxAttempts?: number;
120
+ /**
121
+ * Delay between retries in milliseconds
122
+ */
123
+ delay?: number;
124
+ /**
125
+ * HTTP status codes to retry
126
+ */
127
+ retryOn?: number[];
128
+ };
129
+ /**
130
+ * Cache configuration
131
+ */
132
+ cache?: {
133
+ /**
134
+ * Cache key
135
+ */
136
+ key?: string;
137
+ /**
138
+ * Cache duration in milliseconds
139
+ */
140
+ duration?: number;
141
+ /**
142
+ * Whether to use stale cache while revalidating
143
+ */
144
+ staleWhileRevalidate?: boolean;
145
+ };
146
+ }
147
+
148
+ /**
149
+ * Event handler configuration
150
+ */
151
+ export interface EventHandler {
152
+ /**
153
+ * Event type
154
+ */
155
+ event: string;
156
+ /**
157
+ * Handler type
158
+ */
159
+ type: 'action' | 'api' | 'script' | 'navigation' | 'dialog' | 'toast' | 'custom';
160
+ /**
161
+ * Action configuration (for type: 'action')
162
+ */
163
+ action?: {
164
+ /**
165
+ * Action name/identifier
166
+ */
167
+ name: string;
168
+ /**
169
+ * Action parameters
170
+ */
171
+ params?: Record<string, any>;
172
+ };
173
+ /**
174
+ * API configuration (for type: 'api')
175
+ */
176
+ api?: APIConfig;
177
+ /**
178
+ * Script to execute (for type: 'script')
179
+ * JavaScript code as string
180
+ */
181
+ script?: string;
182
+ /**
183
+ * Navigation target (for type: 'navigation')
184
+ */
185
+ navigate?: {
186
+ /**
187
+ * Target URL or route
188
+ */
189
+ to: string;
190
+ /**
191
+ * Navigation type
192
+ */
193
+ type?: 'push' | 'replace' | 'reload';
194
+ /**
195
+ * Query parameters
196
+ */
197
+ params?: Record<string, any>;
198
+ /**
199
+ * Open in new window/tab
200
+ */
201
+ external?: boolean;
202
+ };
203
+ /**
204
+ * Dialog configuration (for type: 'dialog')
205
+ */
206
+ dialog?: {
207
+ /**
208
+ * Dialog type
209
+ */
210
+ type: 'alert' | 'confirm' | 'prompt' | 'modal';
211
+ /**
212
+ * Dialog title
213
+ */
214
+ title?: string;
215
+ /**
216
+ * Dialog content
217
+ */
218
+ content?: string | BaseSchema;
219
+ /**
220
+ * Dialog actions
221
+ */
222
+ actions?: Array<{
223
+ label: string;
224
+ handler?: EventHandler;
225
+ }>;
226
+ };
227
+ /**
228
+ * Toast configuration (for type: 'toast')
229
+ */
230
+ toast?: {
231
+ /**
232
+ * Toast type
233
+ */
234
+ type: 'success' | 'error' | 'warning' | 'info';
235
+ /**
236
+ * Toast message
237
+ */
238
+ message: string;
239
+ /**
240
+ * Toast duration in milliseconds
241
+ */
242
+ duration?: number;
243
+ };
244
+ /**
245
+ * Condition for executing handler
246
+ * JavaScript expression
247
+ */
248
+ condition?: string;
249
+ /**
250
+ * Whether to prevent default event behavior
251
+ */
252
+ preventDefault?: boolean;
253
+ /**
254
+ * Whether to stop event propagation
255
+ */
256
+ stopPropagation?: boolean;
257
+ /**
258
+ * Debounce delay in milliseconds
259
+ */
260
+ debounce?: number;
261
+ /**
262
+ * Throttle delay in milliseconds
263
+ */
264
+ throttle?: number;
265
+ }
266
+
267
+ /**
268
+ * Component with event handlers
269
+ */
270
+ export interface EventableSchema extends BaseSchema {
271
+ /**
272
+ * Event handlers configuration
273
+ */
274
+ events?: EventHandler[];
275
+ /**
276
+ * Click handler
277
+ */
278
+ onClick?: EventHandler | string;
279
+ /**
280
+ * Change handler
281
+ */
282
+ onChange?: EventHandler | string;
283
+ /**
284
+ * Submit handler
285
+ */
286
+ onSubmit?: EventHandler | string;
287
+ /**
288
+ * Focus handler
289
+ */
290
+ onFocus?: EventHandler | string;
291
+ /**
292
+ * Blur handler
293
+ */
294
+ onBlur?: EventHandler | string;
295
+ /**
296
+ * Mouse enter handler
297
+ */
298
+ onMouseEnter?: EventHandler | string;
299
+ /**
300
+ * Mouse leave handler
301
+ */
302
+ onMouseLeave?: EventHandler | string;
303
+ /**
304
+ * Key down handler
305
+ */
306
+ onKeyDown?: EventHandler | string;
307
+ /**
308
+ * Key up handler
309
+ */
310
+ onKeyUp?: EventHandler | string;
311
+ }
312
+
313
+ /**
314
+ * Data fetching configuration
315
+ */
316
+ export interface DataFetchConfig {
317
+ /**
318
+ * Data source API
319
+ */
320
+ api: string | APIRequest;
321
+ /**
322
+ * Whether to fetch on mount
323
+ * @default true
324
+ */
325
+ fetchOnMount?: boolean;
326
+ /**
327
+ * Polling interval in milliseconds
328
+ * If set, data will be refetched at this interval
329
+ */
330
+ pollInterval?: number;
331
+ /**
332
+ * Dependencies for refetching
333
+ * Array of variable names to watch
334
+ */
335
+ dependencies?: string[];
336
+ /**
337
+ * Default data before fetch completes
338
+ */
339
+ defaultData?: any;
340
+ /**
341
+ * Transform function for fetched data
342
+ * JavaScript expression or function name
343
+ */
344
+ transform?: string;
345
+ /**
346
+ * Filter function for data
347
+ * JavaScript expression or function name
348
+ */
349
+ filter?: string;
350
+ /**
351
+ * Sort configuration
352
+ */
353
+ sort?: {
354
+ /**
355
+ * Field to sort by
356
+ */
357
+ field: string;
358
+ /**
359
+ * Sort order
360
+ */
361
+ order: 'asc' | 'desc';
362
+ };
363
+ /**
364
+ * Pagination configuration
365
+ */
366
+ pagination?: {
367
+ /**
368
+ * Current page
369
+ */
370
+ page?: number;
371
+ /**
372
+ * Page size
373
+ */
374
+ pageSize?: number;
375
+ /**
376
+ * Whether pagination is enabled
377
+ */
378
+ enabled?: boolean;
379
+ };
380
+ }
381
+
382
+ /**
383
+ * Component with data fetching
384
+ */
385
+ export interface DataFetchableSchema extends BaseSchema {
386
+ /**
387
+ * Data fetching configuration
388
+ */
389
+ dataSource?: DataFetchConfig;
390
+ /**
391
+ * Loading state
392
+ */
393
+ loading?: boolean;
394
+ /**
395
+ * Error state
396
+ */
397
+ error?: string | null;
398
+ /**
399
+ * Fetched data
400
+ */
401
+ data?: any;
402
+ }
403
+
404
+ /**
405
+ * Expression evaluation context
406
+ */
407
+ export interface ExpressionContext {
408
+ /**
409
+ * Current component data
410
+ */
411
+ data?: any;
412
+ /**
413
+ * Global application state
414
+ */
415
+ state?: any;
416
+ /**
417
+ * Form values (when in form context)
418
+ */
419
+ form?: any;
420
+ /**
421
+ * Current user information
422
+ */
423
+ user?: any;
424
+ /**
425
+ * Environment variables
426
+ */
427
+ env?: Record<string, any>;
428
+ /**
429
+ * Utility functions
430
+ */
431
+ utils?: Record<string, (...args: any[]) => any>;
432
+ }
433
+
434
+ /**
435
+ * Expression schema for dynamic values
436
+ */
437
+ export interface ExpressionSchema {
438
+ /**
439
+ * Expression type
440
+ */
441
+ type: 'expression';
442
+ /**
443
+ * Expression string
444
+ * Supports ${} syntax for variable interpolation
445
+ */
446
+ value: string;
447
+ /**
448
+ * Default value if expression fails
449
+ */
450
+ defaultValue?: any;
451
+ /**
452
+ * Whether to watch and re-evaluate on context changes
453
+ * @default true
454
+ */
455
+ reactive?: boolean;
456
+ }
457
+
458
+ /**
459
+ * Union type of all API schemas
460
+ */
461
+ export type APISchema =
462
+ | EventableSchema
463
+ | DataFetchableSchema
464
+ | ExpressionSchema;
package/src/app.ts ADDED
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @object-ui/types - Application Schema
3
+ *
4
+ * Defines the metadata structure for a complete application, including
5
+ * global layout, navigation menus, and routing configuration.
6
+ */
7
+
8
+ import type { BaseSchema } from './base';
9
+
10
+ /**
11
+ * Top-level Application Configuration (app.json)
12
+ */
13
+ export interface AppSchema extends BaseSchema {
14
+ type: 'app';
15
+
16
+ /**
17
+ * Application Name (System ID)
18
+ */
19
+ name?: string;
20
+
21
+ /**
22
+ * Display Title
23
+ */
24
+ title?: string;
25
+
26
+ /**
27
+ * Application Description
28
+ */
29
+ description?: string;
30
+
31
+ /**
32
+ * Logo URL or Icon name
33
+ */
34
+ logo?: string;
35
+
36
+ /**
37
+ * Favicon URL
38
+ */
39
+ favicon?: string;
40
+
41
+ /**
42
+ * Global Layout Strategy
43
+ * - sidebar: Standard admin layout with left sidebar
44
+ * - header: Top navigation bar only
45
+ * - empty: No layout, pages are responsible for their own structure
46
+ * @default "sidebar"
47
+ */
48
+ layout?: 'sidebar' | 'header' | 'empty';
49
+
50
+ /**
51
+ * Global Navigation Menu
52
+ */
53
+ menu?: MenuItem[];
54
+
55
+ /**
56
+ * Global Actions (User Profile, Settings, etc)
57
+ */
58
+ actions?: AppAction[];
59
+ }
60
+
61
+ /**
62
+ * Navigation Menu Item
63
+ */
64
+ export interface MenuItem {
65
+ /**
66
+ * Item Type
67
+ */
68
+ type?: 'item' | 'group' | 'separator';
69
+
70
+ /**
71
+ * Display Label
72
+ */
73
+ label?: string;
74
+
75
+ /**
76
+ * Icon Name (Lucide)
77
+ */
78
+ icon?: string;
79
+
80
+ /**
81
+ * Target Path (Route)
82
+ */
83
+ path?: string;
84
+
85
+ /**
86
+ * External Link
87
+ */
88
+ href?: string;
89
+
90
+ /**
91
+ * Child Items (Submenu)
92
+ */
93
+ children?: MenuItem[];
94
+
95
+ /**
96
+ * Badge / Count
97
+ */
98
+ badge?: string | number;
99
+
100
+ /**
101
+ * Visibility Condition
102
+ */
103
+ hidden?: boolean | string;
104
+ }
105
+
106
+ /**
107
+ * Application Header/Toolbar Action
108
+ */
109
+ export interface AppAction {
110
+ type: 'button' | 'dropdown' | 'user';
111
+ label?: string;
112
+ icon?: string;
113
+ onClick?: string;
114
+ /**
115
+ * User Avatar URL (for type='user')
116
+ */
117
+ avatar?: string;
118
+ /**
119
+ * Additional description (e.g. email for user)
120
+ */
121
+ description?: string;
122
+ /**
123
+ * Dropdown Menu Items (for type='dropdown' or 'user')
124
+ */
125
+ items?: MenuItem[];
126
+ /**
127
+ * Keyboard shortcut
128
+ */
129
+ shortcut?: string;
130
+ /**
131
+ * Button variant
132
+ */
133
+ variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
134
+ /**
135
+ * Button size
136
+ */
137
+ size?: 'default' | 'sm' | 'lg' | 'icon';
138
+ }