@object-ui/react 0.5.0 → 3.0.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 (144) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/dist/LazyPluginLoader.d.ts +44 -0
  4. package/dist/LazyPluginLoader.js +92 -3
  5. package/dist/SchemaRenderer.d.ts +20 -1
  6. package/dist/SchemaRenderer.js +76 -13
  7. package/dist/components/form/FieldFactory.js +44 -40
  8. package/dist/components/form/FormRenderer.js +45 -3
  9. package/dist/context/ActionContext.d.ts +76 -0
  10. package/dist/context/ActionContext.js +139 -0
  11. package/dist/context/DndContext.d.ts +135 -0
  12. package/dist/context/DndContext.js +120 -0
  13. package/dist/context/NotificationContext.d.ts +113 -0
  14. package/dist/context/NotificationContext.js +130 -0
  15. package/dist/context/ThemeContext.d.ts +94 -0
  16. package/dist/context/ThemeContext.js +215 -0
  17. package/dist/context/index.d.ts +4 -0
  18. package/dist/context/index.js +4 -0
  19. package/dist/hooks/index.d.ts +22 -0
  20. package/dist/hooks/index.js +22 -0
  21. package/dist/hooks/useActionRunner.d.ts +21 -7
  22. package/dist/hooks/useActionRunner.js +27 -7
  23. package/dist/hooks/useAnimation.d.ts +46 -0
  24. package/dist/hooks/useAnimation.js +59 -0
  25. package/dist/hooks/useClientNotifications.d.ts +53 -0
  26. package/dist/hooks/useClientNotifications.js +190 -0
  27. package/dist/hooks/useColumnSummary.d.ts +38 -0
  28. package/dist/hooks/useColumnSummary.js +54 -0
  29. package/dist/hooks/useCrudShortcuts.d.ts +39 -0
  30. package/dist/hooks/useCrudShortcuts.js +96 -0
  31. package/dist/hooks/useDensityMode.d.ts +48 -0
  32. package/dist/hooks/useDensityMode.js +60 -0
  33. package/dist/hooks/useDiscovery.d.ts +78 -0
  34. package/dist/hooks/useDiscovery.js +96 -0
  35. package/dist/hooks/useDynamicApp.d.ts +70 -0
  36. package/dist/hooks/useDynamicApp.js +92 -0
  37. package/dist/hooks/useETagCache.d.ts +75 -0
  38. package/dist/hooks/useETagCache.js +306 -0
  39. package/dist/hooks/useFocusManagement.d.ts +89 -0
  40. package/dist/hooks/useFocusManagement.js +188 -0
  41. package/dist/hooks/useFocusTrap.d.ts +41 -0
  42. package/dist/hooks/useFocusTrap.js +103 -0
  43. package/dist/hooks/useKeyboardShortcuts.d.ts +49 -0
  44. package/dist/hooks/useKeyboardShortcuts.js +86 -0
  45. package/dist/hooks/useNavigationOverlay.d.ts +78 -0
  46. package/dist/hooks/useNavigationOverlay.js +112 -0
  47. package/dist/hooks/useOffline.d.ts +96 -0
  48. package/dist/hooks/useOffline.js +185 -0
  49. package/dist/hooks/usePageTransition.d.ts +60 -0
  50. package/dist/hooks/usePageTransition.js +111 -0
  51. package/dist/hooks/usePageVariables.d.ts +67 -0
  52. package/dist/hooks/usePageVariables.js +109 -0
  53. package/dist/hooks/usePerformance.d.ts +87 -0
  54. package/dist/hooks/usePerformance.js +165 -0
  55. package/dist/hooks/usePerformanceBudget.d.ts +78 -0
  56. package/dist/hooks/usePerformanceBudget.js +209 -0
  57. package/dist/hooks/useReducedMotion.d.ts +28 -0
  58. package/dist/hooks/useReducedMotion.js +48 -0
  59. package/dist/hooks/useSchemaPersistence.d.ts +87 -0
  60. package/dist/hooks/useSchemaPersistence.js +173 -0
  61. package/dist/hooks/useViewData.d.ts +73 -0
  62. package/dist/hooks/useViewData.js +135 -0
  63. package/dist/hooks/useViewSharing.d.ts +57 -0
  64. package/dist/hooks/useViewSharing.js +74 -0
  65. package/dist/hooks/useViewTransition.d.ts +54 -0
  66. package/dist/hooks/useViewTransition.js +83 -0
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.js +2 -0
  69. package/dist/utils/i18n.d.ts +10 -0
  70. package/dist/utils/i18n.js +12 -0
  71. package/package.json +7 -5
  72. package/src/LazyPluginLoader.tsx +129 -7
  73. package/src/SchemaRenderer.tsx +122 -13
  74. package/src/__tests__/LazyPluginLoader.test.tsx +97 -1
  75. package/src/__tests__/SchemaRenderer.aria.test.tsx +118 -0
  76. package/src/__tests__/SchemaRenderer.errorBoundary.test.tsx +114 -0
  77. package/src/__tests__/SchemaRendererProvider.smoke.test.tsx +132 -0
  78. package/src/__tests__/ThemeProvider.test.tsx +451 -0
  79. package/src/__tests__/useNavigationOverlay.test.ts +416 -0
  80. package/src/__tests__/useOffline.test.ts +198 -0
  81. package/src/__tests__/usePageTransition.test.ts +214 -0
  82. package/src/__tests__/usePageVariables.test.tsx +334 -0
  83. package/src/__tests__/usePerformance.test.ts +137 -0
  84. package/src/__tests__/useViewData.test.tsx +422 -0
  85. package/src/__tests__/view-switching.test.tsx +456 -0
  86. package/src/components/form/FieldFactory.tsx +51 -46
  87. package/src/components/form/FormRenderer.test.tsx +145 -0
  88. package/src/components/form/FormRenderer.tsx +52 -3
  89. package/src/context/ActionContext.tsx +213 -0
  90. package/src/context/DndContext.tsx +260 -0
  91. package/src/context/NotificationContext.tsx +280 -0
  92. package/src/context/ThemeContext.tsx +325 -0
  93. package/src/context/__tests__/ActionContext.test.tsx +174 -0
  94. package/src/context/__tests__/DndContext.test.tsx +150 -0
  95. package/src/context/__tests__/NotificationContext.test.tsx +176 -0
  96. package/src/context/index.ts +4 -0
  97. package/src/hooks/__tests__/useActionRunner.test.ts +153 -0
  98. package/src/hooks/__tests__/useAnimation.test.ts +82 -0
  99. package/src/hooks/__tests__/useColumnSummary.test.ts +93 -0
  100. package/src/hooks/__tests__/useDensityMode.test.ts +81 -0
  101. package/src/hooks/__tests__/useDiscovery.test.tsx +149 -0
  102. package/src/hooks/__tests__/useDynamicApp.test.ts +161 -0
  103. package/src/hooks/__tests__/useETagCache.test.ts +153 -0
  104. package/src/hooks/__tests__/useExpression.test.ts +86 -0
  105. package/src/hooks/__tests__/useFocusTrap.test.ts +47 -0
  106. package/src/hooks/__tests__/useKeyboardShortcuts.test.ts +144 -0
  107. package/src/hooks/__tests__/usePerformanceBudget.test.ts +157 -0
  108. package/src/hooks/__tests__/useSchemaPersistence.test.ts +220 -0
  109. package/src/hooks/__tests__/useViewSharing.test.ts +121 -0
  110. package/src/hooks/__tests__/useViewTransition.test.ts +61 -0
  111. package/src/hooks/index.ts +22 -1
  112. package/src/hooks/useActionRunner.ts +49 -11
  113. package/src/hooks/useAnimation.ts +117 -0
  114. package/src/hooks/useClientNotifications.ts +251 -0
  115. package/src/hooks/useColumnSummary.ts +87 -0
  116. package/src/hooks/useCrudShortcuts.ts +126 -0
  117. package/src/hooks/useDensityMode.ts +102 -0
  118. package/src/hooks/useDiscovery.ts +141 -0
  119. package/src/hooks/useDynamicApp.ts +142 -0
  120. package/src/hooks/useETagCache.ts +404 -0
  121. package/src/hooks/useFocusManagement.ts +248 -0
  122. package/src/hooks/useFocusTrap.ts +138 -0
  123. package/src/hooks/useKeyboardShortcuts.ts +119 -0
  124. package/src/hooks/useNavigationOverlay.ts +180 -0
  125. package/src/hooks/useOffline.ts +301 -0
  126. package/src/hooks/usePageTransition.ts +187 -0
  127. package/src/hooks/usePageVariables.tsx +157 -0
  128. package/src/hooks/usePerformance.ts +246 -0
  129. package/src/hooks/usePerformanceBudget.ts +313 -0
  130. package/src/hooks/useReducedMotion.ts +53 -0
  131. package/src/hooks/useSchemaPersistence.ts +222 -0
  132. package/src/hooks/useViewData.ts +201 -0
  133. package/src/hooks/useViewSharing.ts +140 -0
  134. package/src/hooks/useViewTransition.ts +144 -0
  135. package/src/index.ts +21 -0
  136. package/src/utils/i18n.ts +10 -0
  137. package/tsconfig.json +1 -0
  138. package/tsconfig.tsbuildinfo +1 -1
  139. package/dist/__tests__/LazyPluginLoader.test.d.ts +0 -8
  140. package/dist/__tests__/LazyPluginLoader.test.js +0 -49
  141. package/dist/components/form/FormRenderer.test.d.ts +0 -8
  142. package/dist/components/form/FormRenderer.test.js +0 -534
  143. package/dist/index.test.d.ts +0 -8
  144. package/dist/index.test.js +0 -13
