Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion instances/form/complex-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
"socialName": {
"type": "object",
"x-component": "FormField",
"x-custom": true,
"x-ui": {
"order": 5
},
Expand Down
6 changes: 3 additions & 3 deletions packages/adapters/react/src/provider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ScheptaProvider', () => {
it('should provide components configuration', () => {
const componentSpec = createComponentSpec({
id: 'TestComponent',
factory: () => null,
component: () => null,
type: 'field',
});

Expand All @@ -60,13 +60,13 @@ describe('ScheptaProvider', () => {
it('should support nested providers with hierarchical merge', () => {
const ParentComponent = createComponentSpec({
id: 'ParentComponent',
factory: () => null,
component: () => null,
type: 'field',
});

const ChildComponent = createComponentSpec({
id: 'ChildComponent',
factory: () => null,
component: () => null,
type: 'field',
});

Expand Down
4 changes: 4 additions & 0 deletions packages/adapters/react/src/runtime-adapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import type { RuntimeAdapter, ComponentSpec, RenderResult, RendererSpec } from '
*/
export class ReactRuntimeAdapter implements RuntimeAdapter {
create(spec: ComponentSpec | RendererSpec, props: Record<string, any>): RenderResult {
if (spec.component) {
const component = spec.component(props, this);
// If factory returns a React component type, create element
if (typeof component === 'function' || typeof component === 'object') {
return React.createElement(component as any, props);
}
// If it's already an element, return it
return component as RenderResult;
} else {
throw new Error(`Component ${spec.id} is not a function`);
}
}

fragment(children: RenderResult[]): RenderResult {
Expand Down
15 changes: 11 additions & 4 deletions packages/core/src/orchestrators/component-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,19 @@ export function resolveSpec(
const componentName = schema['x-component'] || componentKey;

const isCustomComponent = schema['x-custom'] === true;
let componentSpec = null;
let componentSpec: ComponentSpec | null = null;

if (isCustomComponent && customComponents) {
if (isCustomComponent && customComponents?.[componentKey]) {
componentSpec = customComponents[componentKey];
} else {
componentSpec = components[componentName];
}
if (!componentSpec) {
componentSpec = components[componentName] ?? null;
}

if (componentSpec && isCustomComponent && !customComponents?.[componentKey] && debugEnabled) {
console.warn(
`x-custom is set but no custom component registered for "${componentKey}"; using "${componentName}" from registry.`
);
}

if (!componentSpec) {
Expand Down
153 changes: 147 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions showcases/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>schepta React Example</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<title>Single-SPA + Vite Experiment</title>
<style>
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
sans-serif;
background: #f8f9fa;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<div id="header"></div>
<div id="vanilla"></div>
<script
type="module"
src="/src/main.ts"
></script>
</body>
</html>

Loading