@object-ui/components 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 (119) hide show
  1. package/.turbo/turbo-build.log +12 -25
  2. package/CHANGELOG.md +32 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +23987 -22576
  5. package/dist/index.umd.cjs +30 -30
  6. package/dist/src/custom/action-param-dialog.d.ts +21 -0
  7. package/dist/src/custom/index.d.ts +4 -0
  8. package/dist/src/custom/navigation-overlay.d.ts +50 -0
  9. package/dist/src/custom/view-skeleton.d.ts +37 -0
  10. package/dist/src/custom/view-states.d.ts +33 -0
  11. package/dist/src/index.d.ts +1 -0
  12. package/dist/src/renderers/action/action-button.d.ts +11 -0
  13. package/dist/src/renderers/action/action-group.d.ts +25 -0
  14. package/dist/src/renderers/action/action-icon.d.ts +10 -0
  15. package/dist/src/renderers/action/action-menu.d.ts +19 -0
  16. package/dist/src/renderers/action/index.d.ts +0 -0
  17. package/dist/src/renderers/action/resolve-icon.d.ts +6 -0
  18. package/package.json +20 -19
  19. package/src/__tests__/PageRendererRegions.test.tsx +664 -55
  20. package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +811 -0
  21. package/src/__tests__/__snapshots__/snapshot.test.tsx.snap +327 -0
  22. package/src/__tests__/accessibility.test.tsx +137 -0
  23. package/src/__tests__/api-consistency.test.tsx +596 -0
  24. package/src/__tests__/color-contrast.test.tsx +212 -0
  25. package/src/__tests__/compliance.test.tsx +72 -0
  26. package/src/__tests__/edge-cases.test.tsx +285 -0
  27. package/src/__tests__/navigation-overlay.test.tsx +273 -0
  28. package/src/__tests__/snapshot-critical.test.tsx +317 -0
  29. package/src/__tests__/snapshot.test.tsx +205 -0
  30. package/src/__tests__/view-compliance.test.tsx +153 -0
  31. package/src/__tests__/wcag-audit.test.tsx +493 -0
  32. package/src/custom/action-param-dialog.tsx +264 -0
  33. package/src/custom/index.ts +4 -0
  34. package/src/custom/navigation-overlay.tsx +296 -0
  35. package/src/custom/view-skeleton.tsx +243 -0
  36. package/src/custom/view-states.tsx +153 -0
  37. package/src/index.ts +1 -0
  38. package/src/renderers/action/action-button.tsx +147 -0
  39. package/src/renderers/action/action-group.tsx +270 -0
  40. package/src/renderers/action/action-icon.tsx +150 -0
  41. package/src/renderers/action/action-menu.tsx +203 -0
  42. package/src/renderers/action/index.ts +18 -0
  43. package/src/renderers/action/resolve-icon.ts +35 -0
  44. package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +275 -0
  45. package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +120 -0
  46. package/src/renderers/complex/__tests__/data-table-editing.test.tsx +221 -0
  47. package/src/renderers/complex/data-table.tsx +269 -33
  48. package/src/renderers/complex/resizable.tsx +20 -17
  49. package/src/renderers/data-display/list.tsx +1 -1
  50. package/src/renderers/data-display/table.tsx +1 -1
  51. package/src/renderers/data-display/tree-view.tsx +2 -1
  52. package/src/renderers/form/form.tsx +33 -10
  53. package/src/renderers/index.ts +1 -0
  54. package/src/renderers/layout/aspect-ratio.tsx +1 -1
  55. package/src/renderers/layout/page.tsx +416 -52
  56. package/src/renderers/navigation/sidebar.tsx +6 -0
  57. package/src/renderers/placeholders.tsx +2 -2
  58. package/src/stories/MockedData.stories.tsx +87 -37
  59. package/src/stories-json/Accessibility.mdx +297 -0
  60. package/src/stories-json/EdgeCases.stories.tsx +160 -0
  61. package/src/stories-json/GettingStarted.mdx +89 -0
  62. package/src/stories-json/Introduction.mdx +127 -0
  63. package/src/stories-json/accordion.stories.tsx +1 -1
  64. package/src/stories-json/aggrid.stories.tsx +1 -1
  65. package/src/stories-json/alert.stories.tsx +1 -1
  66. package/src/stories-json/aspect-ratio.stories.tsx +1 -1
  67. package/src/stories-json/avatar.stories.tsx +1 -1
  68. package/src/stories-json/badge.stories.tsx +1 -1
  69. package/src/stories-json/breadcrumb.stories.tsx +1 -1
  70. package/src/stories-json/button-group.stories.tsx +1 -1
  71. package/src/stories-json/button.stories.tsx +1 -1
  72. package/src/stories-json/calendar.stories.tsx +1 -1
  73. package/src/stories-json/card.stories.tsx +1 -1
  74. package/src/stories-json/carousel.stories.tsx +1 -1
  75. package/src/stories-json/charts.stories.tsx +1 -1
  76. package/src/stories-json/chatbot.stories.tsx +1 -1
  77. package/src/stories-json/code-editor.stories.tsx +1 -1
  78. package/src/stories-json/collapsible.stories.tsx +1 -1
  79. package/src/stories-json/controls.stories.tsx +1 -1
  80. package/src/stories-json/crm-live-data.stories.tsx +154 -0
  81. package/src/stories-json/data-table.stories.tsx +80 -4
  82. package/src/stories-json/data_display_extras.stories.tsx +1 -1
  83. package/src/stories-json/date-picker.stories.tsx +1 -1
  84. package/src/stories-json/detail-view.stories.tsx +1 -1
  85. package/src/stories-json/dialog.stories.tsx +1 -1
  86. package/src/stories-json/feedback_extras.stories.tsx +1 -1
  87. package/src/stories-json/feedback_others.stories.tsx +1 -1
  88. package/src/stories-json/form-variants.stories.tsx +210 -0
  89. package/src/stories-json/form_advanced.stories.tsx +1 -1
  90. package/src/stories-json/form_extras.stories.tsx +1 -1
  91. package/src/stories-json/grid.stories.tsx +1 -1
  92. package/src/stories-json/icon.stories.tsx +1 -1
  93. package/src/stories-json/input.stories.tsx +1 -1
  94. package/src/stories-json/kanban.stories.tsx +1 -1
  95. package/src/stories-json/layout_extended.stories.tsx +1 -1
  96. package/src/stories-json/layout_flex.stories.tsx +1 -1
  97. package/src/stories-json/list-view.stories.tsx +1 -1
  98. package/src/stories-json/markdown.stories.tsx +1 -1
  99. package/src/stories-json/menus.stories.tsx +1 -1
  100. package/src/stories-json/metric-card.stories.tsx +1 -1
  101. package/src/stories-json/navigation-menu.stories.tsx +1 -1
  102. package/src/stories-json/object-aggrid-advanced.stories.tsx +389 -0
  103. package/src/stories-json/object-aggrid.stories.tsx +1 -1
  104. package/src/stories-json/object-form.stories.tsx +1 -1
  105. package/src/stories-json/object-gantt.stories.tsx +1 -1
  106. package/src/stories-json/object-grid.stories.tsx +159 -1
  107. package/src/stories-json/object-map.stories.tsx +1 -1
  108. package/src/stories-json/object-view.stories.tsx +1 -1
  109. package/src/stories-json/overlay_extras.stories.tsx +1 -1
  110. package/src/stories-json/overlay_others.stories.tsx +1 -1
  111. package/src/stories-json/resizable.stories.tsx +1 -1
  112. package/src/stories-json/select.stories.tsx +1 -1
  113. package/src/stories-json/separator.stories.tsx +1 -1
  114. package/src/stories-json/statistic.stories.tsx +1 -1
  115. package/src/stories-json/tabs.stories.tsx +1 -1
  116. package/src/stories-json/timeline.stories.tsx +1 -1
  117. package/src/stories-json/typography.stories.tsx +1 -1
  118. package/src/ui/slider.tsx +6 -2
  119. package/src/stories/Introduction.mdx +0 -34