@@ -1,8 +0,0 @@
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
- export {};
@@ -1,49 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * ObjectUI
4
- * Copyright (c) 2024-present ObjectStack Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- import { describe, it, expect, vi } from 'vitest';
10
- import { render, screen, waitFor } from '@testing-library/react';
11
- import { createLazyPlugin } from '../LazyPluginLoader';
12
- describe('createLazyPlugin', () => {
13
- it('should create a lazy-loaded component', async () => {
14
- const TestComponent = () => _jsx("div", { children: "Test Component" });
15
- const LazyComponent = createLazyPlugin(() => Promise.resolve({ default: TestComponent }));
16
- render(_jsx(LazyComponent, {}));
17
- await waitFor(() => {
18
- expect(screen.getByText('Test Component')).toBeInTheDocument();
19
- });
20
- });
21
- it('should show custom fallback while loading', async () => {
22
- const TestComponent = () => _jsx("div", { children: "Test Component" });
23
- const LazyComponent = createLazyPlugin(() => new Promise((resolve) => {
24
- setTimeout(() => resolve({ default: TestComponent }), 100);
25
- }), { fallback: _jsx("div", { children: "Loading..." }) });
26
- render(_jsx(LazyComponent, {}));
27
- expect(screen.getByText('Loading...')).toBeInTheDocument();
28
- await waitFor(() => {
29
- expect(screen.getByText('Test Component')).toBeInTheDocument();
30
- });
31
- });
32
- it('should pass props to the lazy component', async () => {
33
- const TestComponent = ({ message }) => _jsx("div", { children: message });
34
- const LazyComponent = createLazyPlugin(() => Promise.resolve({ default: TestComponent }));
35
- render(_jsx(LazyComponent, { message: "Hello World" }));
36
- await waitFor(() => {
37
- expect(screen.getByText('Hello World')).toBeInTheDocument();
38
- });
39
- });
40
- it('should handle loading errors gracefully', async () => {
41
- // Mock console.error to avoid noise in test output
42
- const originalError = console.error;
43
- console.error = vi.fn();
44
- const LazyComponent = createLazyPlugin(() => Promise.reject(new Error('Load error')));
45
- expect(() => render(_jsx(LazyComponent, {}))).not.toThrow();
46
- // Restore console.error
47
- console.error = originalError;
48
- });
49
- });
@@ -1,8 +0,0 @@
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
- import '@testing-library/jest-dom';
@@ -1,534 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * ObjectUI
4
- * Copyright (c) 2024-present ObjectStack Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- import { describe, it, expect } from 'vitest';
10
- import { render, screen } from '@testing-library/react';
11
- import '@testing-library/jest-dom';
12
- import { FormRenderer } from './FormRenderer';
13
- describe('FormRenderer', () => {
14
- it('should render a simple form with text fields', () => {
15
- const schema = {
16
- type: 'simple',
17
- sections: [
18
- {
19
- label: 'Personal Information',
20
- collapsible: false,
21
- collapsed: false,
22
- columns: 2,
23
- fields: [
24
- {
25
- field: 'firstName',
26
- label: 'First Name',
27
- required: true,
28
- widget: 'text',
29
- },
30
- {
31
- field: 'lastName',
32
- label: 'Last Name',
33
- required: true,
34
- widget: 'text',
35
- },
36
- ],
37
- },
38
- ],
39
- };
40
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
41
- expect(screen.getByText('Personal Information')).toBeInTheDocument();
42
- expect(screen.getByLabelText(/First Name/)).toBeInTheDocument();
43
- expect(screen.getByLabelText(/Last Name/)).toBeInTheDocument();
44
- });
45
- it('should render form with initial data', () => {
46
- const schema = {
47
- type: 'simple',
48
- sections: [
49
- {
50
- label: 'User Details',
51
- collapsible: false,
52
- collapsed: false,
53
- columns: 1,
54
- fields: [
55
- {
56
- field: 'username',
57
- label: 'Username',
58
- widget: 'text',
59
- },
60
- ],
61
- },
62
- ],
63
- };
64
- const data = { username: 'john_doe' };
65
- render(_jsx(FormRenderer, { schema: schema, data: data }));
66
- const input = screen.getByLabelText('Username');
67
- expect(input.value).toBe('john_doe');
68
- });
69
- it('should handle multi-column layout', () => {
70
- const schema = {
71
- type: 'simple',
72
- sections: [
73
- {
74
- label: 'Contact',
75
- collapsible: false,
76
- collapsed: false,
77
- columns: 3,
78
- fields: [
79
- {
80
- field: 'email',
81
- label: 'Email',
82
- widget: 'email',
83
- },
84
- {
85
- field: 'phone',
86
- label: 'Phone',
87
- widget: 'tel',
88
- },
89
- {
90
- field: 'address',
91
- label: 'Address',
92
- widget: 'textarea',
93
- colSpan: 3,
94
- },
95
- ],
96
- },
97
- ],
98
- };
99
- render(_jsx(FormRenderer, { schema: schema }));
100
- expect(screen.getByLabelText('Email')).toBeInTheDocument();
101
- expect(screen.getByLabelText('Phone')).toBeInTheDocument();
102
- expect(screen.getByLabelText('Address')).toBeInTheDocument();
103
- });
104
- it('should hide fields marked as hidden', () => {
105
- const schema = {
106
- type: 'simple',
107
- sections: [
108
- {
109
- label: 'Form',
110
- collapsible: false,
111
- collapsed: false,
112
- columns: 1,
113
- fields: [
114
- {
115
- field: 'visible',
116
- label: 'Visible Field',
117
- widget: 'text',
118
- },
119
- {
120
- field: 'hidden',
121
- label: 'Hidden Field',
122
- widget: 'text',
123
- hidden: true,
124
- },
125
- ],
126
- },
127
- ],
128
- };
129
- render(_jsx(FormRenderer, { schema: schema }));
130
- expect(screen.getByLabelText('Visible Field')).toBeInTheDocument();
131
- expect(screen.queryByLabelText('Hidden Field')).not.toBeInTheDocument();
132
- });
133
- it('should support legacy string field format', () => {
134
- const schema = {
135
- type: 'simple',
136
- sections: [
137
- {
138
- label: 'Legacy Form',
139
- collapsible: false,
140
- collapsed: false,
141
- columns: 1,
142
- fields: ['username', 'email'],
143
- },
144
- ],
145
- };
146
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
147
- // String fields should still render as inputs
148
- const inputs = container.querySelectorAll('input[type="text"]');
149
- expect(inputs.length).toBeGreaterThan(0);
150
- });
151
- it('should handle number fields', () => {
152
- const schema = {
153
- type: 'simple',
154
- sections: [
155
- {
156
- label: 'Numbers',
157
- collapsible: false,
158
- collapsed: false,
159
- columns: 1,
160
- fields: [
161
- {
162
- field: 'age',
163
- label: 'Age',
164
- widget: 'number',
165
- required: true,
166
- },
167
- ],
168
- },
169
- ],
170
- };
171
- render(_jsx(FormRenderer, { schema: schema }));
172
- const input = screen.getByLabelText(/Age/);
173
- expect(input.type).toBe('number');
174
- });
175
- it('should handle checkbox fields', () => {
176
- const schema = {
177
- type: 'simple',
178
- sections: [
179
- {
180
- label: 'Preferences',
181
- collapsible: false,
182
- collapsed: false,
183
- columns: 1,
184
- fields: [
185
- {
186
- field: 'subscribe',
187
- label: 'Subscribe to newsletter',
188
- widget: 'checkbox',
189
- },
190
- ],
191
- },
192
- ],
193
- };
194
- render(_jsx(FormRenderer, { schema: schema }));
195
- const checkbox = screen.getByLabelText('Subscribe to newsletter');
196
- expect(checkbox.type).toBe('checkbox');
197
- });
198
- it('should render help text when provided', () => {
199
- const schema = {
200
- type: 'simple',
201
- sections: [
202
- {
203
- label: 'Help Text',
204
- collapsible: false,
205
- collapsed: false,
206
- columns: 1,
207
- fields: [
208
- {
209
- field: 'password',
210
- label: 'Password',
211
- widget: 'password',
212
- helpText: 'Must be at least 8 characters',
213
- },
214
- ],
215
- },
216
- ],
217
- };
218
- render(_jsx(FormRenderer, { schema: schema }));
219
- expect(screen.getByText('Must be at least 8 characters')).toBeInTheDocument();
220
- });
221
- it('should mark required fields with asterisk', () => {
222
- const schema = {
223
- type: 'simple',
224
- sections: [
225
- {
226
- label: 'Required',
227
- collapsible: false,
228
- collapsed: false,
229
- columns: 1,
230
- fields: [
231
- {
232
- field: 'name',
233
- label: 'Name',
234
- widget: 'text',
235
- required: true,
236
- },
237
- ],
238
- },
239
- ],
240
- };
241
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
242
- // Check for asterisk
243
- const asterisk = container.querySelector('.text-red-500');
244
- expect(asterisk).toBeInTheDocument();
245
- expect(asterisk?.textContent).toContain('*');
246
- });
247
- // Test new field types
248
- describe('Extended field types', () => {
249
- it('should render currency field with dollar sign', () => {
250
- const schema = {
251
- type: 'simple',
252
- sections: [
253
- {
254
- label: 'Pricing',
255
- collapsible: false,
256
- collapsed: false,
257
- columns: 1,
258
- fields: [
259
- {
260
- field: 'price',
261
- label: 'Price',
262
- widget: 'currency',
263
- },
264
- ],
265
- },
266
- ],
267
- };
268
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
269
- expect(screen.getByLabelText('Price')).toBeInTheDocument();
270
- expect(container.querySelector('.absolute')?.textContent).toBe('$');
271
- });
272
- it('should render percent field with percent sign', () => {
273
- const schema = {
274
- type: 'simple',
275
- sections: [
276
- {
277
- label: 'Metrics',
278
- collapsible: false,
279
- collapsed: false,
280
- columns: 1,
281
- fields: [
282
- {
283
- field: 'discount',
284
- label: 'Discount',
285
- widget: 'percent',
286
- },
287
- ],
288
- },
289
- ],
290
- };
291
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
292
- expect(screen.getByLabelText('Discount')).toBeInTheDocument();
293
- expect(container.querySelector('.absolute')?.textContent).toBe('%');
294
- });
295
- it('should render phone field', () => {
296
- const schema = {
297
- type: 'simple',
298
- sections: [
299
- {
300
- label: 'Contact',
301
- collapsible: false,
302
- collapsed: false,
303
- columns: 1,
304
- fields: [
305
- {
306
- field: 'phoneNumber',
307
- label: 'Phone Number',
308
- widget: 'phone',
309
- },
310
- ],
311
- },
312
- ],
313
- };
314
- render(_jsx(FormRenderer, { schema: schema }));
315
- const input = screen.getByLabelText('Phone Number');
316
- expect(input.type).toBe('tel');
317
- });
318
- it('should render markdown field as textarea', () => {
319
- const schema = {
320
- type: 'simple',
321
- sections: [
322
- {
323
- label: 'Content',
324
- collapsible: false,
325
- collapsed: false,
326
- columns: 1,
327
- fields: [
328
- {
329
- field: 'content',
330
- label: 'Content',
331
- widget: 'markdown',
332
- },
333
- ],
334
- },
335
- ],
336
- };
337
- render(_jsx(FormRenderer, { schema: schema }));
338
- const textarea = screen.getByLabelText('Content');
339
- expect(textarea.tagName).toBe('TEXTAREA');
340
- });
341
- it('should render html field as textarea', () => {
342
- const schema = {
343
- type: 'simple',
344
- sections: [
345
- {
346
- label: 'Content',
347
- collapsible: false,
348
- collapsed: false,
349
- columns: 1,
350
- fields: [
351
- {
352
- field: 'htmlContent',
353
- label: 'HTML Content',
354
- widget: 'html',
355
- },
356
- ],
357
- },
358
- ],
359
- };
360
- render(_jsx(FormRenderer, { schema: schema }));
361
- const textarea = screen.getByLabelText('HTML Content');
362
- expect(textarea.tagName).toBe('TEXTAREA');
363
- });
364
- it('should render file field', () => {
365
- const schema = {
366
- type: 'simple',
367
- sections: [
368
- {
369
- label: 'Upload',
370
- collapsible: false,
371
- collapsed: false,
372
- columns: 1,
373
- fields: [
374
- {
375
- field: 'document',
376
- label: 'Document',
377
- widget: 'file',
378
- },
379
- ],
380
- },
381
- ],
382
- };
383
- render(_jsx(FormRenderer, { schema: schema }));
384
- const input = screen.getByLabelText('Document');
385
- expect(input.type).toBe('file');
386
- });
387
- it('should render image field', () => {
388
- const schema = {
389
- type: 'simple',
390
- sections: [
391
- {
392
- label: 'Upload',
393
- collapsible: false,
394
- collapsed: false,
395
- columns: 1,
396
- fields: [
397
- {
398
- field: 'avatar',
399
- label: 'Avatar',
400
- widget: 'image',
401
- },
402
- ],
403
- },
404
- ],
405
- };
406
- render(_jsx(FormRenderer, { schema: schema }));
407
- const input = screen.getByLabelText('Avatar');
408
- expect(input.type).toBe('file');
409
- });
410
- it('should render location field with lat/lng inputs', () => {
411
- const schema = {
412
- type: 'simple',
413
- sections: [
414
- {
415
- label: 'Location',
416
- collapsible: false,
417
- collapsed: false,
418
- columns: 1,
419
- fields: [
420
- {
421
- field: 'coordinates',
422
- label: 'Coordinates',
423
- widget: 'location',
424
- },
425
- ],
426
- },
427
- ],
428
- };
429
- const { container } = render(_jsx(FormRenderer, { schema: schema }));
430
- const inputs = container.querySelectorAll('input[type="number"]');
431
- expect(inputs.length).toBe(2);
432
- });
433
- it('should render lookup field as select', () => {
434
- const schema = {
435
- type: 'simple',
436
- sections: [
437
- {
438
- label: 'Relations',
439
- collapsible: false,
440
- collapsed: false,
441
- columns: '1',
442
- fields: [
443
- {
444
- field: 'account',
445
- label: 'Account',
446
- widget: 'lookup',
447
- options: [
448
- { label: 'Account 1', value: '1' },
449
- { label: 'Account 2', value: '2' },
450
- ],
451
- },
452
- ],
453
- },
454
- ],
455
- };
456
- render(_jsx(FormRenderer, { schema: schema }));
457
- const select = screen.getByLabelText('Account');
458
- expect(select.tagName).toBe('SELECT');
459
- });
460
- it('should render user field as select', () => {
461
- const schema = {
462
- type: 'simple',
463
- sections: [
464
- {
465
- label: 'Assignment',
466
- collapsible: false,
467
- collapsed: false,
468
- columns: '1',
469
- fields: [
470
- {
471
- field: 'assignedTo',
472
- label: 'Assigned To',
473
- widget: 'user',
474
- options: [
475
- { label: 'User 1', value: 'user1' },
476
- { label: 'User 2', value: 'user2' },
477
- ],
478
- },
479
- ],
480
- },
481
- ],
482
- };
483
- render(_jsx(FormRenderer, { schema: schema }));
484
- const select = screen.getByLabelText('Assigned To');
485
- expect(select.tagName).toBe('SELECT');
486
- });
487
- it('should render formula field as disabled input', () => {
488
- const schema = {
489
- type: 'simple',
490
- sections: [
491
- {
492
- label: 'Computed',
493
- collapsible: false,
494
- collapsed: false,
495
- columns: 1,
496
- fields: [
497
- {
498
- field: 'total',
499
- label: 'Total',
500
- widget: 'formula',
501
- },
502
- ],
503
- },
504
- ],
505
- };
506
- render(_jsx(FormRenderer, { schema: schema }));
507
- const input = screen.getByLabelText('Total');
508
- expect(input.disabled).toBe(true);
509
- });
510
- it('should render object field as JSON textarea', () => {
511
- const schema = {
512
- type: 'simple',
513
- sections: [
514
- {
515
- label: 'Data',
516
- collapsible: false,
517
- collapsed: false,
518
- columns: 1,
519
- fields: [
520
- {
521
- field: 'metadata',
522
- label: 'Metadata',
523
- widget: 'object',
524
- },
525
- ],
526
- },
527
- ],
528
- };
529
- render(_jsx(FormRenderer, { schema: schema }));
530
- const textarea = screen.getByLabelText('Metadata');
531
- expect(textarea.tagName).toBe('TEXTAREA');
532
- });
533
- });
534
- });
@@ -1,8 +0,0 @@
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
- export {};
@@ -1,13 +0,0 @@
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
- import { describe, it, expect } from 'vitest';
9
- describe('react', () => {
10
- it('should work', () => {
11
- expect(true).toBe(true);
12
- });
13
- });