@object-ui/react 3.3.1 → 3.4.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/CHANGELOG.md +20 -0
- package/dist/SchemaRenderer.js +19 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @object-ui/react
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f1ca238]
|
|
8
|
+
- Updated dependencies [de881ef]
|
|
9
|
+
- @object-ui/types@3.4.0
|
|
10
|
+
- @object-ui/core@3.4.0
|
|
11
|
+
- @object-ui/data-objectstack@3.4.0
|
|
12
|
+
- @object-ui/i18n@3.4.0
|
|
13
|
+
|
|
14
|
+
## 3.3.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- @object-ui/types@3.3.2
|
|
19
|
+
- @object-ui/core@3.3.2
|
|
20
|
+
- @object-ui/i18n@3.3.2
|
|
21
|
+
- @object-ui/data-objectstack@3.3.2
|
|
22
|
+
|
|
3
23
|
## 3.3.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/SchemaRenderer.js
CHANGED
|
@@ -6,7 +6,7 @@ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-run
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
import React, { forwardRef, useContext, useMemo, Component } from 'react';
|
|
9
|
+
import React, { forwardRef, useContext, useMemo, useEffect, useReducer, useState, Component } from 'react';
|
|
10
10
|
import { ComponentRegistry, ExpressionEvaluator, isObjectUIError, ERROR_CODES, debugLog, debugTime, debugTimeEnd, DebugCollector, } from '@object-ui/core';
|
|
11
11
|
import { SchemaRendererContext } from './context/SchemaRendererContext';
|
|
12
12
|
import { resolveI18nLabel } from './utils/i18n';
|
|
@@ -66,6 +66,11 @@ export class SchemaErrorBoundary extends Component {
|
|
|
66
66
|
export const SchemaRenderer = forwardRef(({ schema, ...props }, _ref) => {
|
|
67
67
|
const context = useContext(SchemaRendererContext);
|
|
68
68
|
const dataSource = context?.dataSource || {};
|
|
69
|
+
// Re-render trigger when the global ComponentRegistry mutates (e.g. a
|
|
70
|
+
// lazy-loaded plugin finishes registering its components).
|
|
71
|
+
const [, forceUpdate] = useReducer((n) => n + 1, 0);
|
|
72
|
+
useEffect(() => ComponentRegistry.subscribe(forceUpdate), []);
|
|
73
|
+
const [lazyError, setLazyError] = useState(null);
|
|
69
74
|
// Evaluate schema expressions against the data source
|
|
70
75
|
const evaluatedSchema = useMemo(() => {
|
|
71
76
|
if (!schema || typeof schema === 'string')
|
|
@@ -135,9 +140,21 @@ export const SchemaRenderer = forwardRef(({ schema, ...props }, _ref) => {
|
|
|
135
140
|
debugLog('schema', 'Rendering schema node', { type: evaluatedSchema.type, id: evaluatedSchema.id });
|
|
136
141
|
const Component = ComponentRegistry.get(evaluatedSchema.type);
|
|
137
142
|
if (!Component) {
|
|
143
|
+
// If a lazy loader is registered for this type, kick it off — the
|
|
144
|
+
// registry will notify us via subscribe() once the plugin module's
|
|
145
|
+
// top-level register() side-effects have run.
|
|
146
|
+
if (!lazyError && ComponentRegistry.hasLazy(evaluatedSchema.type)) {
|
|
147
|
+
const pending = ComponentRegistry.loadLazy(evaluatedSchema.type);
|
|
148
|
+
if (pending) {
|
|
149
|
+
pending.catch((err) => {
|
|
150
|
+
setLazyError(err instanceof Error ? err : new Error(String(err)));
|
|
151
|
+
});
|
|
152
|
+
return (_jsxs("div", { className: "p-2 text-sm text-muted-foreground animate-pulse", role: "status", "aria-live": "polite", "data-lazy-loading": evaluatedSchema.type, children: ["Loading ", _jsx("code", { children: evaluatedSchema.type }), "\u2026"] }));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
138
155
|
debugLog('schema', 'Component not found in registry', { type: evaluatedSchema.type });
|
|
139
156
|
const errorInfo = ERROR_CODES['OBJUI-001'];
|
|
140
|
-
return (_jsxs("div", { className: "p-4 border border-red-500 rounded text-red-500 bg-red-50 my-2", role: "alert", children: [_jsxs("p", { className: "font-medium", children: ["Unknown component type: ", _jsx("strong", { children: evaluatedSchema.type })] }), globalThis.process?.env?.NODE_ENV !== 'production' && (_jsxs("p", { className: "text-xs mt-1", children: ["\uD83D\uDCA1 ", errorInfo.suggestion, " (OBJUI-001)"] })), _jsx("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(evaluatedSchema, null, 2) })] }));
|
|
157
|
+
return (_jsxs("div", { className: "p-4 border border-red-500 rounded text-red-500 bg-red-50 my-2", role: "alert", children: [_jsxs("p", { className: "font-medium", children: ["Unknown component type: ", _jsx("strong", { children: evaluatedSchema.type })] }), lazyError && (_jsxs("p", { className: "text-xs mt-1", children: ["Failed to load plugin: ", lazyError.message] })), globalThis.process?.env?.NODE_ENV !== 'production' && (_jsxs("p", { className: "text-xs mt-1", children: ["\uD83D\uDCA1 ", errorInfo.suggestion, " (OBJUI-001)"] })), _jsx("pre", { className: "text-xs mt-2 overflow-auto", children: JSON.stringify(evaluatedSchema, null, 2) })] }));
|
|
141
158
|
}
|
|
142
159
|
// Note: We don't forward the ref to the Component because components in the registry
|
|
143
160
|
// may not support refs. The SchemaRenderer itself can still receive refs for its own use.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React bindings and SchemaRenderer component for Object UI",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@objectstack/spec": "^4.0.4",
|
|
28
28
|
"react-hook-form": "^7.75.0",
|
|
29
|
-
"@object-ui/core": "3.
|
|
30
|
-
"@object-ui/data-objectstack": "3.
|
|
31
|
-
"@object-ui/i18n": "3.
|
|
32
|
-
"@object-ui/types": "3.
|
|
29
|
+
"@object-ui/core": "3.4.0",
|
|
30
|
+
"@object-ui/data-objectstack": "3.4.0",
|
|
31
|
+
"@object-ui/i18n": "3.4.0",
|
|
32
|
+
"@object-ui/types": "3.4.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|