mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
extend metadata and set category annotation to core components
This commit is contained in:
parent
f68207c91c
commit
a722dcc34a
@ -25,7 +25,7 @@
|
|||||||
"linebreak-style": ["error", "unix"],
|
"linebreak-style": ["error", "unix"],
|
||||||
"no-case-declarations": "off",
|
"no-case-declarations": "off",
|
||||||
"no-use-before-define": "off",
|
"no-use-before-define": "off",
|
||||||
"no-unused-vars":"off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-unused-vars": ["error"],
|
"@typescript-eslint/no-unused-vars": ["error"],
|
||||||
"comma-dangle": "off",
|
"comma-dangle": "off",
|
||||||
"space-before-function-paren": "off",
|
"space-before-function-paren": "off",
|
||||||
@ -33,6 +33,7 @@
|
|||||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
"@typescript-eslint/ban-types": "off",
|
||||||
"react/prop-types": "off",
|
"react/prop-types": "off",
|
||||||
"react/display-name": "off",
|
"react/display-name": "off",
|
||||||
"react/jsx-uses-react": "off",
|
"react/jsx-uses-react": "off",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import {
|
import {
|
||||||
Tabs as BaseTabs,
|
Tabs as BaseTabs,
|
||||||
@ -74,7 +74,9 @@ export default implementRuntimeComponent({
|
|||||||
</TabList>
|
</TabList>
|
||||||
<TabPanels>
|
<TabPanels>
|
||||||
{tabNames.map((_, idx) => {
|
{tabNames.map((_, idx) => {
|
||||||
const ele = slotsElements.content ? ([] as React.ReactElement[]).concat(slotsElements.content)[idx] : placeholder;
|
const ele = slotsElements.content
|
||||||
|
? ([] as React.ReactElement[]).concat(slotsElements.content)[idx]
|
||||||
|
: placeholder;
|
||||||
return (
|
return (
|
||||||
<TabPanel
|
<TabPanel
|
||||||
key={idx}
|
key={idx}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import { JSONSchema7 } from 'json-schema';
|
import { JSONSchema7 } from 'json-schema';
|
||||||
import { parseVersion } from './version';
|
import { parseVersion, Version } from './version';
|
||||||
import { ComponentMetadata } from './metadata';
|
import { ComponentMetadata } from './metadata';
|
||||||
import { MethodSchema } from './method';
|
import { MethodSchema } from './method';
|
||||||
import { Version } from './version';
|
|
||||||
|
|
||||||
// TODO: (type-safe), rename version 2 to normal version
|
|
||||||
|
|
||||||
type ComponentSpec<
|
type ComponentSpec<
|
||||||
KMethodName extends string,
|
KMethodName extends string,
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
export type Metadata = {
|
export type Metadata<TAnnotations = Record<string, unknown>> = {
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
annotations?: Record<string, any> & TAnnotations;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ComponentMetadata = Metadata & {
|
type ComponentCategory =
|
||||||
|
| (string & {})
|
||||||
|
| 'Layout'
|
||||||
|
| 'Input'
|
||||||
|
| 'Display'
|
||||||
|
| 'Advance'
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
export type ComponentMetadata = Metadata<{ category?: ComponentCategory }> & {
|
||||||
|
// TODO:(yanzhen): move to annotations
|
||||||
isDraggable: boolean;
|
isDraggable: boolean;
|
||||||
isResizable: boolean;
|
isResizable: boolean;
|
||||||
displayName: string;
|
displayName: string;
|
||||||
|
@ -134,6 +134,7 @@ const SchemaField: React.FC<Props> = props => {
|
|||||||
return (
|
return (
|
||||||
<DefaultTemplate
|
<DefaultTemplate
|
||||||
label={label}
|
label={label}
|
||||||
|
description={schema.description}
|
||||||
displayLabel={displayLabel}
|
displayLabel={displayLabel}
|
||||||
codeMode={codeMode}
|
codeMode={codeMode}
|
||||||
isExpression={isExpression}
|
isExpression={isExpression}
|
||||||
|
@ -12,6 +12,9 @@ export default implementRuntimeComponent({
|
|||||||
isResizable: false,
|
isResizable: false,
|
||||||
exampleProperties: {},
|
exampleProperties: {},
|
||||||
exampleSize: [1, 1],
|
exampleSize: [1, 1],
|
||||||
|
annotations: {
|
||||||
|
category: 'Advance',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
properties: Type.Object({}),
|
properties: Type.Object({}),
|
||||||
|
@ -31,6 +31,9 @@ export default implementRuntimeComponent({
|
|||||||
layout: [],
|
layout: [],
|
||||||
},
|
},
|
||||||
exampleSize: [6, 6],
|
exampleSize: [6, 6],
|
||||||
|
annotations: {
|
||||||
|
category: 'Layout',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
properties: PropsSchema,
|
properties: PropsSchema,
|
||||||
|
@ -3,50 +3,46 @@ import { ModuleSchema } from '../../types';
|
|||||||
import { ModuleRenderer } from '../_internal/ModuleRenderer';
|
import { ModuleRenderer } from '../_internal/ModuleRenderer';
|
||||||
|
|
||||||
export default implementRuntimeComponent({
|
export default implementRuntimeComponent({
|
||||||
version: 'core/v1',
|
version: 'core/v1',
|
||||||
metadata: {
|
metadata: {
|
||||||
name: 'moduleContainer',
|
name: 'moduleContainer',
|
||||||
displayName: 'ModuleContainer',
|
displayName: 'ModuleContainer',
|
||||||
description: 'ModuleContainer component',
|
description: 'ModuleContainer component',
|
||||||
isDraggable: true,
|
isDraggable: true,
|
||||||
isResizable: true,
|
isResizable: true,
|
||||||
exampleProperties: {
|
exampleProperties: {
|
||||||
id: 'myModule',
|
id: 'myModule',
|
||||||
type: 'custom/v1/module',
|
type: 'custom/v1/module',
|
||||||
},
|
|
||||||
exampleSize: [6, 6],
|
|
||||||
},
|
},
|
||||||
spec: {
|
exampleSize: [6, 6],
|
||||||
properties: ModuleSchema,
|
annotations: {
|
||||||
state: {},
|
category: 'Advance',
|
||||||
methods: {},
|
|
||||||
slots: [],
|
|
||||||
styleSlots: [],
|
|
||||||
events: [],
|
|
||||||
},
|
},
|
||||||
})(({
|
},
|
||||||
id,
|
spec: {
|
||||||
type,
|
properties: ModuleSchema,
|
||||||
properties,
|
state: {},
|
||||||
handlers,
|
methods: {},
|
||||||
services,
|
slots: [],
|
||||||
app
|
styleSlots: [],
|
||||||
}) => {
|
events: [],
|
||||||
if (!type) {
|
},
|
||||||
return <span>Please choose a module to render.</span>
|
})(({ id, type, properties, handlers, services, app }) => {
|
||||||
}
|
if (!type) {
|
||||||
if (!id) {
|
return <span>Please choose a module to render.</span>;
|
||||||
return <span>Please set a id for module.</span>
|
}
|
||||||
}
|
if (!id) {
|
||||||
|
return <span>Please set a id for module.</span>;
|
||||||
return (
|
}
|
||||||
<ModuleRenderer
|
|
||||||
id={id}
|
return (
|
||||||
type={type}
|
<ModuleRenderer
|
||||||
properties={properties}
|
id={id}
|
||||||
handlers={handlers}
|
type={type}
|
||||||
services={services}
|
properties={properties}
|
||||||
app={app}
|
handlers={handlers}
|
||||||
/>
|
services={services}
|
||||||
);
|
app={app}
|
||||||
})
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
@ -25,6 +25,9 @@ export default implementRuntimeComponent({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
exampleSize: [4, 1],
|
exampleSize: [4, 1],
|
||||||
|
annotations: {
|
||||||
|
category: 'Display',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
properties: PropsSchema,
|
properties: PropsSchema,
|
||||||
|
Loading…
Reference in New Issue
Block a user