@object-ui/components 3.3.0 → 3.3.1
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/CHANGELOG.md +20 -0
- package/README.md +21 -1
- package/dist/index.css +6339 -2
- package/dist/index.js +17600 -17481
- package/dist/index.umd.cjs +36 -36
- package/dist/packages/components/src/custom/empty.d.ts +12 -1
- package/dist/packages/components/src/renderers/action/action-bar.d.ts +12 -1
- package/dist/packages/components/src/ui/chart.d.ts +10 -29
- package/package.json +65 -44
- package/.turbo/turbo-build.log +0 -84
- package/README_SHADCN_SYNC.md +0 -281
- package/TESTING.md +0 -335
- package/docs/FilterBuilder.md +0 -268
- package/metadata/Chart.component.yml +0 -30
- package/metadata/FilterBuilder.component.yml +0 -39
- package/metadata/GridLayout.component.yml +0 -27
- package/metadata/Menu.component.yml +0 -31
- package/metadata/ObjectForm.component.yml +0 -34
- package/metadata/ObjectGrid.component.yml +0 -72
- package/metadata/Page.component.yml +0 -24
- package/postcss.config.js +0 -14
- package/shadcn-components.json +0 -440
- package/src/SchemaRenderer.tsx +0 -28
- package/src/__tests__/PageRendererRegions.test.tsx +0 -668
- package/src/__tests__/README.md +0 -124
- package/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap +0 -811
- package/src/__tests__/__snapshots__/snapshot.test.tsx.snap +0 -327
- package/src/__tests__/accessibility.test.tsx +0 -137
- package/src/__tests__/action-bar.test.tsx +0 -206
- package/src/__tests__/api-consistency.test.tsx +0 -596
- package/src/__tests__/basic-renderers.test.tsx +0 -255
- package/src/__tests__/color-contrast.test.tsx +0 -212
- package/src/__tests__/complex-disclosure-renderers.test.tsx +0 -302
- package/src/__tests__/compliance.test.tsx +0 -72
- package/src/__tests__/config-field-renderer.test.tsx +0 -307
- package/src/__tests__/config-panel-renderer.test.tsx +0 -580
- package/src/__tests__/config-primitives.test.tsx +0 -106
- package/src/__tests__/edge-cases.test.tsx +0 -285
- package/src/__tests__/feedback-overlay-renderers.test.tsx +0 -349
- package/src/__tests__/filter-builder.test.tsx +0 -409
- package/src/__tests__/form-renderers.test.tsx +0 -364
- package/src/__tests__/layout-data-renderers.test.tsx +0 -340
- package/src/__tests__/mobile-accessibility.test.tsx +0 -120
- package/src/__tests__/navigation-overlay.test.tsx +0 -370
- package/src/__tests__/snapshot-critical.test.tsx +0 -317
- package/src/__tests__/snapshot.test.tsx +0 -205
- package/src/__tests__/test-utils.tsx +0 -190
- package/src/__tests__/use-config-draft.test.tsx +0 -295
- package/src/__tests__/view-compliance.test.tsx +0 -153
- package/src/__tests__/wcag-audit.test.tsx +0 -493
- package/src/custom/action-param-dialog.tsx +0 -264
- package/src/custom/button-group.tsx +0 -91
- package/src/custom/combobox.tsx +0 -104
- package/src/custom/config-field-renderer.tsx +0 -276
- package/src/custom/config-panel-renderer.tsx +0 -306
- package/src/custom/config-row.tsx +0 -50
- package/src/custom/date-picker.tsx +0 -61
- package/src/custom/empty.tsx +0 -112
- package/src/custom/field.tsx +0 -81
- package/src/custom/filter-builder.tsx +0 -418
- package/src/custom/index.ts +0 -21
- package/src/custom/input-group.tsx +0 -53
- package/src/custom/item.tsx +0 -201
- package/src/custom/kbd.tsx +0 -36
- package/src/custom/mobile-dialog-content.tsx +0 -67
- package/src/custom/native-select.tsx +0 -33
- package/src/custom/navigation-overlay.tsx +0 -334
- package/src/custom/section-header.tsx +0 -68
- package/src/custom/sort-builder.tsx +0 -129
- package/src/custom/spinner.tsx +0 -26
- package/src/custom/view-skeleton.tsx +0 -243
- package/src/custom/view-states.tsx +0 -153
- package/src/debug/DebugPanel.tsx +0 -313
- package/src/debug/__tests__/DebugPanel.test.tsx +0 -134
- package/src/debug/index.ts +0 -10
- package/src/hooks/use-config-draft.ts +0 -127
- package/src/hooks/use-mobile.tsx +0 -27
- package/src/index.css +0 -245
- package/src/index.ts +0 -47
- package/src/lib/use-sync-external-store-shim.ts +0 -10
- package/src/lib/use-sync-external-store-with-selector-shim.ts +0 -90
- package/src/lib/utils.tsx +0 -35
- package/src/new-components.test.ts +0 -73
- package/src/renderers/action/action-bar.tsx +0 -221
- package/src/renderers/action/action-button.tsx +0 -158
- package/src/renderers/action/action-group.tsx +0 -270
- package/src/renderers/action/action-icon.tsx +0 -150
- package/src/renderers/action/action-menu.tsx +0 -203
- package/src/renderers/action/index.ts +0 -19
- package/src/renderers/action/resolve-icon.ts +0 -35
- package/src/renderers/basic/button-group.tsx +0 -79
- package/src/renderers/basic/div.tsx +0 -60
- package/src/renderers/basic/html.tsx +0 -43
- package/src/renderers/basic/icon.tsx +0 -89
- package/src/renderers/basic/image.tsx +0 -49
- package/src/renderers/basic/index.ts +0 -18
- package/src/renderers/basic/navigation-menu.tsx +0 -81
- package/src/renderers/basic/pagination.tsx +0 -109
- package/src/renderers/basic/separator.tsx +0 -57
- package/src/renderers/basic/span.tsx +0 -63
- package/src/renderers/basic/text.tsx +0 -52
- package/src/renderers/complex/README-KANBAN.md +0 -208
- package/src/renderers/complex/TIMELINE.md +0 -353
- package/src/renderers/complex/__tests__/data-table-airtable-ux.test.tsx +0 -239
- package/src/renderers/complex/__tests__/data-table-batch-editing.test.tsx +0 -275
- package/src/renderers/complex/__tests__/data-table-cell-renderer.test.tsx +0 -120
- package/src/renderers/complex/__tests__/data-table-editing.test.tsx +0 -221
- package/src/renderers/complex/__tests__/data-table.test.ts +0 -76
- package/src/renderers/complex/carousel.tsx +0 -69
- package/src/renderers/complex/data-table.tsx +0 -1243
- package/src/renderers/complex/filter-builder.tsx +0 -77
- package/src/renderers/complex/index.ts +0 -16
- package/src/renderers/complex/resizable.tsx +0 -66
- package/src/renderers/complex/scroll-area.tsx +0 -58
- package/src/renderers/complex/table.tsx +0 -95
- package/src/renderers/data-display/alert.tsx +0 -46
- package/src/renderers/data-display/avatar.tsx +0 -38
- package/src/renderers/data-display/badge.tsx +0 -55
- package/src/renderers/data-display/breadcrumb.tsx +0 -61
- package/src/renderers/data-display/index.ts +0 -18
- package/src/renderers/data-display/kbd.tsx +0 -50
- package/src/renderers/data-display/list.tsx +0 -75
- package/src/renderers/data-display/statistic.tsx +0 -95
- package/src/renderers/data-display/table.tsx +0 -78
- package/src/renderers/data-display/tree-view.tsx +0 -176
- package/src/renderers/disclosure/accordion.tsx +0 -69
- package/src/renderers/disclosure/collapsible.tsx +0 -53
- package/src/renderers/disclosure/index.ts +0 -11
- package/src/renderers/disclosure/toggle-group.tsx +0 -79
- package/src/renderers/feedback/empty.tsx +0 -49
- package/src/renderers/feedback/index.ts +0 -16
- package/src/renderers/feedback/loading.tsx +0 -78
- package/src/renderers/feedback/progress.tsx +0 -29
- package/src/renderers/feedback/skeleton.tsx +0 -31
- package/src/renderers/feedback/sonner.tsx +0 -56
- package/src/renderers/feedback/spinner.tsx +0 -55
- package/src/renderers/feedback/toast.tsx +0 -59
- package/src/renderers/feedback/toaster.tsx +0 -23
- package/src/renderers/form/button.tsx +0 -103
- package/src/renderers/form/calendar.tsx +0 -34
- package/src/renderers/form/checkbox.tsx +0 -71
- package/src/renderers/form/combobox.tsx +0 -48
- package/src/renderers/form/command.tsx +0 -58
- package/src/renderers/form/date-picker.tsx +0 -84
- package/src/renderers/form/file-upload.tsx +0 -184
- package/src/renderers/form/form.tsx +0 -540
- package/src/renderers/form/index.ts +0 -26
- package/src/renderers/form/input-otp.tsx +0 -51
- package/src/renderers/form/input.tsx +0 -121
- package/src/renderers/form/label.tsx +0 -45
- package/src/renderers/form/radio-group.tsx +0 -63
- package/src/renderers/form/select.tsx +0 -94
- package/src/renderers/form/slider.tsx +0 -61
- package/src/renderers/form/switch.tsx +0 -48
- package/src/renderers/form/textarea.tsx +0 -76
- package/src/renderers/form/toggle.tsx +0 -42
- package/src/renderers/index.ts +0 -18
- package/src/renderers/layout/aspect-ratio.tsx +0 -51
- package/src/renderers/layout/card.tsx +0 -85
- package/src/renderers/layout/container.tsx +0 -122
- package/src/renderers/layout/flex.tsx +0 -132
- package/src/renderers/layout/grid.tsx +0 -178
- package/src/renderers/layout/index.ts +0 -19
- package/src/renderers/layout/page.tsx +0 -466
- package/src/renderers/layout/semantic.tsx +0 -48
- package/src/renderers/layout/stack.tsx +0 -132
- package/src/renderers/layout/tabs.tsx +0 -97
- package/src/renderers/navigation/header-bar.tsx +0 -118
- package/src/renderers/navigation/index.ts +0 -10
- package/src/renderers/navigation/sidebar.tsx +0 -208
- package/src/renderers/overlay/alert-dialog.tsx +0 -72
- package/src/renderers/overlay/context-menu.tsx +0 -100
- package/src/renderers/overlay/dialog.tsx +0 -77
- package/src/renderers/overlay/drawer.tsx +0 -77
- package/src/renderers/overlay/dropdown-menu.tsx +0 -99
- package/src/renderers/overlay/hover-card.tsx +0 -55
- package/src/renderers/overlay/index.ts +0 -18
- package/src/renderers/overlay/menubar.tsx +0 -76
- package/src/renderers/overlay/popover.tsx +0 -56
- package/src/renderers/overlay/sheet.tsx +0 -77
- package/src/renderers/overlay/tooltip.tsx +0 -67
- package/src/renderers/placeholders.tsx +0 -107
- package/src/stories/CRMApp.stories.tsx +0 -706
- package/src/stories/ConfigPanel.stories.tsx +0 -232
- package/src/stories/Guide.mdx +0 -55
- package/src/stories/MockedData.stories.tsx +0 -121
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +0 -1
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +0 -1
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +0 -1
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +0 -1
- package/src/stories/assets/youtube.svg +0 -1
- package/src/stories/button.css +0 -30
- package/src/stories/header.css +0 -32
- package/src/stories/page.css +0 -68
- package/src/stories-json/Accessibility.mdx +0 -297
- package/src/stories-json/EdgeCases.stories.tsx +0 -160
- package/src/stories-json/GettingStarted.mdx +0 -89
- package/src/stories-json/Introduction.mdx +0 -127
- package/src/stories-json/accordion.stories.tsx +0 -43
- package/src/stories-json/aggrid.stories.tsx +0 -103
- package/src/stories-json/alert.stories.tsx +0 -39
- package/src/stories-json/aspect-ratio.stories.tsx +0 -34
- package/src/stories-json/avatar.stories.tsx +0 -38
- package/src/stories-json/badge.stories.tsx +0 -53
- package/src/stories-json/breadcrumb.stories.tsx +0 -30
- package/src/stories-json/button-group.stories.tsx +0 -43
- package/src/stories-json/button.stories.tsx +0 -73
- package/src/stories-json/calendar.stories.tsx +0 -85
- package/src/stories-json/card.stories.tsx +0 -48
- package/src/stories-json/carousel.stories.tsx +0 -33
- package/src/stories-json/charts.stories.tsx +0 -195
- package/src/stories-json/chatbot.stories.tsx +0 -349
- package/src/stories-json/code-editor.stories.tsx +0 -92
- package/src/stories-json/collapsible.stories.tsx +0 -40
- package/src/stories-json/controls.stories.tsx +0 -36
- package/src/stories-json/crm-live-data.stories.tsx +0 -154
- package/src/stories-json/dashboard.stories.tsx +0 -318
- package/src/stories-json/data-table.stories.tsx +0 -136
- package/src/stories-json/data_display_extras.stories.tsx +0 -102
- package/src/stories-json/date-picker.stories.tsx +0 -28
- package/src/stories-json/detail-view.stories.tsx +0 -258
- package/src/stories-json/dialog.stories.tsx +0 -43
- package/src/stories-json/feedback_extras.stories.tsx +0 -40
- package/src/stories-json/feedback_others.stories.tsx +0 -46
- package/src/stories-json/form-variants.stories.tsx +0 -210
- package/src/stories-json/form_advanced.stories.tsx +0 -117
- package/src/stories-json/form_extras.stories.tsx +0 -123
- package/src/stories-json/grid.stories.tsx +0 -56
- package/src/stories-json/icon.stories.tsx +0 -36
- package/src/stories-json/input.stories.tsx +0 -52
- package/src/stories-json/kanban.stories.tsx +0 -295
- package/src/stories-json/layout_extended.stories.tsx +0 -76
- package/src/stories-json/layout_flex.stories.tsx +0 -107
- package/src/stories-json/list-view.stories.tsx +0 -97
- package/src/stories-json/markdown.stories.tsx +0 -129
- package/src/stories-json/menus.stories.tsx +0 -63
- package/src/stories-json/metric-card.stories.tsx +0 -143
- package/src/stories-json/navigation-menu.stories.tsx +0 -37
- package/src/stories-json/object-aggrid-advanced.stories.tsx +0 -389
- package/src/stories-json/object-aggrid.stories.tsx +0 -252
- package/src/stories-json/object-form.stories.tsx +0 -130
- package/src/stories-json/object-gantt.stories.tsx +0 -114
- package/src/stories-json/object-grid.stories.tsx +0 -315
- package/src/stories-json/object-map.stories.tsx +0 -116
- package/src/stories-json/object-view.stories.tsx +0 -118
- package/src/stories-json/overlay_extras.stories.tsx +0 -113
- package/src/stories-json/overlay_others.stories.tsx +0 -76
- package/src/stories-json/page.stories.tsx +0 -55
- package/src/stories-json/reports.stories.tsx +0 -163
- package/src/stories-json/resizable.stories.tsx +0 -44
- package/src/stories-json/select.stories.tsx +0 -34
- package/src/stories-json/separator.stories.tsx +0 -41
- package/src/stories-json/sidebar.stories.tsx +0 -147
- package/src/stories-json/statistic.stories.tsx +0 -44
- package/src/stories-json/tabs.stories.tsx +0 -51
- package/src/stories-json/timeline.stories.tsx +0 -188
- package/src/stories-json/typography.stories.tsx +0 -45
- package/src/types/config-panel.ts +0 -101
- package/src/ui/accordion.tsx +0 -66
- package/src/ui/alert-dialog.tsx +0 -149
- package/src/ui/alert.tsx +0 -67
- package/src/ui/aspect-ratio.tsx +0 -15
- package/src/ui/avatar.tsx +0 -58
- package/src/ui/badge.tsx +0 -44
- package/src/ui/breadcrumb.tsx +0 -123
- package/src/ui/button.tsx +0 -64
- package/src/ui/calendar.tsx +0 -221
- package/src/ui/card.tsx +0 -87
- package/src/ui/carousel.tsx +0 -270
- package/src/ui/chart.tsx +0 -377
- package/src/ui/checkbox.tsx +0 -38
- package/src/ui/collapsible.tsx +0 -19
- package/src/ui/command.tsx +0 -161
- package/src/ui/context-menu.tsx +0 -208
- package/src/ui/dialog.tsx +0 -130
- package/src/ui/drawer.tsx +0 -126
- package/src/ui/dropdown-menu.tsx +0 -208
- package/src/ui/form.tsx +0 -186
- package/src/ui/hover-card.tsx +0 -37
- package/src/ui/index.ts +0 -56
- package/src/ui/input-otp.tsx +0 -79
- package/src/ui/input.tsx +0 -30
- package/src/ui/label.tsx +0 -34
- package/src/ui/menubar.tsx +0 -264
- package/src/ui/navigation-menu.tsx +0 -136
- package/src/ui/pagination.tsx +0 -125
- package/src/ui/popover.tsx +0 -39
- package/src/ui/progress.tsx +0 -36
- package/src/ui/radio-group.tsx +0 -52
- package/src/ui/resizable.tsx +0 -53
- package/src/ui/scroll-area.tsx +0 -56
- package/src/ui/select.tsx +0 -168
- package/src/ui/separator.tsx +0 -39
- package/src/ui/sheet.tsx +0 -150
- package/src/ui/sidebar.tsx +0 -781
- package/src/ui/skeleton.tsx +0 -23
- package/src/ui/slider.tsx +0 -39
- package/src/ui/sonner.tsx +0 -53
- package/src/ui/switch.tsx +0 -37
- package/src/ui/table.tsx +0 -125
- package/src/ui/tabs.tsx +0 -63
- package/src/ui/textarea.tsx +0 -30
- package/src/ui/toast.tsx +0 -137
- package/src/ui/toggle-group.tsx +0 -69
- package/src/ui/toggle.tsx +0 -53
- package/src/ui/tooltip.tsx +0 -38
- package/src/ui/typography.tsx +0 -85
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -71
- package/vitest.config.ts +0 -5
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ObjectUI — Page Renderer
|
|
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
|
-
* 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.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import React, { useMemo } from 'react';
|
|
16
|
-
import type { PageSchema, PageRegion, SchemaNode } from '@object-ui/types';
|
|
17
|
-
import { SchemaRenderer, PageVariablesProvider } from '@object-ui/react';
|
|
18
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
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 }) => {
|
|
310
|
-
if (schema.regions && schema.regions.length > 0) {
|
|
311
|
-
return <RegionLayout regions={schema.regions} pageType="record" />;
|
|
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';
|
|
350
|
-
|
|
351
|
-
// Extract designer-related props
|
|
352
|
-
const {
|
|
353
|
-
'data-obj-id': dataObjId,
|
|
354
|
-
'data-obj-type': dataObjType,
|
|
355
|
-
style,
|
|
356
|
-
...pageProps
|
|
357
|
-
} = props;
|
|
358
|
-
|
|
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}
|
|
387
|
-
data-obj-id={dataObjId}
|
|
388
|
-
data-obj-type={dataObjType}
|
|
389
|
-
style={style}
|
|
390
|
-
{...pageProps}
|
|
391
|
-
>
|
|
392
|
-
<div className={cn('mx-auto space-y-8', getPageMaxWidth(pageType))}>
|
|
393
|
-
{/* Page header */}
|
|
394
|
-
{(schema.title || schema.description) && (
|
|
395
|
-
<div className="space-y-2">
|
|
396
|
-
{schema.title && (
|
|
397
|
-
<h1 className="text-3xl font-bold tracking-tight text-foreground">
|
|
398
|
-
{schema.title}
|
|
399
|
-
</h1>
|
|
400
|
-
)}
|
|
401
|
-
{schema.description && (
|
|
402
|
-
<p className="text-muted-foreground">{schema.description}</p>
|
|
403
|
-
)}
|
|
404
|
-
</div>
|
|
405
|
-
)}
|
|
406
|
-
|
|
407
|
-
{/* Page body — type-specific layout */}
|
|
408
|
-
{layoutElement}
|
|
409
|
-
</div>
|
|
410
|
-
</div>
|
|
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;
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
// ---------------------------------------------------------------------------
|
|
426
|
-
// ComponentRegistry registration
|
|
427
|
-
// ---------------------------------------------------------------------------
|
|
428
|
-
|
|
429
|
-
const pageMeta: any = {
|
|
430
|
-
namespace: 'ui',
|
|
431
|
-
label: 'Page',
|
|
432
|
-
icon: 'Layout',
|
|
433
|
-
category: 'layout',
|
|
434
|
-
inputs: [
|
|
435
|
-
{ name: 'title', type: 'string', label: 'Title' },
|
|
436
|
-
{ name: 'description', type: 'string', label: 'Description' },
|
|
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
|
-
],
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
ComponentRegistry.register('page', PageRenderer, pageMeta);
|
|
462
|
-
ComponentRegistry.register('app', PageRenderer, { ...pageMeta, label: 'App Page' });
|
|
463
|
-
ComponentRegistry.register('utility', PageRenderer, { ...pageMeta, label: 'Utility Page' });
|
|
464
|
-
ComponentRegistry.register('home', PageRenderer, { ...pageMeta, label: 'Home Page' });
|
|
465
|
-
ComponentRegistry.register('record', PageRenderer, { ...pageMeta, label: 'Record Page' });
|
|
466
|
-
|
|
@@ -1,48 +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
|
-
|
|
9
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
-
import { renderChildren } from '../../lib/utils';
|
|
11
|
-
import { forwardRef } from 'react';
|
|
12
|
-
|
|
13
|
-
const tags = ['aside', 'main', 'header', 'nav', 'footer', 'section', 'article'] as const;
|
|
14
|
-
|
|
15
|
-
tags.forEach(tag => {
|
|
16
|
-
const Component = forwardRef<HTMLElement, any>(({ schema, className, ...props }, ref) => {
|
|
17
|
-
// Extract designer-related props
|
|
18
|
-
const {
|
|
19
|
-
'data-obj-id': dataObjId,
|
|
20
|
-
'data-obj-type': dataObjType,
|
|
21
|
-
style,
|
|
22
|
-
...restProps
|
|
23
|
-
} = props;
|
|
24
|
-
|
|
25
|
-
const Tag = tag;
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Tag
|
|
29
|
-
ref={ref}
|
|
30
|
-
className={className}
|
|
31
|
-
{...restProps}
|
|
32
|
-
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
|
|
33
|
-
>
|
|
34
|
-
{renderChildren(schema.children || schema.body)}
|
|
35
|
-
</Tag>
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
Component.displayName = `Semantic${tag.charAt(0).toUpperCase() + tag.slice(1)}`;
|
|
39
|
-
|
|
40
|
-
ComponentRegistry.register(tag, Component, {
|
|
41
|
-
namespace: 'ui',
|
|
42
|
-
label: tag.charAt(0).toUpperCase() + tag.slice(1),
|
|
43
|
-
category: 'layout',
|
|
44
|
-
inputs: [
|
|
45
|
-
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,132 +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
|
-
|
|
9
|
-
import { ComponentRegistry } from '@object-ui/core';
|
|
10
|
-
import type { StackSchema } from '@object-ui/types';
|
|
11
|
-
import { renderChildren } from '../../lib/utils';
|
|
12
|
-
import { cn } from '../../lib/utils';
|
|
13
|
-
import { forwardRef } from 'react';
|
|
14
|
-
|
|
15
|
-
// Stack is essentially a Flex container that defaults to column direction
|
|
16
|
-
const StackRenderer = forwardRef<HTMLDivElement, { schema: StackSchema; className?: string; [key: string]: any }>(
|
|
17
|
-
({ schema, className, ...props }, ref) => {
|
|
18
|
-
// Default to column for Stack
|
|
19
|
-
const direction = schema.direction || 'col';
|
|
20
|
-
const justify = schema.justify || 'start';
|
|
21
|
-
const align = schema.align || 'stretch'; // Stack items usually stretch
|
|
22
|
-
const gap = schema.gap ?? (schema as any).spacing ?? 2;
|
|
23
|
-
const wrap = schema.wrap || false;
|
|
24
|
-
|
|
25
|
-
const stackClass = cn(
|
|
26
|
-
'flex',
|
|
27
|
-
// Direction
|
|
28
|
-
direction === 'row' && 'flex-row',
|
|
29
|
-
direction === 'col' && 'flex-col',
|
|
30
|
-
direction === 'row-reverse' && 'flex-row-reverse',
|
|
31
|
-
direction === 'col-reverse' && 'flex-col-reverse',
|
|
32
|
-
// Justify content
|
|
33
|
-
justify === 'start' && 'justify-start',
|
|
34
|
-
justify === 'end' && 'justify-end',
|
|
35
|
-
justify === 'center' && 'justify-center',
|
|
36
|
-
justify === 'between' && 'justify-between',
|
|
37
|
-
justify === 'around' && 'justify-around',
|
|
38
|
-
justify === 'evenly' && 'justify-evenly',
|
|
39
|
-
// Align items
|
|
40
|
-
align === 'start' && 'items-start',
|
|
41
|
-
align === 'end' && 'items-end',
|
|
42
|
-
align === 'center' && 'items-center',
|
|
43
|
-
align === 'baseline' && 'items-baseline',
|
|
44
|
-
align === 'stretch' && 'items-stretch',
|
|
45
|
-
// Gap - Mobile-first responsive
|
|
46
|
-
gap === 0 && 'gap-0',
|
|
47
|
-
gap === 1 && 'gap-1',
|
|
48
|
-
gap === 2 && 'gap-1.5 sm:gap-2',
|
|
49
|
-
gap === 3 && 'gap-2 sm:gap-3',
|
|
50
|
-
gap === 4 && 'gap-2 sm:gap-3 md:gap-4',
|
|
51
|
-
gap === 5 && 'gap-3 sm:gap-4 md:gap-5',
|
|
52
|
-
gap === 6 && 'gap-3 sm:gap-4 md:gap-6',
|
|
53
|
-
gap === 8 && 'gap-4 sm:gap-6 md:gap-8',
|
|
54
|
-
gap === 10 && 'gap-5 sm:gap-7 md:gap-10',
|
|
55
|
-
// Wrap
|
|
56
|
-
wrap && 'flex-wrap',
|
|
57
|
-
className
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Extract designer-related props
|
|
61
|
-
const {
|
|
62
|
-
'data-obj-id': dataObjId,
|
|
63
|
-
'data-obj-type': dataObjType,
|
|
64
|
-
style,
|
|
65
|
-
...stackProps
|
|
66
|
-
} = props;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div
|
|
70
|
-
ref={ref}
|
|
71
|
-
className={stackClass}
|
|
72
|
-
{...stackProps}
|
|
73
|
-
// Apply designer props
|
|
74
|
-
{...{ 'data-obj-id': dataObjId, 'data-obj-type': dataObjType, style }}
|
|
75
|
-
>
|
|
76
|
-
{schema.children && renderChildren(schema.children)}
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
ComponentRegistry.register('stack',
|
|
83
|
-
StackRenderer,
|
|
84
|
-
{
|
|
85
|
-
namespace: 'ui',
|
|
86
|
-
label: 'Stack',
|
|
87
|
-
inputs: [
|
|
88
|
-
{
|
|
89
|
-
name: 'direction',
|
|
90
|
-
type: 'enum',
|
|
91
|
-
label: 'Direction',
|
|
92
|
-
enum: ['col', 'row', 'col-reverse', 'row-reverse'],
|
|
93
|
-
defaultValue: 'col'
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'gap',
|
|
97
|
-
type: 'number',
|
|
98
|
-
label: 'Gap',
|
|
99
|
-
defaultValue: 2
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
name: 'align',
|
|
103
|
-
type: 'enum',
|
|
104
|
-
label: 'Align Items',
|
|
105
|
-
enum: ['start', 'end', 'center', 'stretch', 'baseline'],
|
|
106
|
-
defaultValue: 'stretch'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'justify',
|
|
110
|
-
type: 'enum',
|
|
111
|
-
label: 'Justify Content',
|
|
112
|
-
enum: ['start', 'end', 'center', 'between', 'around', 'evenly'],
|
|
113
|
-
defaultValue: 'start'
|
|
114
|
-
},
|
|
115
|
-
{ name: 'className', type: 'string', label: 'CSS Class' }
|
|
116
|
-
],
|
|
117
|
-
defaultProps: {
|
|
118
|
-
direction: 'col',
|
|
119
|
-
gap: 2,
|
|
120
|
-
align: 'stretch',
|
|
121
|
-
children: []
|
|
122
|
-
},
|
|
123
|
-
isContainer: true,
|
|
124
|
-
resizable: true,
|
|
125
|
-
resizeConstraints: {
|
|
126
|
-
width: true,
|
|
127
|
-
height: true,
|
|
128
|
-
minWidth: 100,
|
|
129
|
-
minHeight: 50
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
);
|