@@ -1,53 +1,396 @@
1
1
  /**
2
- * ObjectUI
2
+ * ObjectUI — Page Renderer
3
3
  * Copyright (c) 2024-present ObjectStack Inc.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * The Page renderer interprets PageSchema into structured layouts.
9
+ * It supports four page types (record, home, app, utility) and
10
+ * renders named regions (header, sidebar, main, footer, aside) with
11
+ * configurable widths. When no regions are defined, it falls back to
12
+ * body/children for backward compatibility.
7
13
  */
8
14
 
9
- import React from 'react';
10
- import { PageSchema } from '@object-ui/types';
11
- import { SchemaRenderer } from '@object-ui/react';
15
+ import React, { useMemo } from 'react';
16
+ import type { PageSchema, PageRegion, SchemaNode } from '@object-ui/types';
17
+ import { SchemaRenderer, PageVariablesProvider } from '@object-ui/react';
12
18
  import { ComponentRegistry } from '@object-ui/core';
13
- import { cn } from '../../lib/utils'; // Keep internal import for utils
14
-
15
- export const PageRenderer: React.FC<{ schema: PageSchema; className?: string; [key: string]: any }> = ({
16
- schema,
17
- className,
18
- ...props
19
- }) => {
20
- // Support regions (spec compliant), body (legacy), and children
21
- let nodes: any[] = [];
22
-
19
+ import { cn } from '../../lib/utils';
20
+
21
+ // ---------------------------------------------------------------------------
22
+ // Helpers
23
+ // ---------------------------------------------------------------------------
24
+
25
+ /** Map region width enum values to Tailwind width classes */
26
+ function getRegionWidthClass(width?: string): string {
27
+ switch (width) {
28
+ case 'small':
29
+ return 'w-64';
30
+ case 'medium':
31
+ return 'w-80';
32
+ case 'large':
33
+ return 'w-96';
34
+ case 'full':
35
+ return 'w-full';
36
+ default:
37
+ return width ? width : 'w-full';
38
+ }
39
+ }
40
+
41
+ /** Max-width constraint by page type */
42
+ function getPageMaxWidth(pageType?: string): string {
43
+ switch (pageType) {
44
+ case 'utility':
45
+ return 'max-w-4xl';
46
+ case 'home':
47
+ return 'max-w-screen-2xl';
48
+ case 'app':
49
+ return 'max-w-screen-xl';
50
+ case 'record':
51
+ default:
52
+ return 'max-w-7xl';
53
+ }
54
+ }
55
+
56
+ /** Find a named region (case-insensitive) */
57
+ function findRegion(regions: PageRegion[] | undefined, name: string): PageRegion | undefined {
58
+ return regions?.find((r) => r.name?.toLowerCase() === name.toLowerCase());
59
+ }
60
+
61
+ /** Get all regions that are NOT in the named set */
62
+ function getRemainingRegions(regions: PageRegion[] | undefined, exclude: string[]): PageRegion[] {
63
+ if (!regions) return [];
64
+ const lowerSet = new Set(exclude.map((n) => n.toLowerCase()));
65
+ return regions.filter((r) => !lowerSet.has(r.name?.toLowerCase() ?? ''));
66
+ }
67
+
68
+ // ---------------------------------------------------------------------------
69
+ // RegionContent — renders all components inside a single region
70
+ // ---------------------------------------------------------------------------
71
+
72
+ const RegionContent: React.FC<{
73
+ region: PageRegion;
74
+ className?: string;
75
+ }> = ({ region, className }) => {
76
+ const components = region.components || [];
77
+ if (components.length === 0) return null;
78
+
79
+ return (
80
+ <div
81
+ className={cn('space-y-4', region.className, className)}
82
+ data-region={region.name}
83
+ >
84
+ {components.map((node: SchemaNode, idx: number) => (
85
+ <SchemaRenderer key={(node as any)?.id || `${region.name}-${idx}`} schema={node} />
86
+ ))}
87
+ </div>
88
+ );
89
+ };
90
+
91
+ // ---------------------------------------------------------------------------
92
+ // RegionLayout — structured layout with named slots
93
+ // ---------------------------------------------------------------------------
94
+
95
+ const RegionLayout: React.FC<{
96
+ regions: PageRegion[];
97
+ pageType?: string;
98
+ className?: string;
99
+ }> = ({ regions, pageType, className }) => {
100
+ const header = findRegion(regions, 'header');
101
+ const sidebar = findRegion(regions, 'sidebar');
102
+ const main = findRegion(regions, 'main');
103
+ const aside = findRegion(regions, 'aside');
104
+ const footer = findRegion(regions, 'footer');
105
+
106
+ // Remaining regions that don't match named slots → append below main
107
+ const extras = getRemainingRegions(regions, ['header', 'sidebar', 'main', 'aside', 'footer']);
108
+
109
+ // If there's no named layout structure, just stack everything
110
+ const hasStructure = header || sidebar || main || aside || footer;
111
+ if (!hasStructure) {
112
+ return (
113
+ <div className={cn('space-y-6', className)} data-page-layout={pageType}>
114
+ {regions.map((region, idx) => (
115
+ <RegionContent key={region.name || idx} region={region} />
116
+ ))}
117
+ </div>
118
+ );
119
+ }
120
+
121
+ return (
122
+ <div className={cn('flex flex-col gap-6', className)} data-page-layout={pageType}>
123
+ {/* Header region */}
124
+ {header && (
125
+ <RegionContent
126
+ region={header}
127
+ className={cn(getRegionWidthClass(header.width as string))}
128
+ />
129
+ )}
130
+
131
+ {/* Body: sidebar + main + aside */}
132
+ <div className="flex flex-1 gap-6">
133
+ {sidebar && (
134
+ <aside className={cn('shrink-0', getRegionWidthClass(sidebar.width as string || 'small'))}>
135
+ <RegionContent region={sidebar} />
136
+ </aside>
137
+ )}
138
+
139
+ <div className="flex-1 min-w-0 space-y-6">
140
+ {main && <RegionContent region={main} />}
141
+ {extras.map((region, idx) => (
142
+ <RegionContent key={region.name || `extra-${idx}`} region={region} />
143
+ ))}
144
+ </div>
145
+
146
+ {aside && (
147
+ <aside className={cn('shrink-0', getRegionWidthClass(aside.width as string || 'small'))}>
148
+ <RegionContent region={aside} />
149
+ </aside>
150
+ )}
151
+ </div>
152
+
153
+ {/* Footer region */}
154
+ {footer && (
155
+ <RegionContent
156
+ region={footer}
157
+ className={cn(getRegionWidthClass(footer.width as string))}
158
+ />
159
+ )}
160
+ </div>
161
+ );
162
+ };
163
+
164
+ // ---------------------------------------------------------------------------
165
+ // FlatContent — legacy body/children fallback
166
+ // ---------------------------------------------------------------------------
167
+
168
+ const FlatContent: React.FC<{ schema: PageSchema }> = ({ schema }) => {
169
+ const content = schema.body || schema.children;
170
+ const nodes: SchemaNode[] = Array.isArray(content)
171
+ ? content
172
+ : content
173
+ ? [content as SchemaNode]
174
+ : [];
175
+
176
+ if (nodes.length === 0) return null;
177
+
178
+ return (
179
+ <div className="space-y-6">
180
+ {nodes.map((node: any, index: number) => (
181
+ <SchemaRenderer key={node?.id || index} schema={node} />
182
+ ))}
183
+ </div>
184
+ );
185
+ };
186
+
187
+ // ---------------------------------------------------------------------------
188
+ // Template layouts — predefined layout templates
189
+ // ---------------------------------------------------------------------------
190
+
191
+ /** Template: full-width single column */
192
+ const FullWidthTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
193
+ if (schema.regions && schema.regions.length > 0) {
194
+ return <RegionLayout regions={schema.regions} pageType={schema.pageType} />;
195
+ }
196
+ return <FlatContent schema={schema} />;
197
+ };
198
+
199
+ /** Template: header-sidebar-main — header spanning full width, sidebar + main below */
200
+ const HeaderSidebarMainTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
201
+ const regions = schema.regions || [];
202
+ if (regions.length === 0) return <FlatContent schema={schema} />;
203
+
204
+ const header = findRegion(regions, 'header');
205
+ const sidebar = findRegion(regions, 'sidebar');
206
+ const main = findRegion(regions, 'main');
207
+ const extras = getRemainingRegions(regions, ['header', 'sidebar', 'main']);
208
+
209
+ return (
210
+ <div className="flex flex-col gap-6" data-template="header-sidebar-main">
211
+ {header && <RegionContent region={header} />}
212
+ <div className="flex flex-1 gap-6">
213
+ {sidebar && (
214
+ <aside className={cn('shrink-0', getRegionWidthClass(sidebar.width as string || 'medium'))}>
215
+ <RegionContent region={sidebar} />
216
+ </aside>
217
+ )}
218
+ <div className="flex-1 min-w-0 space-y-6">
219
+ {main && <RegionContent region={main} />}
220
+ {extras.map((region, idx) => (
221
+ <RegionContent key={region.name || `extra-${idx}`} region={region} />
222
+ ))}
223
+ </div>
224
+ </div>
225
+ </div>
226
+ );
227
+ };
228
+
229
+ /** Template: three-column — sidebar + main + aside */
230
+ const ThreeColumnTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
231
+ const regions = schema.regions || [];
232
+ if (regions.length === 0) return <FlatContent schema={schema} />;
233
+
234
+ const header = findRegion(regions, 'header');
235
+ const sidebar = findRegion(regions, 'sidebar');
236
+ const main = findRegion(regions, 'main');
237
+ const aside = findRegion(regions, 'aside');
238
+ const footer = findRegion(regions, 'footer');
239
+ const extras = getRemainingRegions(regions, ['header', 'sidebar', 'main', 'aside', 'footer']);
240
+
241
+ return (
242
+ <div className="flex flex-col gap-6" data-template="three-column">
243
+ {header && <RegionContent region={header} />}
244
+ <div className="flex flex-1 gap-6">
245
+ {sidebar && (
246
+ <aside className={cn('shrink-0', getRegionWidthClass(sidebar.width as string || 'small'))}>
247
+ <RegionContent region={sidebar} />
248
+ </aside>
249
+ )}
250
+ <div className="flex-1 min-w-0 space-y-6">
251
+ {main && <RegionContent region={main} />}
252
+ {extras.map((region, idx) => (
253
+ <RegionContent key={region.name || `extra-${idx}`} region={region} />
254
+ ))}
255
+ </div>
256
+ {aside && (
257
+ <aside className={cn('shrink-0', getRegionWidthClass(aside.width as string || 'small'))}>
258
+ <RegionContent region={aside} />
259
+ </aside>
260
+ )}
261
+ </div>
262
+ {footer && <RegionContent region={footer} />}
263
+ </div>
264
+ );
265
+ };
266
+
267
+ /** Template: dashboard — 2x2 grid of regions */
268
+ const DashboardTemplate: React.FC<{ schema: PageSchema }> = ({ schema }) => {
269
+ const regions = schema.regions || [];
270
+ if (regions.length === 0) return <FlatContent schema={schema} />;
271
+
272
+ const header = findRegion(regions, 'header');
273
+ const footer = findRegion(regions, 'footer');
274
+ const contentRegions = getRemainingRegions(regions, ['header', 'footer']);
275
+
276
+ return (
277
+ <div className="flex flex-col gap-6" data-template="dashboard">
278
+ {header && <RegionContent region={header} />}
279
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
280
+ {contentRegions.map((region, idx) => (
281
+ <RegionContent key={region.name || `region-${idx}`} region={region} />
282
+ ))}
283
+ </div>
284
+ {footer && <RegionContent region={footer} />}
285
+ </div>
286
+ );
287
+ };
288
+
289
+ /** Template registry — maps template names to layout components */
290
+ const TEMPLATE_REGISTRY: Record<string, React.FC<{ schema: PageSchema }>> = {
291
+ 'default': FullWidthTemplate,
292
+ 'full-width': FullWidthTemplate,
293
+ 'header-sidebar-main': HeaderSidebarMainTemplate,
294
+ 'three-column': ThreeColumnTemplate,
295
+ 'dashboard': DashboardTemplate,
296
+ };
297
+
298
+ /** Resolve template: if the schema specifies a template name, use the matching layout */
299
+ function resolveTemplate(schema: PageSchema): React.FC<{ schema: PageSchema }> | null {
300
+ if (!schema.template) return null;
301
+ return TEMPLATE_REGISTRY[schema.template] || null;
302
+ }
303
+
304
+ // ---------------------------------------------------------------------------
305
+ // Page type variant layouts
306
+ // ---------------------------------------------------------------------------
307
+
308
+ /** Record page — detail-oriented, narrower max-width */
309
+ const RecordPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
23
310
  if (schema.regions && schema.regions.length > 0) {
24
- // If regions are present, flatten their components into the main flow
25
- // Ideally, we might want a grid layout here, but linear stacking works for simple single-region pages
26
- nodes = schema.regions.flatMap(r => r.components || []);
27
- } else {
28
- // Fallback to direct children/body
29
- const content = schema.body || schema.children;
30
- nodes = Array.isArray(content) ? content : (content ? [content] : []);
311
+ return <RegionLayout regions={schema.regions} pageType="record" />;
31
312
  }
