mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
fix typo: hanlder => handler
This commit is contained in:
parent
46137aa8d2
commit
2df5395665
@ -5,7 +5,7 @@ import {
|
||||
SlotName,
|
||||
TraitType,
|
||||
} from '../../src/AppModel/IAppModel';
|
||||
import { AppSchema, EventHanlderMockSchema } from './mock';
|
||||
import { AppSchema, EventHandlerMockSchema } from './mock';
|
||||
import { produce } from 'immer';
|
||||
import { get } from 'lodash-es';
|
||||
import { registry } from '../sevices';
|
||||
@ -58,7 +58,7 @@ describe('update component property', () => {
|
||||
});
|
||||
|
||||
describe('update event trait handlers(array) property', () => {
|
||||
const appModel = new AppModel(EventHanlderMockSchema, registry);
|
||||
const appModel = new AppModel(EventHandlerMockSchema, registry);
|
||||
const button1 = appModel.getComponentById('button1' as any)!;
|
||||
const oldHandlers = button1.traits[0].rawProperties.handlers;
|
||||
const newHandlers = produce(oldHandlers, (draft: any) => {
|
||||
|
@ -149,7 +149,7 @@ export const DuplicatedIdSchema: ComponentSchema[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const EventHanlderMockSchema: ComponentSchema[] = [
|
||||
export const EventHandlerMockSchema: ComponentSchema[] = [
|
||||
{
|
||||
id: 'button1',
|
||||
type: 'chakra_ui/v1/button',
|
||||
|
@ -24,7 +24,7 @@ import { ComponentId } from '../../../AppModel/IAppModel';
|
||||
type Props = {
|
||||
eventTypes: readonly string[];
|
||||
handler: Static<typeof EventHandlerSchema>;
|
||||
onChange: (hanlder: Static<typeof EventHandlerSchema>) => void;
|
||||
onChange: (handler: Static<typeof EventHandlerSchema>) => void;
|
||||
onRemove: () => void;
|
||||
hideEventType?: boolean;
|
||||
services: EditorServices;
|
||||
|
@ -72,7 +72,7 @@ export const EventTraitForm: React.FC<Props> = props => {
|
||||
(handlers || []).map((h, i) => {
|
||||
const onChange = (handler: EventHandler) => {
|
||||
const index = component.traits.findIndex(t => t.type === 'core/v1/event');
|
||||
const newHanlders = produce(handlers!, draft => {
|
||||
const newHandlers = produce(handlers!, draft => {
|
||||
draft[i] = handler;
|
||||
});
|
||||
eventBus.send(
|
||||
@ -81,7 +81,7 @@ export const EventTraitForm: React.FC<Props> = props => {
|
||||
componentId: component.id,
|
||||
traitIndex: index,
|
||||
properties: {
|
||||
handlers: newHanlders
|
||||
handlers: newHandlers
|
||||
}
|
||||
})
|
||||
);
|
||||
@ -89,7 +89,7 @@ export const EventTraitForm: React.FC<Props> = props => {
|
||||
|
||||
const onRemove = () => {
|
||||
const index = component.traits.findIndex(t => t.type === 'core/v1/event');
|
||||
const newHanlders = produce(handlers!, draft => {
|
||||
const newHandlers = produce(handlers!, draft => {
|
||||
draft.splice(i, 1);
|
||||
});
|
||||
eventBus.send(
|
||||
@ -98,7 +98,7 @@ export const EventTraitForm: React.FC<Props> = props => {
|
||||
componentId: component.id,
|
||||
traitIndex: index,
|
||||
properties: {
|
||||
handlers: newHanlders
|
||||
handlers: newHandlers
|
||||
}
|
||||
})
|
||||
);
|
||||
|
@ -18,7 +18,7 @@ import './styles.css';
|
||||
type SunmaoUIEditorProps = {
|
||||
libs?: SunmaoLib[];
|
||||
runtimeProps?: SunmaoUIRuntimeProps;
|
||||
storageHanlder?: StorageHandler;
|
||||
storageHandler?: StorageHandler;
|
||||
defaultApplication?: Application;
|
||||
defaultModules?: Module[];
|
||||
};
|
||||
@ -64,7 +64,7 @@ export function initSunmaoUIEditor(props: SunmaoUIEditorProps = {}) {
|
||||
const appStorage = new AppStorage(
|
||||
props.defaultApplication,
|
||||
props.defaultModules,
|
||||
props.storageHanlder
|
||||
props.storageHandler
|
||||
);
|
||||
const appModelManager = new AppModelManager(
|
||||
eventBus,
|
||||
|
@ -15,7 +15,7 @@ type Options = Partial<{
|
||||
const lsManager = new LocalStorageManager();
|
||||
const { Editor, registry } = initSunmaoUIEditor({
|
||||
libs: [sunmaoChakraUILib],
|
||||
storageHanlder: {
|
||||
storageHandler: {
|
||||
onSaveApp(app) {
|
||||
lsManager.saveAppInLS(app);
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ export class AppStorage {
|
||||
constructor(
|
||||
defaultApplication?: Application,
|
||||
defaultModules?: Module[],
|
||||
private storageHanlder?: StorageHandler
|
||||
private storageHandler?: StorageHandler
|
||||
) {
|
||||
this.app = defaultApplication || EmptyAppSchema;
|
||||
this.modules = defaultModules || [];
|
||||
@ -123,12 +123,12 @@ export class AppStorage {
|
||||
}
|
||||
|
||||
private saveApplication() {
|
||||
this.storageHanlder?.onSaveApp && this.storageHanlder?.onSaveApp(toJS(this.app));
|
||||
this.storageHandler?.onSaveApp && this.storageHandler?.onSaveApp(toJS(this.app));
|
||||
}
|
||||
|
||||
private saveModules() {
|
||||
const modules = this.modules.map(addModuleId);
|
||||
this.storageHanlder?.onSaveModules && this.storageHanlder?.onSaveModules(modules);
|
||||
this.storageHandler?.onSaveModules && this.storageHandler?.onSaveModules(modules);
|
||||
}
|
||||
|
||||
setApp(app: Application) {
|
||||
|
Loading…
Reference in New Issue
Block a user