@object-ui/react 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/SchemaRenderer.js +61 -2
- package/dist/context/SchemaRendererContext.d.ts +4 -1
- package/dist/context/SchemaRendererContext.js +6 -4
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/useActionEngine.d.ts +27 -0
- package/dist/hooks/useActionEngine.js +39 -0
- package/dist/hooks/useDebugMode.d.ts +43 -0
- package/dist/hooks/useDebugMode.js +71 -0
- package/dist/hooks/useGlobalUndo.d.ts +35 -0
- package/dist/hooks/useGlobalUndo.js +86 -0
- package/dist/hooks/useNavigationOverlay.d.ts +2 -0
- package/dist/hooks/useNavigationOverlay.js +12 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/spec-bridge/SpecBridge.d.ts +26 -0
- package/dist/spec-bridge/SpecBridge.js +62 -0
- package/dist/spec-bridge/bridges/dashboard.d.ts +81 -0
- package/dist/spec-bridge/bridges/dashboard.js +121 -0
- package/dist/spec-bridge/bridges/form-view.d.ts +44 -0
- package/dist/spec-bridge/bridges/form-view.js +77 -0
- package/dist/spec-bridge/bridges/list-view.d.ts +82 -0
- package/dist/spec-bridge/bridges/list-view.js +154 -0
- package/dist/spec-bridge/bridges/page.d.ts +68 -0
- package/dist/spec-bridge/bridges/page.js +81 -0
- package/dist/spec-bridge/index.d.ts +13 -0
- package/dist/spec-bridge/index.js +12 -0
- package/dist/spec-bridge/types.d.ts +34 -0
- package/dist/spec-bridge/types.js +8 -0
- package/package.json +7 -7
- package/src/SchemaRenderer.tsx +66 -0
- package/src/__tests__/LazyPluginLoader.test.tsx +1 -1
- package/src/__tests__/SchemaRenderer.debug.test.tsx +69 -0
- package/src/__tests__/SchemaRenderer.expressions.test.tsx +131 -0
- package/src/__tests__/useNavigationOverlay.test.ts +162 -0
- package/src/context/SchemaRendererContext.tsx +9 -4
- package/src/context/__tests__/useDataScope.test.tsx +91 -0
- package/src/hooks/__tests__/useActionEngine.test.ts +170 -0
- package/src/hooks/__tests__/useCrudShortcuts.test.ts +85 -0
- package/src/hooks/__tests__/useDebugMode.test.ts +83 -0
- package/src/hooks/__tests__/useFocusTrap.test.ts +247 -0
- package/src/hooks/__tests__/usePageTransition.test.ts +158 -0
- package/src/hooks/__tests__/useReducedMotion.test.ts +104 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useActionEngine.ts +84 -0
- package/src/hooks/useDebugMode.ts +95 -0
- package/src/hooks/useGlobalUndo.ts +98 -0
- package/src/hooks/useNavigationOverlay.ts +14 -5
- package/src/index.ts +6 -0
- package/src/spec-bridge/SpecBridge.ts +64 -0
- package/src/spec-bridge/__tests__/P1SpecBridge.test.ts +855 -0
- package/src/spec-bridge/__tests__/SpecBridge.test.ts +550 -0
- package/src/spec-bridge/bridges/dashboard.ts +180 -0
- package/src/spec-bridge/bridges/form-view.ts +109 -0
- package/src/spec-bridge/bridges/list-view.ts +187 -0
- package/src/spec-bridge/bridges/page.ts +136 -0
- package/src/spec-bridge/index.ts +14 -0
- package/src/spec-bridge/types.ts +38 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
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 type { SchemaNode } from '@object-ui/core';
|
|
10
|
+
import type { BridgeContext, BridgeFn } from '../types';
|
|
11
|
+
|
|
12
|
+
interface DashboardWidget {
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
chartConfig?: any;
|
|
17
|
+
colorVariant?: string;
|
|
18
|
+
actionUrl?: string;
|
|
19
|
+
actionType?: string;
|
|
20
|
+
actionIcon?: string;
|
|
21
|
+
object?: string;
|
|
22
|
+
filter?: any;
|
|
23
|
+
categoryField?: string;
|
|
24
|
+
valueField?: string;
|
|
25
|
+
aggregate?: string;
|
|
26
|
+
measures?: any[];
|
|
27
|
+
layout?: any;
|
|
28
|
+
options?: any;
|
|
29
|
+
responsive?: any;
|
|
30
|
+
aria?: { ariaLabel?: string; ariaDescribedBy?: string; role?: string };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface DashboardHeader {
|
|
34
|
+
showTitle?: boolean;
|
|
35
|
+
showDescription?: boolean;
|
|
36
|
+
actions?: Array<{
|
|
37
|
+
label: string;
|
|
38
|
+
actionUrl?: string;
|
|
39
|
+
actionType?: string;
|
|
40
|
+
icon?: string;
|
|
41
|
+
}>;
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface GlobalFilter {
|
|
46
|
+
field: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
options?: string[];
|
|
50
|
+
optionsFrom?: {
|
|
51
|
+
object: string;
|
|
52
|
+
valueField: string;
|
|
53
|
+
labelField?: string;
|
|
54
|
+
filter?: any;
|
|
55
|
+
};
|
|
56
|
+
defaultValue?: any;
|
|
57
|
+
scope?: string;
|
|
58
|
+
targetWidgets?: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface DashboardSpec {
|
|
62
|
+
name?: string;
|
|
63
|
+
label?: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
widgets?: DashboardWidget[];
|
|
66
|
+
globalFilters?: GlobalFilter[];
|
|
67
|
+
header?: DashboardHeader;
|
|
68
|
+
// P1.3 additions
|
|
69
|
+
refreshInterval?: number;
|
|
70
|
+
dateRange?: {
|
|
71
|
+
field?: string;
|
|
72
|
+
defaultRange?: string;
|
|
73
|
+
allowCustomRange?: boolean;
|
|
74
|
+
};
|
|
75
|
+
aria?: { ariaLabel?: string; ariaDescribedBy?: string; role?: string };
|
|
76
|
+
performance?: any;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function mapWidget(widget: DashboardWidget, index: number): SchemaNode {
|
|
80
|
+
const node: SchemaNode = {
|
|
81
|
+
type: widget.type ?? 'chart',
|
|
82
|
+
id: `widget-${index}`,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (widget.title) node.title = widget.title;
|
|
86
|
+
if (widget.description) node.description = widget.description;
|
|
87
|
+
if (widget.chartConfig) node.chartConfig = widget.chartConfig;
|
|
88
|
+
if (widget.colorVariant) node.colorVariant = widget.colorVariant;
|
|
89
|
+
if (widget.actionUrl) node.actionUrl = widget.actionUrl;
|
|
90
|
+
if (widget.actionType) node.actionType = widget.actionType;
|
|
91
|
+
if (widget.actionIcon) node.actionIcon = widget.actionIcon;
|
|
92
|
+
if (widget.object) node.object = widget.object;
|
|
93
|
+
if (widget.filter) node.filter = widget.filter;
|
|
94
|
+
if (widget.categoryField) node.categoryField = widget.categoryField;
|
|
95
|
+
if (widget.valueField) node.valueField = widget.valueField;
|
|
96
|
+
if (widget.aggregate) node.aggregate = widget.aggregate;
|
|
97
|
+
if (widget.measures) node.measures = widget.measures;
|
|
98
|
+
if (widget.layout) node.layout = widget.layout;
|
|
99
|
+
if (widget.options) node.options = widget.options;
|
|
100
|
+
if (widget.responsive) node.responsive = widget.responsive;
|
|
101
|
+
if (widget.aria) node.aria = widget.aria;
|
|
102
|
+
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function mapGlobalFilters(filters: GlobalFilter[]): SchemaNode {
|
|
107
|
+
return {
|
|
108
|
+
type: 'filter-bar',
|
|
109
|
+
id: 'dashboard-filters',
|
|
110
|
+
filters: filters.map((f) => {
|
|
111
|
+
const mapped: Record<string, any> = { field: f.field };
|
|
112
|
+
if (f.label) mapped.label = f.label;
|
|
113
|
+
if (f.type) mapped.type = f.type;
|
|
114
|
+
if (f.options) mapped.options = f.options;
|
|
115
|
+
if (f.optionsFrom) mapped.optionsFrom = f.optionsFrom;
|
|
116
|
+
if (f.defaultValue != null) mapped.defaultValue = f.defaultValue;
|
|
117
|
+
if (f.scope) mapped.scope = f.scope;
|
|
118
|
+
if (f.targetWidgets) mapped.targetWidgets = f.targetWidgets;
|
|
119
|
+
return mapped;
|
|
120
|
+
}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function mapHeader(header: DashboardHeader): SchemaNode {
|
|
125
|
+
const node: SchemaNode = {
|
|
126
|
+
type: 'dashboard-header',
|
|
127
|
+
id: 'dashboard-header',
|
|
128
|
+
...header,
|
|
129
|
+
};
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Transforms a Dashboard spec into a dashboard layout SchemaNode */
|
|
134
|
+
export const bridgeDashboard: BridgeFn<DashboardSpec> = (
|
|
135
|
+
spec: DashboardSpec,
|
|
136
|
+
_context: BridgeContext,
|
|
137
|
+
): SchemaNode => {
|
|
138
|
+
const widgetNodes = (spec.widgets ?? []).map(mapWidget);
|
|
139
|
+
|
|
140
|
+
const bodyChildren: SchemaNode[] = [];
|
|
141
|
+
|
|
142
|
+
if (spec.header) {
|
|
143
|
+
bodyChildren.push(mapHeader(spec.header));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (spec.globalFilters && spec.globalFilters.length > 0) {
|
|
147
|
+
bodyChildren.push(mapGlobalFilters(spec.globalFilters));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// P1.3 — Date range filter
|
|
151
|
+
if (spec.dateRange) {
|
|
152
|
+
bodyChildren.push({
|
|
153
|
+
type: 'date-range-filter',
|
|
154
|
+
id: 'dashboard-date-range',
|
|
155
|
+
...spec.dateRange,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
bodyChildren.push({
|
|
160
|
+
type: 'widget-grid',
|
|
161
|
+
id: 'dashboard-widgets',
|
|
162
|
+
body: widgetNodes,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const node: SchemaNode = {
|
|
166
|
+
type: 'dashboard',
|
|
167
|
+
id: spec.name,
|
|
168
|
+
body: bodyChildren,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (spec.label) node.label = spec.label;
|
|
172
|
+
if (spec.description) node.description = spec.description;
|
|
173
|
+
if (spec.refreshInterval != null) node.refreshInterval = spec.refreshInterval;
|
|
174
|
+
|
|
175
|
+
// P1.6 — i18n & ARIA
|
|
176
|
+
if (spec.aria) node.aria = spec.aria;
|
|
177
|
+
if (spec.performance) node.performance = spec.performance;
|
|
178
|
+
|
|
179
|
+
return node;
|
|
180
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
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 type { SchemaNode } from '@object-ui/core';
|
|
10
|
+
import type { BridgeContext, BridgeFn } from '../types';
|
|
11
|
+
|
|
12
|
+
interface FormField {
|
|
13
|
+
field: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
helpText?: string;
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
colSpan?: number;
|
|
21
|
+
widget?: string;
|
|
22
|
+
dependsOn?: string[];
|
|
23
|
+
visibleOn?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface FormSection {
|
|
27
|
+
label?: string;
|
|
28
|
+
collapsible?: boolean;
|
|
29
|
+
collapsed?: boolean;
|
|
30
|
+
columns?: number;
|
|
31
|
+
fields?: FormField[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface FormViewSpec {
|
|
35
|
+
type?: string;
|
|
36
|
+
data?: any;
|
|
37
|
+
sections?: FormSection[];
|
|
38
|
+
groups?: any;
|
|
39
|
+
// P1.2 additions
|
|
40
|
+
defaultSort?: any;
|
|
41
|
+
sharing?: any;
|
|
42
|
+
aria?: { ariaLabel?: string; ariaDescribedBy?: string; role?: string };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function mapField(field: FormField): Record<string, any> {
|
|
46
|
+
const mapped: Record<string, any> = {
|
|
47
|
+
name: field.field,
|
|
48
|
+
label: field.label ?? field.field,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (field.placeholder) mapped.placeholder = field.placeholder;
|
|
52
|
+
if (field.helpText) mapped.helpText = field.helpText;
|
|
53
|
+
if (field.readonly != null) mapped.readonly = field.readonly;
|
|
54
|
+
if (field.required != null) mapped.required = field.required;
|
|
55
|
+
if (field.hidden != null) mapped.hidden = field.hidden;
|
|
56
|
+
if (field.colSpan != null) mapped.colSpan = field.colSpan;
|
|
57
|
+
if (field.widget) mapped.widget = field.widget;
|
|
58
|
+
if (field.dependsOn) mapped.dependsOn = field.dependsOn;
|
|
59
|
+
if (field.visibleOn) mapped.visibleOn = field.visibleOn;
|
|
60
|
+
|
|
61
|
+
return mapped;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function mapSection(section: FormSection): Record<string, any> {
|
|
65
|
+
const mapped: Record<string, any> = {
|
|
66
|
+
fields: (section.fields ?? []).map(mapField),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (section.label) mapped.label = section.label;
|
|
70
|
+
if (section.collapsible != null) mapped.collapsible = section.collapsible;
|
|
71
|
+
if (section.collapsed != null) mapped.collapsed = section.collapsed;
|
|
72
|
+
if (section.columns != null) mapped.columns = section.columns;
|
|
73
|
+
|
|
74
|
+
return mapped;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Maps spec formType to ObjectUI formType */
|
|
78
|
+
function mapFormType(type?: string): string | undefined {
|
|
79
|
+
if (!type) return undefined;
|
|
80
|
+
const validTypes = ['simple', 'tabbed', 'wizard', 'split', 'drawer', 'modal'];
|
|
81
|
+
return validTypes.includes(type) ? type : undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Transforms a FormView spec into a Form SchemaNode */
|
|
85
|
+
export const bridgeFormView: BridgeFn<FormViewSpec> = (
|
|
86
|
+
spec: FormViewSpec,
|
|
87
|
+
_context: BridgeContext,
|
|
88
|
+
): SchemaNode => {
|
|
89
|
+
const sections = (spec.sections ?? []).map(mapSection);
|
|
90
|
+
const formType = mapFormType(spec.type);
|
|
91
|
+
|
|
92
|
+
const node: SchemaNode = {
|
|
93
|
+
type: 'object-form',
|
|
94
|
+
id: `form-${spec.type ?? 'default'}`,
|
|
95
|
+
sections,
|
|
96
|
+
data: spec.data,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// P1.2 — formType mapping (tabbed, wizard, split, drawer, modal)
|
|
100
|
+
if (formType) node.formType = formType;
|
|
101
|
+
if (spec.groups) node.groups = spec.groups;
|
|
102
|
+
if (spec.defaultSort) node.defaultSort = spec.defaultSort;
|
|
103
|
+
|
|
104
|
+
// P1.6 — i18n & ARIA
|
|
105
|
+
if (spec.sharing) node.sharing = spec.sharing;
|
|
106
|
+
if (spec.aria) node.aria = spec.aria;
|
|
107
|
+
|
|
108
|
+
return node;
|
|
109
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
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 type { SchemaNode } from '@object-ui/core';
|
|
10
|
+
import { normalizeQuickFilters } from '@object-ui/core';
|
|
11
|
+
import type { BridgeContext, BridgeFn } from '../types';
|
|
12
|
+
import type { ListViewGalleryConfig, ListViewTimelineConfig } from '@object-ui/types';
|
|
13
|
+
|
|
14
|
+
interface ListColumn {
|
|
15
|
+
field: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
align?: string;
|
|
19
|
+
hidden?: boolean;
|
|
20
|
+
sortable?: boolean;
|
|
21
|
+
resizable?: boolean;
|
|
22
|
+
wrap?: boolean;
|
|
23
|
+
type?: string;
|
|
24
|
+
pinned?: string;
|
|
25
|
+
summary?: any;
|
|
26
|
+
link?: any;
|
|
27
|
+
action?: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface ListViewSpec {
|
|
31
|
+
name?: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
type?: string;
|
|
34
|
+
data?: any;
|
|
35
|
+
columns?: ListColumn[];
|
|
36
|
+
filter?: any;
|
|
37
|
+
sort?: any;
|
|
38
|
+
searchableFields?: string[];
|
|
39
|
+
filterableFields?: string[];
|
|
40
|
+
quickFilters?: any[];
|
|
41
|
+
selection?: any;
|
|
42
|
+
pagination?: any;
|
|
43
|
+
rowHeight?: string;
|
|
44
|
+
resizable?: boolean;
|
|
45
|
+
striped?: boolean;
|
|
46
|
+
bordered?: boolean;
|
|
47
|
+
grouping?: any;
|
|
48
|
+
rowColor?: any;
|
|
49
|
+
navigation?: any;
|
|
50
|
+
kanban?: any;
|
|
51
|
+
calendar?: any;
|
|
52
|
+
gantt?: any;
|
|
53
|
+
gallery?: ListViewGalleryConfig;
|
|
54
|
+
timeline?: ListViewTimelineConfig;
|
|
55
|
+
// P1.1 additions
|
|
56
|
+
rowActions?: string[];
|
|
57
|
+
bulkActions?: string[];
|
|
58
|
+
virtualScroll?: boolean;
|
|
59
|
+
conditionalFormatting?: Array<{ condition: string; style: Record<string, string> }>;
|
|
60
|
+
inlineEdit?: boolean;
|
|
61
|
+
exportOptions?: any;
|
|
62
|
+
emptyState?: { title?: string; message?: string; icon?: string };
|
|
63
|
+
userActions?: any;
|
|
64
|
+
appearance?: any;
|
|
65
|
+
tabs?: any[];
|
|
66
|
+
addRecord?: any;
|
|
67
|
+
showRecordCount?: boolean;
|
|
68
|
+
allowPrinting?: boolean;
|
|
69
|
+
// P1.6 i18n & ARIA
|
|
70
|
+
aria?: { ariaLabel?: string; ariaDescribedBy?: string; role?: string };
|
|
71
|
+
sharing?: any;
|
|
72
|
+
hiddenFields?: string[];
|
|
73
|
+
fieldOrder?: string[];
|
|
74
|
+
description?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mapColumn(col: ListColumn): Record<string, any> {
|
|
78
|
+
const mapped: Record<string, any> = {
|
|
79
|
+
accessorKey: col.field,
|
|
80
|
+
header: col.label ?? col.field,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (col.width != null) mapped.width = col.width;
|
|
84
|
+
if (col.align) mapped.align = col.align;
|
|
85
|
+
if (col.hidden != null) mapped.hidden = col.hidden;
|
|
86
|
+
if (col.sortable != null) mapped.sortable = col.sortable;
|
|
87
|
+
if (col.resizable != null) mapped.resizable = col.resizable;
|
|
88
|
+
if (col.wrap != null) mapped.wrap = col.wrap;
|
|
89
|
+
if (col.type) mapped.type = col.type;
|
|
90
|
+
if (col.pinned) mapped.pinned = col.pinned;
|
|
91
|
+
if (col.summary) mapped.summary = col.summary;
|
|
92
|
+
if (col.link) mapped.link = col.link;
|
|
93
|
+
if (col.action) mapped.action = col.action;
|
|
94
|
+
|
|
95
|
+
return mapped;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function mapDensity(
|
|
99
|
+
rowHeight?: string,
|
|
100
|
+
): 'compact' | 'comfortable' | 'spacious' | undefined {
|
|
101
|
+
if (!rowHeight) return undefined;
|
|
102
|
+
const map: Record<string, 'compact' | 'comfortable' | 'spacious'> = {
|
|
103
|
+
compact: 'compact',
|
|
104
|
+
short: 'compact',
|
|
105
|
+
comfortable: 'comfortable',
|
|
106
|
+
spacious: 'spacious',
|
|
107
|
+
small: 'compact',
|
|
108
|
+
medium: 'comfortable',
|
|
109
|
+
large: 'spacious',
|
|
110
|
+
tall: 'spacious',
|
|
111
|
+
extra_tall: 'spacious',
|
|
112
|
+
};
|
|
113
|
+
return map[rowHeight];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Transforms a ListView spec into a DataTable SchemaNode */
|
|
117
|
+
export const bridgeListView: BridgeFn<ListViewSpec> = (
|
|
118
|
+
spec: ListViewSpec,
|
|
119
|
+
_context: BridgeContext,
|
|
120
|
+
): SchemaNode => {
|
|
121
|
+
const columns = (spec.columns ?? []).map(mapColumn);
|
|
122
|
+
const density = mapDensity(spec.rowHeight);
|
|
123
|
+
|
|
124
|
+
const node: SchemaNode = {
|
|
125
|
+
type: 'object-grid',
|
|
126
|
+
id: spec.name,
|
|
127
|
+
columns,
|
|
128
|
+
data: spec.data,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (spec.label) node.label = spec.label;
|
|
132
|
+
if (spec.selection) node.selection = spec.selection;
|
|
133
|
+
if (spec.pagination) node.pagination = spec.pagination;
|
|
134
|
+
if (spec.sort) node.sort = spec.sort;
|
|
135
|
+
if (spec.filter) node.filter = spec.filter;
|
|
136
|
+
if (density) node.density = density;
|
|
137
|
+
if (spec.grouping) node.grouping = spec.grouping;
|
|
138
|
+
if (spec.rowColor) node.rowColor = spec.rowColor;
|
|
139
|
+
if (spec.searchableFields) node.searchableFields = spec.searchableFields;
|
|
140
|
+
if (spec.filterableFields) node.filterableFields = spec.filterableFields;
|
|
141
|
+
// Normalize quickFilters: spec format { field, operator, value } → ObjectUI format
|
|
142
|
+
const normalizedQF = normalizeQuickFilters(spec.quickFilters);
|
|
143
|
+
if (normalizedQF) node.quickFilters = normalizedQF;
|
|
144
|
+
if (spec.resizable != null) node.resizable = spec.resizable;
|
|
145
|
+
if (spec.striped != null) node.striped = spec.striped;
|
|
146
|
+
if (spec.bordered != null) node.bordered = spec.bordered;
|
|
147
|
+
if (spec.navigation) node.navigation = spec.navigation;
|
|
148
|
+
if (spec.kanban) node.kanban = spec.kanban;
|
|
149
|
+
if (spec.calendar) node.calendar = spec.calendar;
|
|
150
|
+
if (spec.gantt) node.gantt = spec.gantt;
|
|
151
|
+
if (spec.gallery) node.gallery = spec.gallery;
|
|
152
|
+
if (spec.timeline) node.timeline = spec.timeline;
|
|
153
|
+
|
|
154
|
+
// P1.1 — Spec Protocol Alignment additions
|
|
155
|
+
if (spec.rowActions) node.rowActions = spec.rowActions;
|
|
156
|
+
if (spec.bulkActions) node.bulkActions = spec.bulkActions;
|
|
157
|
+
if (spec.virtualScroll != null) node.virtualScroll = spec.virtualScroll;
|
|
158
|
+
if (spec.conditionalFormatting) node.conditionalFormatting = spec.conditionalFormatting;
|
|
159
|
+
if (spec.inlineEdit != null) node.inlineEdit = spec.inlineEdit;
|
|
160
|
+
if (spec.exportOptions) node.exportOptions = spec.exportOptions;
|
|
161
|
+
if (spec.emptyState) node.emptyState = spec.emptyState;
|
|
162
|
+
if (spec.userActions) node.userActions = spec.userActions;
|
|
163
|
+
if (spec.appearance) node.appearance = spec.appearance;
|
|
164
|
+
if (spec.tabs) node.tabs = spec.tabs;
|
|
165
|
+
if (spec.addRecord) node.addRecord = spec.addRecord;
|
|
166
|
+
if (spec.showRecordCount != null) node.showRecordCount = spec.showRecordCount;
|
|
167
|
+
if (spec.allowPrinting != null) node.allowPrinting = spec.allowPrinting;
|
|
168
|
+
|
|
169
|
+
// P1.6 — i18n & ARIA
|
|
170
|
+
if (spec.aria) node.aria = spec.aria;
|
|
171
|
+
if (spec.sharing) {
|
|
172
|
+
// Normalize spec sharing format: map type → visibility, set enabled = true
|
|
173
|
+
const sharing: Record<string, any> = { ...spec.sharing };
|
|
174
|
+
if (sharing.type && !sharing.visibility) {
|
|
175
|
+
sharing.visibility = sharing.type === 'collaborative' ? 'team' : 'private';
|
|
176
|
+
}
|
|
177
|
+
if (sharing.type && sharing.enabled == null) {
|
|
178
|
+
sharing.enabled = true;
|
|
179
|
+
}
|
|
180
|
+
node.sharing = sharing;
|
|
181
|
+
}
|
|
182
|
+
if (spec.hiddenFields) node.hiddenFields = spec.hiddenFields;
|
|
183
|
+
if (spec.fieldOrder) node.fieldOrder = spec.fieldOrder;
|
|
184
|
+
if (spec.description) node.description = spec.description;
|
|
185
|
+
|
|
186
|
+
return node;
|
|
187
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
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 type { SchemaNode } from '@object-ui/core';
|
|
10
|
+
import type { BridgeContext, BridgeFn } from '../types';
|
|
11
|
+
|
|
12
|
+
interface PageComponent {
|
|
13
|
+
type: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
properties?: Record<string, any>;
|
|
17
|
+
events?: Record<string, any>;
|
|
18
|
+
style?: Record<string, any>;
|
|
19
|
+
className?: string;
|
|
20
|
+
visibility?: string;
|
|
21
|
+
dataSource?: any;
|
|
22
|
+
responsive?: any;
|
|
23
|
+
aria?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface PageRegion {
|
|
27
|
+
name?: string;
|
|
28
|
+
width?: string;
|
|
29
|
+
components?: PageComponent[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface PageVariable {
|
|
33
|
+
name: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
defaultValue?: any;
|
|
36
|
+
source?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface BlankPageLayoutItem {
|
|
40
|
+
componentId: string;
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface PageSpec {
|
|
48
|
+
name?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
icon?: string;
|
|
52
|
+
type?: string;
|
|
53
|
+
variables?: PageVariable[];
|
|
54
|
+
regions?: PageRegion[];
|
|
55
|
+
template?: string;
|
|
56
|
+
object?: string;
|
|
57
|
+
// P1.4 additions
|
|
58
|
+
blankLayout?: {
|
|
59
|
+
columns?: number;
|
|
60
|
+
rowHeight?: number;
|
|
61
|
+
gap?: number;
|
|
62
|
+
items?: BlankPageLayoutItem[];
|
|
63
|
+
};
|
|
64
|
+
recordReview?: any;
|
|
65
|
+
isDefault?: boolean;
|
|
66
|
+
assignedProfiles?: string[];
|
|
67
|
+
interfaceConfig?: any;
|
|
68
|
+
aria?: { ariaLabel?: string; ariaDescribedBy?: string; role?: string };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function mapComponent(component: PageComponent): SchemaNode {
|
|
72
|
+
const node: SchemaNode = {
|
|
73
|
+
type: component.type,
|
|
74
|
+
id: component.id,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
if (component.label) node.label = component.label;
|
|
78
|
+
if (component.className) node.className = component.className;
|
|
79
|
+
if (component.properties) {
|
|
80
|
+
Object.assign(node, component.properties);
|
|
81
|
+
}
|
|
82
|
+
if (component.events) node.events = component.events;
|
|
83
|
+
if (component.visibility) node.visibility = component.visibility;
|
|
84
|
+
if (component.dataSource) node.dataSource = component.dataSource;
|
|
85
|
+
if (component.responsive) node.responsive = component.responsive;
|
|
86
|
+
if (component.aria) node.aria = component.aria;
|
|
87
|
+
|
|
88
|
+
return node;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function mapRegion(region: PageRegion): SchemaNode {
|
|
92
|
+
const children = (region.components ?? []).map(mapComponent);
|
|
93
|
+
const node: SchemaNode = {
|
|
94
|
+
type: 'page-region',
|
|
95
|
+
id: region.name,
|
|
96
|
+
body: children,
|
|
97
|
+
};
|
|
98
|
+
if (region.width) node.width = region.width;
|
|
99
|
+
return node;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Transforms a Page spec into a page layout SchemaNode */
|
|
103
|
+
export const bridgePage: BridgeFn<PageSpec> = (
|
|
104
|
+
spec: PageSpec,
|
|
105
|
+
_context: BridgeContext,
|
|
106
|
+
): SchemaNode => {
|
|
107
|
+
const regions = (spec.regions ?? []).map(mapRegion);
|
|
108
|
+
|
|
109
|
+
const node: SchemaNode = {
|
|
110
|
+
type: 'page',
|
|
111
|
+
id: spec.name,
|
|
112
|
+
body: regions,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
if (spec.label) node.label = spec.label;
|
|
116
|
+
if (spec.description) node.description = spec.description;
|
|
117
|
+
if (spec.icon) node.icon = spec.icon;
|
|
118
|
+
if (spec.type) node.pageType = spec.type;
|
|
119
|
+
if (spec.variables) node.variables = spec.variables;
|
|
120
|
+
if (spec.template) node.template = spec.template;
|
|
121
|
+
if (spec.object) node.object = spec.object;
|
|
122
|
+
|
|
123
|
+
// P1.4 — Blank page layout
|
|
124
|
+
if (spec.blankLayout) node.blankLayout = spec.blankLayout;
|
|
125
|
+
|
|
126
|
+
// P1.4 — Additional page properties
|
|
127
|
+
if (spec.recordReview) node.recordReview = spec.recordReview;
|
|
128
|
+
if (spec.isDefault != null) node.isDefault = spec.isDefault;
|
|
129
|
+
if (spec.assignedProfiles) node.assignedProfiles = spec.assignedProfiles;
|
|
130
|
+
if (spec.interfaceConfig) node.interfaceConfig = spec.interfaceConfig;
|
|
131
|
+
|
|
132
|
+
// P1.6 — i18n & ARIA
|
|
133
|
+
if (spec.aria) node.aria = spec.aria;
|
|
134
|
+
|
|
135
|
+
return node;
|
|
136
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export { SpecBridge } from './SpecBridge';
|
|
10
|
+
export type { BridgeContext, BridgeFn, ObjectDefLite } from './types';
|
|
11
|
+
export { bridgeListView } from './bridges/list-view';
|
|
12
|
+
export { bridgeFormView } from './bridges/form-view';
|
|
13
|
+
export { bridgePage } from './bridges/page';
|
|
14
|
+
export { bridgeDashboard } from './bridges/dashboard';
|
|
@@ -0,0 +1,38 @@
|
|
|
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 type { SchemaNode } from '@object-ui/core';
|
|
10
|
+
|
|
11
|
+
/** Context passed to all bridge functions */
|
|
12
|
+
export interface BridgeContext {
|
|
13
|
+
/** Current user context for permission checks */
|
|
14
|
+
user?: Record<string, any>;
|
|
15
|
+
/** App-level variables */
|
|
16
|
+
variables?: Record<string, any>;
|
|
17
|
+
/** Registered object definitions for field metadata lookup */
|
|
18
|
+
objectDefs?: Record<string, ObjectDefLite>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Lightweight object definition for field metadata resolution */
|
|
22
|
+
export interface ObjectDefLite {
|
|
23
|
+
name: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
fields: Array<{
|
|
26
|
+
name: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
type: string;
|
|
29
|
+
required?: boolean;
|
|
30
|
+
options?: Array<{ label: string; value: string }>;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A bridge function transforms a spec schema into a SchemaNode tree */
|
|
35
|
+
export type BridgeFn<T = any> = (
|
|
36
|
+
spec: T,
|
|
37
|
+
context: BridgeContext,
|
|
38
|
+
) => SchemaNode;
|