@object-ui/react 3.0.2 → 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/CHANGELOG.md +8 -0
- 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/{src/index.test.ts → dist/spec-bridge/types.js} +1 -8
- 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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import type { BridgeFn } from '../types';
|
|
9
|
+
interface DashboardWidget {
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
chartConfig?: any;
|
|
14
|
+
colorVariant?: string;
|
|
15
|
+
actionUrl?: string;
|
|
16
|
+
actionType?: string;
|
|
17
|
+
actionIcon?: string;
|
|
18
|
+
object?: string;
|
|
19
|
+
filter?: any;
|
|
20
|
+
categoryField?: string;
|
|
21
|
+
valueField?: string;
|
|
22
|
+
aggregate?: string;
|
|
23
|
+
measures?: any[];
|
|
24
|
+
layout?: any;
|
|
25
|
+
options?: any;
|
|
26
|
+
responsive?: any;
|
|
27
|
+
aria?: {
|
|
28
|
+
ariaLabel?: string;
|
|
29
|
+
ariaDescribedBy?: string;
|
|
30
|
+
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
|
+
interface GlobalFilter {
|
|
45
|
+
field: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
type?: string;
|
|
48
|
+
options?: string[];
|
|
49
|
+
optionsFrom?: {
|
|
50
|
+
object: string;
|
|
51
|
+
valueField: string;
|
|
52
|
+
labelField?: string;
|
|
53
|
+
filter?: any;
|
|
54
|
+
};
|
|
55
|
+
defaultValue?: any;
|
|
56
|
+
scope?: string;
|
|
57
|
+
targetWidgets?: string[];
|
|
58
|
+
}
|
|
59
|
+
interface DashboardSpec {
|
|
60
|
+
name?: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
widgets?: DashboardWidget[];
|
|
64
|
+
globalFilters?: GlobalFilter[];
|
|
65
|
+
header?: DashboardHeader;
|
|
66
|
+
refreshInterval?: number;
|
|
67
|
+
dateRange?: {
|
|
68
|
+
field?: string;
|
|
69
|
+
defaultRange?: string;
|
|
70
|
+
allowCustomRange?: boolean;
|
|
71
|
+
};
|
|
72
|
+
aria?: {
|
|
73
|
+
ariaLabel?: string;
|
|
74
|
+
ariaDescribedBy?: string;
|
|
75
|
+
role?: string;
|
|
76
|
+
};
|
|
77
|
+
performance?: any;
|
|
78
|
+
}
|
|
79
|
+
/** Transforms a Dashboard spec into a dashboard layout SchemaNode */
|
|
80
|
+
export declare const bridgeDashboard: BridgeFn<DashboardSpec>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
function mapWidget(widget, index) {
|
|
9
|
+
const node = {
|
|
10
|
+
type: widget.type ?? 'chart',
|
|
11
|
+
id: `widget-${index}`,
|
|
12
|
+
};
|
|
13
|
+
if (widget.title)
|
|
14
|
+
node.title = widget.title;
|
|
15
|
+
if (widget.description)
|
|
16
|
+
node.description = widget.description;
|
|
17
|
+
if (widget.chartConfig)
|
|
18
|
+
node.chartConfig = widget.chartConfig;
|
|
19
|
+
if (widget.colorVariant)
|
|
20
|
+
node.colorVariant = widget.colorVariant;
|
|
21
|
+
if (widget.actionUrl)
|
|
22
|
+
node.actionUrl = widget.actionUrl;
|
|
23
|
+
if (widget.actionType)
|
|
24
|
+
node.actionType = widget.actionType;
|
|
25
|
+
if (widget.actionIcon)
|
|
26
|
+
node.actionIcon = widget.actionIcon;
|
|
27
|
+
if (widget.object)
|
|
28
|
+
node.object = widget.object;
|
|
29
|
+
if (widget.filter)
|
|
30
|
+
node.filter = widget.filter;
|
|
31
|
+
if (widget.categoryField)
|
|
32
|
+
node.categoryField = widget.categoryField;
|
|
33
|
+
if (widget.valueField)
|
|
34
|
+
node.valueField = widget.valueField;
|
|
35
|
+
if (widget.aggregate)
|
|
36
|
+
node.aggregate = widget.aggregate;
|
|
37
|
+
if (widget.measures)
|
|
38
|
+
node.measures = widget.measures;
|
|
39
|
+
if (widget.layout)
|
|
40
|
+
node.layout = widget.layout;
|
|
41
|
+
if (widget.options)
|
|
42
|
+
node.options = widget.options;
|
|
43
|
+
if (widget.responsive)
|
|
44
|
+
node.responsive = widget.responsive;
|
|
45
|
+
if (widget.aria)
|
|
46
|
+
node.aria = widget.aria;
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
function mapGlobalFilters(filters) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'filter-bar',
|
|
52
|
+
id: 'dashboard-filters',
|
|
53
|
+
filters: filters.map((f) => {
|
|
54
|
+
const mapped = { field: f.field };
|
|
55
|
+
if (f.label)
|
|
56
|
+
mapped.label = f.label;
|
|
57
|
+
if (f.type)
|
|
58
|
+
mapped.type = f.type;
|
|
59
|
+
if (f.options)
|
|
60
|
+
mapped.options = f.options;
|
|
61
|
+
if (f.optionsFrom)
|
|
62
|
+
mapped.optionsFrom = f.optionsFrom;
|
|
63
|
+
if (f.defaultValue != null)
|
|
64
|
+
mapped.defaultValue = f.defaultValue;
|
|
65
|
+
if (f.scope)
|
|
66
|
+
mapped.scope = f.scope;
|
|
67
|
+
if (f.targetWidgets)
|
|
68
|
+
mapped.targetWidgets = f.targetWidgets;
|
|
69
|
+
return mapped;
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function mapHeader(header) {
|
|
74
|
+
const node = {
|
|
75
|
+
type: 'dashboard-header',
|
|
76
|
+
id: 'dashboard-header',
|
|
77
|
+
...header,
|
|
78
|
+
};
|
|
79
|
+
return node;
|
|
80
|
+
}
|
|
81
|
+
/** Transforms a Dashboard spec into a dashboard layout SchemaNode */
|
|
82
|
+
export const bridgeDashboard = (spec, _context) => {
|
|
83
|
+
const widgetNodes = (spec.widgets ?? []).map(mapWidget);
|
|
84
|
+
const bodyChildren = [];
|
|
85
|
+
if (spec.header) {
|
|
86
|
+
bodyChildren.push(mapHeader(spec.header));
|
|
87
|
+
}
|
|
88
|
+
if (spec.globalFilters && spec.globalFilters.length > 0) {
|
|
89
|
+
bodyChildren.push(mapGlobalFilters(spec.globalFilters));
|
|
90
|
+
}
|
|
91
|
+
// P1.3 — Date range filter
|
|
92
|
+
if (spec.dateRange) {
|
|
93
|
+
bodyChildren.push({
|
|
94
|
+
type: 'date-range-filter',
|
|
95
|
+
id: 'dashboard-date-range',
|
|
96
|
+
...spec.dateRange,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
bodyChildren.push({
|
|
100
|
+
type: 'widget-grid',
|
|
101
|
+
id: 'dashboard-widgets',
|
|
102
|
+
body: widgetNodes,
|
|
103
|
+
});
|
|
104
|
+
const node = {
|
|
105
|
+
type: 'dashboard',
|
|
106
|
+
id: spec.name,
|
|
107
|
+
body: bodyChildren,
|
|
108
|
+
};
|
|
109
|
+
if (spec.label)
|
|
110
|
+
node.label = spec.label;
|
|
111
|
+
if (spec.description)
|
|
112
|
+
node.description = spec.description;
|
|
113
|
+
if (spec.refreshInterval != null)
|
|
114
|
+
node.refreshInterval = spec.refreshInterval;
|
|
115
|
+
// P1.6 — i18n & ARIA
|
|
116
|
+
if (spec.aria)
|
|
117
|
+
node.aria = spec.aria;
|
|
118
|
+
if (spec.performance)
|
|
119
|
+
node.performance = spec.performance;
|
|
120
|
+
return node;
|
|
121
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import type { BridgeFn } from '../types';
|
|
9
|
+
interface FormField {
|
|
10
|
+
field: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
helpText?: string;
|
|
14
|
+
readonly?: boolean;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
colSpan?: number;
|
|
18
|
+
widget?: string;
|
|
19
|
+
dependsOn?: string[];
|
|
20
|
+
visibleOn?: string;
|
|
21
|
+
}
|
|
22
|
+
interface FormSection {
|
|
23
|
+
label?: string;
|
|
24
|
+
collapsible?: boolean;
|
|
25
|
+
collapsed?: boolean;
|
|
26
|
+
columns?: number;
|
|
27
|
+
fields?: FormField[];
|
|
28
|
+
}
|
|
29
|
+
interface FormViewSpec {
|
|
30
|
+
type?: string;
|
|
31
|
+
data?: any;
|
|
32
|
+
sections?: FormSection[];
|
|
33
|
+
groups?: any;
|
|
34
|
+
defaultSort?: any;
|
|
35
|
+
sharing?: any;
|
|
36
|
+
aria?: {
|
|
37
|
+
ariaLabel?: string;
|
|
38
|
+
ariaDescribedBy?: string;
|
|
39
|
+
role?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Transforms a FormView spec into a Form SchemaNode */
|
|
43
|
+
export declare const bridgeFormView: BridgeFn<FormViewSpec>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
function mapField(field) {
|
|
9
|
+
const mapped = {
|
|
10
|
+
name: field.field,
|
|
11
|
+
label: field.label ?? field.field,
|
|
12
|
+
};
|
|
13
|
+
if (field.placeholder)
|
|
14
|
+
mapped.placeholder = field.placeholder;
|
|
15
|
+
if (field.helpText)
|
|
16
|
+
mapped.helpText = field.helpText;
|
|
17
|
+
if (field.readonly != null)
|
|
18
|
+
mapped.readonly = field.readonly;
|
|
19
|
+
if (field.required != null)
|
|
20
|
+
mapped.required = field.required;
|
|
21
|
+
if (field.hidden != null)
|
|
22
|
+
mapped.hidden = field.hidden;
|
|
23
|
+
if (field.colSpan != null)
|
|
24
|
+
mapped.colSpan = field.colSpan;
|
|
25
|
+
if (field.widget)
|
|
26
|
+
mapped.widget = field.widget;
|
|
27
|
+
if (field.dependsOn)
|
|
28
|
+
mapped.dependsOn = field.dependsOn;
|
|
29
|
+
if (field.visibleOn)
|
|
30
|
+
mapped.visibleOn = field.visibleOn;
|
|
31
|
+
return mapped;
|
|
32
|
+
}
|
|
33
|
+
function mapSection(section) {
|
|
34
|
+
const mapped = {
|
|
35
|
+
fields: (section.fields ?? []).map(mapField),
|
|
36
|
+
};
|
|
37
|
+
if (section.label)
|
|
38
|
+
mapped.label = section.label;
|
|
39
|
+
if (section.collapsible != null)
|
|
40
|
+
mapped.collapsible = section.collapsible;
|
|
41
|
+
if (section.collapsed != null)
|
|
42
|
+
mapped.collapsed = section.collapsed;
|
|
43
|
+
if (section.columns != null)
|
|
44
|
+
mapped.columns = section.columns;
|
|
45
|
+
return mapped;
|
|
46
|
+
}
|
|
47
|
+
/** Maps spec formType to ObjectUI formType */
|
|
48
|
+
function mapFormType(type) {
|
|
49
|
+
if (!type)
|
|
50
|
+
return undefined;
|
|
51
|
+
const validTypes = ['simple', 'tabbed', 'wizard', 'split', 'drawer', 'modal'];
|
|
52
|
+
return validTypes.includes(type) ? type : undefined;
|
|
53
|
+
}
|
|
54
|
+
/** Transforms a FormView spec into a Form SchemaNode */
|
|
55
|
+
export const bridgeFormView = (spec, _context) => {
|
|
56
|
+
const sections = (spec.sections ?? []).map(mapSection);
|
|
57
|
+
const formType = mapFormType(spec.type);
|
|
58
|
+
const node = {
|
|
59
|
+
type: 'object-form',
|
|
60
|
+
id: `form-${spec.type ?? 'default'}`,
|
|
61
|
+
sections,
|
|
62
|
+
data: spec.data,
|
|
63
|
+
};
|
|
64
|
+
// P1.2 — formType mapping (tabbed, wizard, split, drawer, modal)
|
|
65
|
+
if (formType)
|
|
66
|
+
node.formType = formType;
|
|
67
|
+
if (spec.groups)
|
|
68
|
+
node.groups = spec.groups;
|
|
69
|
+
if (spec.defaultSort)
|
|
70
|
+
node.defaultSort = spec.defaultSort;
|
|
71
|
+
// P1.6 — i18n & ARIA
|
|
72
|
+
if (spec.sharing)
|
|
73
|
+
node.sharing = spec.sharing;
|
|
74
|
+
if (spec.aria)
|
|
75
|
+
node.aria = spec.aria;
|
|
76
|
+
return node;
|
|
77
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import type { BridgeFn } from '../types';
|
|
9
|
+
import type { ListViewGalleryConfig, ListViewTimelineConfig } from '@object-ui/types';
|
|
10
|
+
interface ListColumn {
|
|
11
|
+
field: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
width?: number;
|
|
14
|
+
align?: string;
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
sortable?: boolean;
|
|
17
|
+
resizable?: boolean;
|
|
18
|
+
wrap?: boolean;
|
|
19
|
+
type?: string;
|
|
20
|
+
pinned?: string;
|
|
21
|
+
summary?: any;
|
|
22
|
+
link?: any;
|
|
23
|
+
action?: any;
|
|
24
|
+
}
|
|
25
|
+
interface ListViewSpec {
|
|
26
|
+
name?: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
data?: any;
|
|
30
|
+
columns?: ListColumn[];
|
|
31
|
+
filter?: any;
|
|
32
|
+
sort?: any;
|
|
33
|
+
searchableFields?: string[];
|
|
34
|
+
filterableFields?: string[];
|
|
35
|
+
quickFilters?: any[];
|
|
36
|
+
selection?: any;
|
|
37
|
+
pagination?: any;
|
|
38
|
+
rowHeight?: string;
|
|
39
|
+
resizable?: boolean;
|
|
40
|
+
striped?: boolean;
|
|
41
|
+
bordered?: boolean;
|
|
42
|
+
grouping?: any;
|
|
43
|
+
rowColor?: any;
|
|
44
|
+
navigation?: any;
|
|
45
|
+
kanban?: any;
|
|
46
|
+
calendar?: any;
|
|
47
|
+
gantt?: any;
|
|
48
|
+
gallery?: ListViewGalleryConfig;
|
|
49
|
+
timeline?: ListViewTimelineConfig;
|
|
50
|
+
rowActions?: string[];
|
|
51
|
+
bulkActions?: string[];
|
|
52
|
+
virtualScroll?: boolean;
|
|
53
|
+
conditionalFormatting?: Array<{
|
|
54
|
+
condition: string;
|
|
55
|
+
style: Record<string, string>;
|
|
56
|
+
}>;
|
|
57
|
+
inlineEdit?: boolean;
|
|
58
|
+
exportOptions?: any;
|
|
59
|
+
emptyState?: {
|
|
60
|
+
title?: string;
|
|
61
|
+
message?: string;
|
|
62
|
+
icon?: string;
|
|
63
|
+
};
|
|
64
|
+
userActions?: any;
|
|
65
|
+
appearance?: any;
|
|
66
|
+
tabs?: any[];
|
|
67
|
+
addRecord?: any;
|
|
68
|
+
showRecordCount?: boolean;
|
|
69
|
+
allowPrinting?: boolean;
|
|
70
|
+
aria?: {
|
|
71
|
+
ariaLabel?: string;
|
|
72
|
+
ariaDescribedBy?: string;
|
|
73
|
+
role?: string;
|
|
74
|
+
};
|
|
75
|
+
sharing?: any;
|
|
76
|
+
hiddenFields?: string[];
|
|
77
|
+
fieldOrder?: string[];
|
|
78
|
+
description?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Transforms a ListView spec into a DataTable SchemaNode */
|
|
81
|
+
export declare const bridgeListView: BridgeFn<ListViewSpec>;
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { normalizeQuickFilters } from '@object-ui/core';
|
|
9
|
+
function mapColumn(col) {
|
|
10
|
+
const mapped = {
|
|
11
|
+
accessorKey: col.field,
|
|
12
|
+
header: col.label ?? col.field,
|
|
13
|
+
};
|
|
14
|
+
if (col.width != null)
|
|
15
|
+
mapped.width = col.width;
|
|
16
|
+
if (col.align)
|
|
17
|
+
mapped.align = col.align;
|
|
18
|
+
if (col.hidden != null)
|
|
19
|
+
mapped.hidden = col.hidden;
|
|
20
|
+
if (col.sortable != null)
|
|
21
|
+
mapped.sortable = col.sortable;
|
|
22
|
+
if (col.resizable != null)
|
|
23
|
+
mapped.resizable = col.resizable;
|
|
24
|
+
if (col.wrap != null)
|
|
25
|
+
mapped.wrap = col.wrap;
|
|
26
|
+
if (col.type)
|
|
27
|
+
mapped.type = col.type;
|
|
28
|
+
if (col.pinned)
|
|
29
|
+
mapped.pinned = col.pinned;
|
|
30
|
+
if (col.summary)
|
|
31
|
+
mapped.summary = col.summary;
|
|
32
|
+
if (col.link)
|
|
33
|
+
mapped.link = col.link;
|
|
34
|
+
if (col.action)
|
|
35
|
+
mapped.action = col.action;
|
|
36
|
+
return mapped;
|
|
37
|
+
}
|
|
38
|
+
function mapDensity(rowHeight) {
|
|
39
|
+
if (!rowHeight)
|
|
40
|
+
return undefined;
|
|
41
|
+
const map = {
|
|
42
|
+
compact: 'compact',
|
|
43
|
+
short: 'compact',
|
|
44
|
+
comfortable: 'comfortable',
|
|
45
|
+
spacious: 'spacious',
|
|
46
|
+
small: 'compact',
|
|
47
|
+
medium: 'comfortable',
|
|
48
|
+
large: 'spacious',
|
|
49
|
+
tall: 'spacious',
|
|
50
|
+
extra_tall: 'spacious',
|
|
51
|
+
};
|
|
52
|
+
return map[rowHeight];
|
|
53
|
+
}
|
|
54
|
+
/** Transforms a ListView spec into a DataTable SchemaNode */
|
|
55
|
+
export const bridgeListView = (spec, _context) => {
|
|
56
|
+
const columns = (spec.columns ?? []).map(mapColumn);
|
|
57
|
+
const density = mapDensity(spec.rowHeight);
|
|
58
|
+
const node = {
|
|
59
|
+
type: 'object-grid',
|
|
60
|
+
id: spec.name,
|
|
61
|
+
columns,
|
|
62
|
+
data: spec.data,
|
|
63
|
+
};
|
|
64
|
+
if (spec.label)
|
|
65
|
+
node.label = spec.label;
|
|
66
|
+
if (spec.selection)
|
|
67
|
+
node.selection = spec.selection;
|
|
68
|
+
if (spec.pagination)
|
|
69
|
+
node.pagination = spec.pagination;
|
|
70
|
+
if (spec.sort)
|
|
71
|
+
node.sort = spec.sort;
|
|
72
|
+
if (spec.filter)
|
|
73
|
+
node.filter = spec.filter;
|
|
74
|
+
if (density)
|
|
75
|
+
node.density = density;
|
|
76
|
+
if (spec.grouping)
|
|
77
|
+
node.grouping = spec.grouping;
|
|
78
|
+
if (spec.rowColor)
|
|
79
|
+
node.rowColor = spec.rowColor;
|
|
80
|
+
if (spec.searchableFields)
|
|
81
|
+
node.searchableFields = spec.searchableFields;
|
|
82
|
+
if (spec.filterableFields)
|
|
83
|
+
node.filterableFields = spec.filterableFields;
|
|
84
|
+
// Normalize quickFilters: spec format { field, operator, value } → ObjectUI format
|
|
85
|
+
const normalizedQF = normalizeQuickFilters(spec.quickFilters);
|
|
86
|
+
if (normalizedQF)
|
|
87
|
+
node.quickFilters = normalizedQF;
|
|
88
|
+
if (spec.resizable != null)
|
|
89
|
+
node.resizable = spec.resizable;
|
|
90
|
+
if (spec.striped != null)
|
|
91
|
+
node.striped = spec.striped;
|
|
92
|
+
if (spec.bordered != null)
|
|
93
|
+
node.bordered = spec.bordered;
|
|
94
|
+
if (spec.navigation)
|
|
95
|
+
node.navigation = spec.navigation;
|
|
96
|
+
if (spec.kanban)
|
|
97
|
+
node.kanban = spec.kanban;
|
|
98
|
+
if (spec.calendar)
|
|
99
|
+
node.calendar = spec.calendar;
|
|
100
|
+
if (spec.gantt)
|
|
101
|
+
node.gantt = spec.gantt;
|
|
102
|
+
if (spec.gallery)
|
|
103
|
+
node.gallery = spec.gallery;
|
|
104
|
+
if (spec.timeline)
|
|
105
|
+
node.timeline = spec.timeline;
|
|
106
|
+
// P1.1 — Spec Protocol Alignment additions
|
|
107
|
+
if (spec.rowActions)
|
|
108
|
+
node.rowActions = spec.rowActions;
|
|
109
|
+
if (spec.bulkActions)
|
|
110
|
+
node.bulkActions = spec.bulkActions;
|
|
111
|
+
if (spec.virtualScroll != null)
|
|
112
|
+
node.virtualScroll = spec.virtualScroll;
|
|
113
|
+
if (spec.conditionalFormatting)
|
|
114
|
+
node.conditionalFormatting = spec.conditionalFormatting;
|
|
115
|
+
if (spec.inlineEdit != null)
|
|
116
|
+
node.inlineEdit = spec.inlineEdit;
|
|
117
|
+
if (spec.exportOptions)
|
|
118
|
+
node.exportOptions = spec.exportOptions;
|
|
119
|
+
if (spec.emptyState)
|
|
120
|
+
node.emptyState = spec.emptyState;
|
|
121
|
+
if (spec.userActions)
|
|
122
|
+
node.userActions = spec.userActions;
|
|
123
|
+
if (spec.appearance)
|
|
124
|
+
node.appearance = spec.appearance;
|
|
125
|
+
if (spec.tabs)
|
|
126
|
+
node.tabs = spec.tabs;
|
|
127
|
+
if (spec.addRecord)
|
|
128
|
+
node.addRecord = spec.addRecord;
|
|
129
|
+
if (spec.showRecordCount != null)
|
|
130
|
+
node.showRecordCount = spec.showRecordCount;
|
|
131
|
+
if (spec.allowPrinting != null)
|
|
132
|
+
node.allowPrinting = spec.allowPrinting;
|
|
133
|
+
// P1.6 — i18n & ARIA
|
|
134
|
+
if (spec.aria)
|
|
135
|
+
node.aria = spec.aria;
|
|
136
|
+
if (spec.sharing) {
|
|
137
|
+
// Normalize spec sharing format: map type → visibility, set enabled = true
|
|
138
|
+
const sharing = { ...spec.sharing };
|
|
139
|
+
if (sharing.type && !sharing.visibility) {
|
|
140
|
+
sharing.visibility = sharing.type === 'collaborative' ? 'team' : 'private';
|
|
141
|
+
}
|
|
142
|
+
if (sharing.type && sharing.enabled == null) {
|
|
143
|
+
sharing.enabled = true;
|
|
144
|
+
}
|
|
145
|
+
node.sharing = sharing;
|
|
146
|
+
}
|
|
147
|
+
if (spec.hiddenFields)
|
|
148
|
+
node.hiddenFields = spec.hiddenFields;
|
|
149
|
+
if (spec.fieldOrder)
|
|
150
|
+
node.fieldOrder = spec.fieldOrder;
|
|
151
|
+
if (spec.description)
|
|
152
|
+
node.description = spec.description;
|
|
153
|
+
return node;
|
|
154
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import type { BridgeFn } from '../types';
|
|
9
|
+
interface PageComponent {
|
|
10
|
+
type: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
properties?: Record<string, any>;
|
|
14
|
+
events?: Record<string, any>;
|
|
15
|
+
style?: Record<string, any>;
|
|
16
|
+
className?: string;
|
|
17
|
+
visibility?: string;
|
|
18
|
+
dataSource?: any;
|
|
19
|
+
responsive?: any;
|
|
20
|
+
aria?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
interface PageRegion {
|
|
23
|
+
name?: string;
|
|
24
|
+
width?: string;
|
|
25
|
+
components?: PageComponent[];
|
|
26
|
+
}
|
|
27
|
+
interface PageVariable {
|
|
28
|
+
name: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
defaultValue?: any;
|
|
31
|
+
source?: string;
|
|
32
|
+
}
|
|
33
|
+
interface BlankPageLayoutItem {
|
|
34
|
+
componentId: string;
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}
|
|
40
|
+
interface PageSpec {
|
|
41
|
+
name?: string;
|
|
42
|
+
label?: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
icon?: string;
|
|
45
|
+
type?: string;
|
|
46
|
+
variables?: PageVariable[];
|
|
47
|
+
regions?: PageRegion[];
|
|
48
|
+
template?: string;
|
|
49
|
+
object?: string;
|
|
50
|
+
blankLayout?: {
|
|
51
|
+
columns?: number;
|
|
52
|
+
rowHeight?: number;
|
|
53
|
+
gap?: number;
|
|
54
|
+
items?: BlankPageLayoutItem[];
|
|
55
|
+
};
|
|
56
|
+
recordReview?: any;
|
|
57
|
+
isDefault?: boolean;
|
|
58
|
+
assignedProfiles?: string[];
|
|
59
|
+
interfaceConfig?: any;
|
|
60
|
+
aria?: {
|
|
61
|
+
ariaLabel?: string;
|
|
62
|
+
ariaDescribedBy?: string;
|
|
63
|
+
role?: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** Transforms a Page spec into a page layout SchemaNode */
|
|
67
|
+
export declare const bridgePage: BridgeFn<PageSpec>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
function mapComponent(component) {
|
|
9
|
+
const node = {
|
|
10
|
+
type: component.type,
|
|
11
|
+
id: component.id,
|
|
12
|
+
};
|
|
13
|
+
if (component.label)
|
|
14
|
+
node.label = component.label;
|
|
15
|
+
if (component.className)
|
|
16
|
+
node.className = component.className;
|
|
17
|
+
if (component.properties) {
|
|
18
|
+
Object.assign(node, component.properties);
|
|
19
|
+
}
|
|
20
|
+
if (component.events)
|
|
21
|
+
node.events = component.events;
|
|
22
|
+
if (component.visibility)
|
|
23
|
+
node.visibility = component.visibility;
|
|
24
|
+
if (component.dataSource)
|
|
25
|
+
node.dataSource = component.dataSource;
|
|
26
|
+
if (component.responsive)
|
|
27
|
+
node.responsive = component.responsive;
|
|
28
|
+
if (component.aria)
|
|
29
|
+
node.aria = component.aria;
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
function mapRegion(region) {
|
|
33
|
+
const children = (region.components ?? []).map(mapComponent);
|
|
34
|
+
const node = {
|
|
35
|
+
type: 'page-region',
|
|
36
|
+
id: region.name,
|
|
37
|
+
body: children,
|
|
38
|
+
};
|
|
39
|
+
if (region.width)
|
|
40
|
+
node.width = region.width;
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
/** Transforms a Page spec into a page layout SchemaNode */
|
|
44
|
+
export const bridgePage = (spec, _context) => {
|
|
45
|
+
const regions = (spec.regions ?? []).map(mapRegion);
|
|
46
|
+
const node = {
|
|
47
|
+
type: 'page',
|
|
48
|
+
id: spec.name,
|
|
49
|
+
body: regions,
|
|
50
|
+
};
|
|
51
|
+
if (spec.label)
|
|
52
|
+
node.label = spec.label;
|
|
53
|
+
if (spec.description)
|
|
54
|
+
node.description = spec.description;
|
|
55
|
+
if (spec.icon)
|
|
56
|
+
node.icon = spec.icon;
|
|
57
|
+
if (spec.type)
|
|
58
|
+
node.pageType = spec.type;
|
|
59
|
+
if (spec.variables)
|
|
60
|
+
node.variables = spec.variables;
|
|
61
|
+
if (spec.template)
|
|
62
|
+
node.template = spec.template;
|
|
63
|
+
if (spec.object)
|
|
64
|
+
node.object = spec.object;
|
|
65
|
+
// P1.4 — Blank page layout
|
|
66
|
+
if (spec.blankLayout)
|
|
67
|
+
node.blankLayout = spec.blankLayout;
|
|
68
|
+
// P1.4 — Additional page properties
|
|
69
|
+
if (spec.recordReview)
|
|
70
|
+
node.recordReview = spec.recordReview;
|
|
71
|
+
if (spec.isDefault != null)
|
|
72
|
+
node.isDefault = spec.isDefault;
|
|
73
|
+
if (spec.assignedProfiles)
|
|
74
|
+
node.assignedProfiles = spec.assignedProfiles;
|
|
75
|
+
if (spec.interfaceConfig)
|
|
76
|
+
node.interfaceConfig = spec.interfaceConfig;
|
|
77
|
+
// P1.6 — i18n & ARIA
|
|
78
|
+
if (spec.aria)
|
|
79
|
+
node.aria = spec.aria;
|
|
80
|
+
return node;
|
|
81
|
+
};
|