mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-21 03:15:49 +08:00
move appModel to root dir
This commit is contained in:
parent
26300bff0c
commit
6bcee65a54
@ -1,8 +1,8 @@
|
||||
import { ApplicationModel } from '../../src/operations/AppModel/AppModel';
|
||||
import { ApplicationModel } from '../../src/AppModel/AppModel';
|
||||
import {
|
||||
ComponentId,
|
||||
ComponentType,
|
||||
} from '../../src/operations/AppModel/IAppModel';
|
||||
} from '../../src/AppModel/IAppModel';
|
||||
import {AppSchema} from './schema'
|
||||
|
||||
describe('AppModel test', () => {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { ApplicationModel } from '../../src/operations/AppModel/AppModel';
|
||||
import { ApplicationModel } from '../../src/AppModel/AppModel';
|
||||
import {
|
||||
ComponentId,
|
||||
ComponentType,
|
||||
SlotName,
|
||||
TraitType,
|
||||
} from '../../src/operations/AppModel/IAppModel';
|
||||
} from '../../src/AppModel/IAppModel';
|
||||
import { AppSchema } from './schema';
|
||||
|
||||
describe('ComponentModel test', () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ApplicationComponent, RuntimeComponentSpec } from '@sunmao-ui/core';
|
||||
import { registry } from '../../setup';
|
||||
import { ApplicationComponent, MethodSchema, RuntimeComponentSpec } from '@sunmao-ui/core';
|
||||
import { registry } from '../setup';
|
||||
import { genComponent, genTrait } from './utils';
|
||||
import {
|
||||
ComponentId,
|
||||
@ -8,7 +8,6 @@ import {
|
||||
IComponentModel,
|
||||
SlotName,
|
||||
StyleSlotName,
|
||||
MethodName,
|
||||
StateKey,
|
||||
ITraitModel,
|
||||
IFieldModel,
|
||||
@ -76,10 +75,10 @@ export class ComponentModel implements IComponentModel {
|
||||
|
||||
get methods() {
|
||||
if (!this.spec) return [];
|
||||
const componentMethods = this.spec.spec.methods as any;
|
||||
const traitMethods: MethodName[] = this.traits.reduce(
|
||||
const componentMethods = this.spec.spec.methods;
|
||||
const traitMethods: MethodSchema[] = this.traits.reduce(
|
||||
(acc, t) => acc.concat(t.methods),
|
||||
[] as any
|
||||
[] as MethodSchema[]
|
||||
);
|
||||
return [...componentMethods, ...traitMethods];
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { JSONSchema7 } from 'json-schema';
|
||||
import { ApplicationComponent, ComponentTrait } from '@sunmao-ui/core';
|
||||
import { ApplicationComponent, ComponentTrait, MethodSchema } from '@sunmao-ui/core';
|
||||
|
||||
export type ComponentId = string & {
|
||||
kind: 'componentId';
|
||||
@ -68,7 +67,7 @@ export interface IComponentModel {
|
||||
stateKeys: StateKey[];
|
||||
slots: SlotName[];
|
||||
styleSlots: StyleSlotName[];
|
||||
methods: Array<{name: MethodName, parameters: JSONSchema7}>;
|
||||
methods: MethodSchema[];
|
||||
events: EventName[];
|
||||
allComponents: IComponentModel[];
|
||||
nextSilbing: IComponentModel | null;
|
||||
@ -98,7 +97,7 @@ export interface ITraitModel {
|
||||
type: TraitType;
|
||||
rawProperties: Record<string, any>;
|
||||
properties: Record<string, IFieldModel>;
|
||||
methods: Array<{name: MethodName, parameters: JSONSchema7}>;
|
||||
methods: MethodSchema[];
|
||||
stateKeys: StateKey[];
|
||||
_isDirty: boolean;
|
||||
toSchema(): ComponentTrait;
|
@ -1,8 +1,7 @@
|
||||
import { ComponentTrait, RuntimeTraitSpec } from '@sunmao-ui/core';
|
||||
import { registry } from '../../setup';
|
||||
import { registry } from '../setup';
|
||||
import {
|
||||
IComponentModel,
|
||||
MethodName,
|
||||
TraitType,
|
||||
ITraitModel,
|
||||
IFieldModel,
|
||||
@ -44,7 +43,7 @@ export class TraitModel implements ITraitModel {
|
||||
}
|
||||
|
||||
get methods() {
|
||||
return this.spec ? this.spec.spec.methods as any : []
|
||||
return this.spec ? this.spec.spec.methods : []
|
||||
}
|
||||
|
||||
get stateKeys() {
|
@ -1,5 +1,5 @@
|
||||
import { ApplicationComponent, ComponentTrait } from '@sunmao-ui/core';
|
||||
import { registry } from '../../setup';
|
||||
import { registry } from '../setup';
|
||||
|
||||
export function genComponent(
|
||||
type: string,
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import produce from 'immer';
|
||||
import { ComponentId, SlotName } from '../AppModel/IAppModel';
|
||||
import { ComponentId, SlotName } from '../../AppModel/IAppModel';
|
||||
import {
|
||||
CreateComponentLeafOperation,
|
||||
ModifyComponentPropertiesLeafOperation,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import produce from 'immer';
|
||||
import { ApplicationModel } from '../AppModel/AppModel';
|
||||
import { ComponentId } from '../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import {
|
||||
ModifyComponentPropertiesLeafOperation,
|
||||
RemoveComponentLeafOperation,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
export type AdjustComponentOrderLeafOperationContext = {
|
||||
orientation: 'up' | 'down';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId, ComponentType, IComponentModel, SlotName } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId, ComponentType, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type CreateComponentLeafOperationContext = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type ModifyComponentIdLeafOperationContext = {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
import _ from 'lodash-es';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../../AppModel/IAppModel';
|
||||
export type ModifyComponentPropertiesLeafOperationContext = {
|
||||
componentId: string;
|
||||
properties: Record<string, any | (<T = any>(prev: T) => T)>;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId, IComponentModel, SlotName } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type PasteComponentLeafOperationContext = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId, IComponentModel, SlotName } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type RemoveComponentLeafOperationContext = {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId, TraitId, TraitType } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId, TraitId, TraitType } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type CreateTraitLeafOperationContext = {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import _ from 'lodash-es';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId } from '../../../AppModel/IAppModel';
|
||||
|
||||
export type ModifyTraitPropertiesLeafOperationContext = {
|
||||
componentId: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { ApplicationModel } from '../../AppModel/AppModel';
|
||||
import { ComponentId, ITraitModel } from '../../AppModel/IAppModel';
|
||||
import { ApplicationModel } from '../../../AppModel/AppModel';
|
||||
import { ComponentId, ITraitModel } from '../../../AppModel/IAppModel';
|
||||
import { BaseLeafOperation } from '../../type';
|
||||
|
||||
export type RemoveTraitLeafOperationContext = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ApplicationComponent, RuntimeComponentSpec } from '@sunmao-ui/core';
|
||||
import { Registry } from '@sunmao-ui/runtime';
|
||||
import Ajv from 'ajv';
|
||||
import { ApplicationModel } from '../operations/AppModel/AppModel';
|
||||
import { ApplicationModel } from '../AppModel/AppModel';
|
||||
import {
|
||||
ISchemaValidator,
|
||||
ComponentValidatorRule,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ApplicationComponent } from '@sunmao-ui/core';
|
||||
import { Registry } from '@sunmao-ui/runtime';
|
||||
import Ajv, { ValidateFunction } from 'ajv';
|
||||
import { IApplicationModel, IComponentModel, ITraitModel } from '../operations/AppModel/IAppModel';
|
||||
import { IApplicationModel, IComponentModel, ITraitModel } from '../AppModel/IAppModel';
|
||||
|
||||
export interface ValidatorMap {
|
||||
components: Record<string, ValidateFunction>;
|
||||
@ -12,7 +12,7 @@ interface BaseValidateContext {
|
||||
validators: ValidatorMap;
|
||||
registry: Registry;
|
||||
appModel: IApplicationModel;
|
||||
ajv: Ajv
|
||||
ajv: Ajv;
|
||||
}
|
||||
|
||||
export interface ComponentValidateContext extends BaseValidateContext {
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
} from '../interfaces';
|
||||
import { EventHandlerSchema } from '@sunmao-ui/runtime';
|
||||
import { isExpression } from '../utils';
|
||||
import { ComponentId, EventName } from '../../operations/AppModel/IAppModel';
|
||||
import { ComponentId, EventName } from '../../AppModel/IAppModel';
|
||||
|
||||
class TraitPropertyValidatorRule implements TraitValidatorRule {
|
||||
kind: 'trait' = 'trait';
|
||||
|
Loading…
Reference in New Issue
Block a user