Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { ActionCard } from '../widgets/ActionCard';
import { UISchema } from './uischema.types';

export const uiSchema: UISchema = {
default: {
'ui:widget': ActionCard,
},
[SDKTypes.EditArray]: {
'ui:widget': ActionCard,
content: data => `${data.changeType} {${data.itemsProperty || '?'}}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import { FC, ComponentClass } from 'react';
import { BaseSchema, SDKTypes } from '@bfc/shared';

export enum UISchemaBuiltinKeys {
default = 'default',
}

/** schema */
export type UISchema = {
[key in SDKTypes]?: UIWidget;
[key in SDKTypes | UISchemaBuiltinKeys]?: UIWidget;
};

/** widget */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ const renderWidget = (inputData, schema: UIWidget, contextProps = {}): JSX.Eleme
return <Widget data={inputData} {...contextProps} {...props} />;
};

const renderFallbackElement = (data: BaseSchema) => <></>;

export const renderSDKType = (data: BaseSchema, context?: { menu: JSX.Element; onClick }): JSX.Element => {
const $type = get(data, '$type');
const schema: UIWidget = get(uiSchema, $type);
if (!schema) return renderFallbackElement(data);
const schema = get(uiSchema, $type, uiSchema.default);

return renderWidget(data, schema, context);
};