@object-ui/react 3.1.5 → 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.
Files changed (109) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +28 -3
  3. package/dist/SchemaRenderer.js +2 -2
  4. package/dist/components/form/FieldFactory.js +5 -2
  5. package/dist/context/AppShellContext.d.ts +26 -0
  6. package/dist/context/AppShellContext.js +67 -0
  7. package/dist/context/index.d.ts +1 -7
  8. package/dist/context/index.js +1 -7
  9. package/dist/hooks/index.d.ts +1 -0
  10. package/dist/hooks/index.js +1 -0
  11. package/dist/hooks/useDataRefresh.d.ts +36 -0
  12. package/dist/hooks/useDataRefresh.js +50 -0
  13. package/dist/hooks/useDiscovery.d.ts +12 -0
  14. package/dist/hooks/useDiscovery.js +6 -0
  15. package/dist/hooks/usePerformanceBudget.js +1 -1
  16. package/package.json +32 -9
  17. package/.turbo/turbo-build.log +0 -4
  18. package/src/LazyPluginLoader.tsx +0 -174
  19. package/src/SchemaRenderer.tsx +0 -266
  20. package/src/__tests__/LazyPluginLoader.test.tsx +0 -176
  21. package/src/__tests__/SchemaRenderer.aria.test.tsx +0 -118
  22. package/src/__tests__/SchemaRenderer.debug.test.tsx +0 -69
  23. package/src/__tests__/SchemaRenderer.errorBoundary.test.tsx +0 -114
  24. package/src/__tests__/SchemaRenderer.expressions.test.tsx +0 -131
  25. package/src/__tests__/SchemaRendererProvider.smoke.test.tsx +0 -132
  26. package/src/__tests__/ThemeProvider.test.tsx +0 -451
  27. package/src/__tests__/useNavigationOverlay.test.ts +0 -578
  28. package/src/__tests__/useOffline.test.ts +0 -198
  29. package/src/__tests__/usePageTransition.test.ts +0 -214
  30. package/src/__tests__/usePageVariables.test.tsx +0 -334
  31. package/src/__tests__/usePerformance.test.ts +0 -137
  32. package/src/__tests__/useViewData.test.tsx +0 -422
  33. package/src/__tests__/view-switching.test.tsx +0 -456
  34. package/src/components/form/FieldFactory.tsx +0 -509
  35. package/src/components/form/FormRenderer.test.tsx +0 -744
  36. package/src/components/form/FormRenderer.tsx +0 -258
  37. package/src/components/form/README.md +0 -352
  38. package/src/components/form/index.ts +0 -12
  39. package/src/context/ActionContext.tsx +0 -213
  40. package/src/context/DndContext.tsx +0 -260
  41. package/src/context/NotificationContext.tsx +0 -280
  42. package/src/context/SchemaRendererContext.tsx +0 -48
  43. package/src/context/ThemeContext.tsx +0 -325
  44. package/src/context/__tests__/ActionContext.test.tsx +0 -174
  45. package/src/context/__tests__/DndContext.test.tsx +0 -150
  46. package/src/context/__tests__/NotificationContext.test.tsx +0 -176
  47. package/src/context/__tests__/useDataScope.test.tsx +0 -91
  48. package/src/context/index.ts +0 -13
  49. package/src/hooks/__tests__/useActionEngine.test.ts +0 -170
  50. package/src/hooks/__tests__/useActionRunner.test.ts +0 -153
  51. package/src/hooks/__tests__/useAnimation.test.ts +0 -82
  52. package/src/hooks/__tests__/useColumnSummary.test.ts +0 -93
  53. package/src/hooks/__tests__/useCrudShortcuts.test.ts +0 -85
  54. package/src/hooks/__tests__/useDebugMode.test.ts +0 -83
  55. package/src/hooks/__tests__/useDensityMode.test.ts +0 -81
  56. package/src/hooks/__tests__/useDiscovery.test.tsx +0 -149
  57. package/src/hooks/__tests__/useDynamicApp.test.ts +0 -161
  58. package/src/hooks/__tests__/useETagCache.test.ts +0 -153
  59. package/src/hooks/__tests__/useExpression.test.ts +0 -86
  60. package/src/hooks/__tests__/useFocusTrap.test.ts +0 -294
  61. package/src/hooks/__tests__/useKeyboardShortcuts.test.ts +0 -144
  62. package/src/hooks/__tests__/usePageTransition.test.ts +0 -158
  63. package/src/hooks/__tests__/usePerformanceBudget.test.ts +0 -157
  64. package/src/hooks/__tests__/useReducedMotion.test.ts +0 -104
  65. package/src/hooks/__tests__/useSchemaPersistence.test.ts +0 -220
  66. package/src/hooks/__tests__/useViewSharing.test.ts +0 -121
  67. package/src/hooks/__tests__/useViewTransition.test.ts +0 -61
  68. package/src/hooks/index.ts +0 -35
  69. package/src/hooks/useActionEngine.ts +0 -84
  70. package/src/hooks/useActionRunner.ts +0 -119
  71. package/src/hooks/useAnimation.ts +0 -117
  72. package/src/hooks/useClientNotifications.ts +0 -251
  73. package/src/hooks/useColumnSummary.ts +0 -87
  74. package/src/hooks/useCrudShortcuts.ts +0 -126
  75. package/src/hooks/useDebugMode.ts +0 -95
  76. package/src/hooks/useDensityMode.ts +0 -102
  77. package/src/hooks/useDiscovery.ts +0 -154
  78. package/src/hooks/useDynamicApp.ts +0 -142
  79. package/src/hooks/useETagCache.ts +0 -404
  80. package/src/hooks/useExpression.ts +0 -56
  81. package/src/hooks/useFocusManagement.ts +0 -248
  82. package/src/hooks/useFocusTrap.ts +0 -138
  83. package/src/hooks/useGlobalUndo.ts +0 -98
  84. package/src/hooks/useKeyboardShortcuts.ts +0 -119
  85. package/src/hooks/useNavigationOverlay.ts +0 -190
  86. package/src/hooks/useOffline.ts +0 -301
  87. package/src/hooks/usePageTransition.ts +0 -187
  88. package/src/hooks/usePageVariables.tsx +0 -157
  89. package/src/hooks/usePerformance.ts +0 -246
  90. package/src/hooks/usePerformanceBudget.ts +0 -313
  91. package/src/hooks/useReducedMotion.ts +0 -53
  92. package/src/hooks/useSchemaPersistence.ts +0 -222
  93. package/src/hooks/useViewData.ts +0 -201
  94. package/src/hooks/useViewSharing.ts +0 -140
  95. package/src/hooks/useViewTransition.ts +0 -144
  96. package/src/index.ts +0 -41
  97. package/src/spec-bridge/SpecBridge.ts +0 -64
  98. package/src/spec-bridge/__tests__/P1SpecBridge.test.ts +0 -855
  99. package/src/spec-bridge/__tests__/SpecBridge.test.ts +0 -550
  100. package/src/spec-bridge/bridges/dashboard.ts +0 -180
  101. package/src/spec-bridge/bridges/form-view.ts +0 -109
  102. package/src/spec-bridge/bridges/list-view.ts +0 -187
  103. package/src/spec-bridge/bridges/page.ts +0 -136
  104. package/src/spec-bridge/index.ts +0 -14
  105. package/src/spec-bridge/types.ts +0 -38
  106. package/src/utils/i18n.ts +0 -10
  107. package/tsconfig.json +0 -17
  108. package/tsconfig.tsbuildinfo +0 -1
  109. package/vitest.config.ts +0 -2
@@ -1,180 +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 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
- };
@@ -1,109 +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 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
- };
@@ -1,187 +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 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
- };
@@ -1,136 +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 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
- };
@@ -1,14 +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
- 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';
@@ -1,38 +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 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;
package/src/utils/i18n.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Resolves an I18nLabel to a plain string.
3
- * I18nLabel can be either a string or an object { key, defaultValue?, params? }.
4
- * When it's an object, we return the defaultValue or the key as fallback.
5
- */
6
- export function resolveI18nLabel(label: string | { key: string; defaultValue?: string; params?: Record<string, any> } | undefined): string | undefined {
7
- if (label === undefined || label === null) return undefined;
8
- if (typeof label === 'string') return label;
9
- return label.defaultValue || label.key;
10
- }
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src",
6
- "jsx": "react-jsx",
7
- "noEmit": false,
8
- "declaration": true,
9
- "composite": true
10
- },
11
- "include": ["src"],
12
- "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"],
13
- "references": [
14
- { "path": "../types" },
15
- { "path": "../core" }
16
- ]
17
- }