313
+ return <FlatContent schema={schema} />;
314
+ };
315
+
316
+ /** Home page — dashboard-style, wider layout */
317
+ const HomePageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
318
+ if (schema.regions && schema.regions.length > 0) {
319
+ return <RegionLayout regions={schema.regions} pageType="home" />;
320
+ }
321
+ return <FlatContent schema={schema} />;
322
+ };
323
+
324
+ /** App page — application shell, full-width capable */
325
+ const AppPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
326
+ if (schema.regions && schema.regions.length > 0) {
327
+ return <RegionLayout regions={schema.regions} pageType="app" />;
328
+ }
329
+ return <FlatContent schema={schema} />;
330
+ };
331
+
332
+ /** Utility page — compact, focused, narrower */
333
+ const UtilityPageLayout: React.FC<{ schema: PageSchema }> = ({ schema }) => {
334
+ if (schema.regions && schema.regions.length > 0) {
335
+ return <RegionLayout regions={schema.regions} pageType="utility" />;
336
+ }
337
+ return <FlatContent schema={schema} />;
338
+ };
339
+
340
+ // ---------------------------------------------------------------------------
341
+ // Main PageRenderer
342
+ // ---------------------------------------------------------------------------
343
+
344
+ export const PageRenderer: React.FC<{
345
+ schema: PageSchema;
346
+ className?: string;
347
+ [key: string]: any;
348
+ }> = ({ schema, className, ...props }) => {
349
+ const pageType = schema.pageType || 'record';
32
350
 
33
351
  // Extract designer-related props
34
- const {
35
- 'data-obj-id': dataObjId,
36
- 'data-obj-type': dataObjType,
37
- style,
38
- ...pageProps
352
+ const {
353
+ 'data-obj-id': dataObjId,
354
+ 'data-obj-type': dataObjType,
355
+ style,
356
+ ...pageProps
39
357
  } = props;
40
358
 
41
- return (
42
- <div
43
- className={cn("min-h-full w-full bg-background p-4 md:p-6 lg:p-8", className)}
44
- {...pageProps}
45
- // Apply designer props
359
+ // Select the layout variant based on template or page type
360
+ const layoutElement = useMemo(() => {
361
+ const TemplateLayout = resolveTemplate(schema);
362
+ if (TemplateLayout) {
363
+ // Template takes priority over page type
364
+ // eslint-disable-next-line react-hooks/static-components -- TemplateLayout is resolved from a stable template registry
365
+ return <TemplateLayout schema={schema} />;
366
+ }
367
+ switch (pageType) {
368
+ case 'home':
369
+ return <HomePageLayout schema={schema} />;
370
+ case 'app':
371
+ return <AppPageLayout schema={schema} />;
372
+ case 'utility':
373
+ return <UtilityPageLayout schema={schema} />;
374
+ case 'record':
375
+ default:
376
+ return <RecordPageLayout schema={schema} />;
377
+ }
378
+ }, [schema, pageType]);
379
+
380
+ const pageContent = (
381
+ <div
382
+ className={cn(
383
+ 'min-h-full w-full bg-background p-4 md:p-6 lg:p-8',
384
+ className,
385
+ )}
386
+ data-page-type={pageType}
46
387
  data-obj-id={dataObjId}
47
388
  data-obj-type={dataObjType}
48
389
  style={style}
390
+ {...pageProps}
49
391
  >
50
- <div className="mx-auto max-w-7xl space-y-8">
392
+ <div className={cn('mx-auto space-y-8', getPageMaxWidth(pageType))}>
393
+ {/* Page header */}
51
394
  {(schema.title || schema.description) && (
52
395
  <div className="space-y-2">
53
396
  {schema.title && (
@@ -56,27 +399,33 @@ export const PageRenderer: React.FC<{ schema: PageSchema; className?: string; [k
56
399
  </h1>
57
400
  )}
58
401
  {schema.description && (
59
- <p className="text-muted-foreground">
60
- {schema.description}
61
- </p>
402
+ <p className="text-muted-foreground">{schema.description}</p>
62
403
  )}
63
404
  </div>
64
405
  )}
65
-
66
- <div className="space-y-6">
67
- {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
68
- {nodes.map((node: any, index: number) => (
69
- <SchemaRenderer
70
- key={node?.id || index}
71
- schema={node}
72
- />
73
- ))}
74
- </div>
406
+
407
+ {/* Page body — type-specific layout */}
408
+ {layoutElement}
75
409
  </div>
76
410
  </div>
77
411
  );
412
+
413
+ // Wrap with PageVariablesProvider when variables are defined
414
+ if (schema.variables && schema.variables.length > 0) {
415
+ return (
416
+ <PageVariablesProvider definitions={schema.variables}>
417
+ {pageContent}
418
+ </PageVariablesProvider>
419
+ );
420
+ }
421
+
422
+ return pageContent;
78
423
  };
79
424
 
425
+ // ---------------------------------------------------------------------------
426
+ // ComponentRegistry registration
427
+ // ---------------------------------------------------------------------------
428
+
80
429
  const pageMeta: any = {
81
430
  namespace: 'ui',
82
431
  label: 'Page',
@@ -85,13 +434,28 @@ const pageMeta: any = {
85
434
  inputs: [
86
435
  { name: 'title', type: 'string', label: 'Title' },
87
436
  { name: 'description', type: 'string', label: 'Description' },
88
- {
89
- name: 'body',
90
- type: 'array',
91
- label: 'Content',
92
- itemType: 'component'
93
- }
94
- ]
437
+ { name: 'pageType', type: 'string', label: 'Page Type' },
438
+ { name: 'object', type: 'string', label: 'Object Name' },
439
+ { name: 'template', type: 'string', label: 'Template' },
440
+ {
441
+ name: 'regions',
442
+ type: 'array',
443
+ label: 'Regions',
444
+ itemType: 'object',
445
+ },
446
+ {
447
+ name: 'variables',
448
+ type: 'array',
449
+ label: 'Variables',
450
+ itemType: 'object',
451
+ },
452
+ {
453
+ name: 'body',
454
+ type: 'array',
455
+ label: 'Content (Legacy)',
456
+ itemType: 'component',
457
+ },
458
+ ],
95
459
  };
96
460
 
97
461
  ComponentRegistry.register('page', PageRenderer, pageMeta);
@@ -75,6 +75,7 @@ ComponentRegistry.register('sidebar-header',
75
75
  <SidebarHeader {...props}>{renderChildren(schema.body)}</SidebarHeader>
76
76
  ),
77
77
  {
78
+ namespace: 'ui',
78
79
  label: 'Sidebar Header',
79
80
  defaultChildren: [
80
81
  { type: 'text', content: 'Sidebar Header' }
@@ -87,6 +88,7 @@ ComponentRegistry.register('sidebar-content',
87
88
  <SidebarContent {...props}>{renderChildren(schema.body)}</SidebarContent>
88
89
  ),
89
90
  {
91
+ namespace: 'ui',
90
92
  label: 'Sidebar Content',
91
93
  defaultChildren: [
92
94
  { type: 'sidebar-group' }
@@ -123,6 +125,7 @@ ComponentRegistry.register('sidebar-menu',
123
125
  <SidebarMenu {...props}>{renderChildren(schema.body)}</SidebarMenu>
124
126
  ),
125
127
  {
128
+ namespace: 'ui',
126
129
  label: 'Sidebar Menu',
127
130
  defaultChildren: [
128
131
  { type: 'sidebar-menu-item' },
@@ -136,6 +139,7 @@ ComponentRegistry.register('sidebar-menu-item',
136
139
  <SidebarMenuItem {...props}>{renderChildren(schema.body)}</SidebarMenuItem>
137
140
  ),
138
141
  {
142
+ namespace: 'ui',
139
143
  label: 'Sidebar Menu Item',
140
144
  defaultChildren: [
141
145
  { type: 'sidebar-menu-button' }
@@ -171,6 +175,7 @@ ComponentRegistry.register('sidebar-footer',
171
175
  <SidebarFooter {...props}>{renderChildren(schema.body)}</SidebarFooter>
172
176
  ),
173
177
  {
178
+ namespace: 'ui',
174
179
  label: 'Sidebar Footer',
175
180
  defaultChildren: [
176
181
  { type: 'text', content: 'Footer' }
@@ -183,6 +188,7 @@ ComponentRegistry.register('sidebar-inset',
183
188
  <SidebarInset {...props}>{renderChildren(schema.body)}</SidebarInset>
184
189
  ),
185
190
  {
191
+ namespace: 'ui',
186
192
  label: 'Sidebar Inset',
187
193
  defaultChildren: [
188
194
  { type: 'div', className: 'p-4', body: [{ type: 'text', content: 'Main content area' }] }
@@ -90,8 +90,8 @@ const PROTOCOL_COMPONENTS = [
90
90
  'widget:metric', 'widget:bar', 'widget:line', 'widget:pie', 'widget:funnel',
91
91
  'widget:radar', 'widget:scatter', 'widget:heatmap', 'widget:pivot', 'widget:table', 'widget:text', 'widget:image',
92
92
 
93
- // 14. Smart Actions
94
- 'action:button', 'action:group', 'action:menu', 'action:icon',
93
+ // 14. Smart Actions (implemented in ./action/)
94
+ // 'action:button', 'action:group', 'action:menu', 'action:icon',
95
95
 
96
96
  // 15. AI
97
97
  'ai:chat_window', 'ai:input', 'ai:suggestion', 'ai:feedback'