mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-21 03:15:49 +08:00
fix: hide the event type in the API form's handlers
This commit is contained in:
parent
1b1df68fc9
commit
16824e29f7
@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import { EventWidget, mergeWidgetOptionsIntoSchema } from '@sunmao-ui/editor-sdk';
|
||||
import { EventWidget } from '@sunmao-ui/editor-sdk';
|
||||
import { Box, IconButton, VStack } from '@chakra-ui/react';
|
||||
import { Static } from '@sinclair/typebox';
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { CloseIcon } from '@chakra-ui/icons';
|
||||
import { EventHandlerSchema } from '@sunmao-ui/runtime';
|
||||
import { ComponentSchema } from '@sunmao-ui/core';
|
||||
@ -13,19 +14,19 @@ type Props = {
|
||||
handler: Static<typeof EventHandlerSchema>;
|
||||
onChange: (handler: Static<typeof EventHandlerSchema>) => void;
|
||||
onRemove: () => void;
|
||||
hideEventType?: boolean;
|
||||
services: EditorServices;
|
||||
schema?: JSONSchema7;
|
||||
};
|
||||
|
||||
export const EventHandlerForm: React.FC<Props> = props => {
|
||||
const { handler, component, onChange, onRemove, hideEventType, services } = props;
|
||||
const { schema = EventHandlerSchema, handler, component, onChange, onRemove, services } = props;
|
||||
|
||||
return (
|
||||
<Box position="relative" width="100%">
|
||||
<VStack className={formWrapperCSS}>
|
||||
<EventWidget
|
||||
component={component}
|
||||
schema={mergeWidgetOptionsIntoSchema(EventHandlerSchema, { hideEventType })}
|
||||
schema={schema}
|
||||
value={handler}
|
||||
path={[]}
|
||||
level={1}
|
||||
|
@ -19,8 +19,9 @@ import { EventHandlerForm } from '../../ComponentForm/EventTraitForm/EventHandle
|
||||
import {
|
||||
FetchTraitPropertiesSchema,
|
||||
EventCallBackHandlerSchema,
|
||||
BaseEventSchema
|
||||
} from '@sunmao-ui/runtime';
|
||||
import { Static } from '@sinclair/typebox';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { EditorServices } from '../../../types';
|
||||
import { ComponentSchema } from '@sunmao-ui/core';
|
||||
|
||||
@ -94,7 +95,7 @@ export const Basic: React.FC<Props> = props => {
|
||||
<EventHandlerForm
|
||||
component={api}
|
||||
handler={{ type: '', ...handler }}
|
||||
hideEventType={true}
|
||||
schema={Type.Object(BaseEventSchema)}
|
||||
onChange={onChange}
|
||||
onRemove={onRemove}
|
||||
services={services}
|
||||
|
Loading…
Reference in New Issue
Block a user