From 451590b5814468c3591eda47d1a38b6a83eb20b1 Mon Sep 17 00:00:00 2001 From: Bowen Tan Date: Mon, 13 Dec 2021 10:38:01 +0800 Subject: [PATCH] change some components' property to optional --- .../chakra-ui-lib/src/components/Stack.tsx | 32 ++++++++++--------- .../src/components/Table/Table.tsx | 2 +- .../src/components/Table/TableTypes.ts | 4 +-- packages/editor/src/constants.ts | 4 +-- packages/editor/src/validator/rules.ts | 2 ++ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/chakra-ui-lib/src/components/Stack.tsx b/packages/chakra-ui-lib/src/components/Stack.tsx index 45969f3f..a0c1d7f9 100644 --- a/packages/chakra-ui-lib/src/components/Stack.tsx +++ b/packages/chakra-ui-lib/src/components/Stack.tsx @@ -3,16 +3,8 @@ import { Static, Type } from '@sinclair/typebox'; import { Stack as BaseStack } from '@chakra-ui/react'; import { ComponentImplementation, Slot } from '@sunmao-ui/runtime'; -export const DirectionSchema = Type.Union([ - Type.KeyOf( - Type.Object({ - column: Type.String(), - 'column-reverse': Type.String(), - row: Type.String(), - 'row-reverse': Type.String(), - }) - ), - Type.Array( +export const DirectionSchema = Type.Optional( + Type.Union([ Type.KeyOf( Type.Object({ column: Type.String(), @@ -20,16 +12,26 @@ export const DirectionSchema = Type.Union([ row: Type.String(), 'row-reverse': Type.String(), }) - ) - ), -]); -export const FlexWrapSchema = Type.KeyOf( + ), + Type.Array( + Type.KeyOf( + Type.Object({ + column: Type.String(), + 'column-reverse': Type.String(), + row: Type.String(), + 'row-reverse': Type.String(), + }) + ) + ), + ]) +); +export const FlexWrapSchema = Type.Optional(Type.KeyOf( Type.Object({ nowrap: Type.String(), wrap: Type.String(), 'wrap-reverse': Type.String(), }) -); +)); export const AlignItemsSchema = Type.String(); export const JustifyContentSchema = Type.String(); export const SpacingSchema = Type.Union([Type.String(), Type.Number()]); diff --git a/packages/chakra-ui-lib/src/components/Table/Table.tsx b/packages/chakra-ui-lib/src/components/Table/Table.tsx index 382ca35f..730236ed 100644 --- a/packages/chakra-ui-lib/src/components/Table/Table.tsx +++ b/packages/chakra-ui-lib/src/components/Table/Table.tsx @@ -130,7 +130,7 @@ export const TableImpl: ComponentImplementation<{ const tableContent = ( <> - + {isMultiSelect ? allCheckbox : undefined} diff --git a/packages/chakra-ui-lib/src/components/Table/TableTypes.ts b/packages/chakra-ui-lib/src/components/Table/TableTypes.ts index 5e937877..f501c231 100644 --- a/packages/chakra-ui-lib/src/components/Table/TableTypes.ts +++ b/packages/chakra-ui-lib/src/components/Table/TableTypes.ts @@ -4,13 +4,13 @@ import { RuntimeModuleSchema, EventHandlerSchema } from '@sunmao-ui/runtime'; export const MajorKeyPropertySchema = Type.String(); export const RowsPerPagePropertySchema = Type.Number(); export const DataPropertySchema = Type.Array(Type.Any()); -export const TableSizePropertySchema = Type.KeyOf( +export const TableSizePropertySchema = Type.Optional(Type.KeyOf( Type.Object({ sm: Type.String(), md: Type.String(), lg: Type.String(), }) -); +)); export const TdTypeSchema = Type.KeyOf( Type.Object({ diff --git a/packages/editor/src/constants.ts b/packages/editor/src/constants.ts index 50167ef2..c950724c 100644 --- a/packages/editor/src/constants.ts +++ b/packages/editor/src/constants.ts @@ -187,7 +187,7 @@ export const UserCenterApp: Application = { traits: [ { type: 'core/v1/slot', - properties: { container: { id: 'hhhh', slot: 'content' } }, + properties: { container: { id: 'tabs1', slot: 'content' } }, }, ], }, @@ -206,7 +206,7 @@ export const UserCenterApp: Application = { ], }, { - id: 'isUpdateRole', + id: 'isUpdatePosition', type: 'core/v1/dummy', properties: {}, traits: [ diff --git a/packages/editor/src/validator/rules.ts b/packages/editor/src/validator/rules.ts index ee067b65..9e209b5b 100644 --- a/packages/editor/src/validator/rules.ts +++ b/packages/editor/src/validator/rules.ts @@ -80,6 +80,7 @@ export class ComponentPropertyValidatorRule implements ComponentValidatorRule { const validate = ajv.compile(propertySchema); const valid = validate(component.properties); if (!valid) { + console.log('validate.errors', validate.errors) validate.errors!.forEach(error => { let errorMsg = error.message; if (error.keyword === 'type') { @@ -124,6 +125,7 @@ export class TraitPropertyValidatorRule implements TraitValidatorRule { const validate = ajv.compile(propertySchema); const valid = validate(trait.properties); if (!valid) { + console.log('validate.errors', validate.errors) validate.errors!.forEach(error => { let errorMsg = error.message; if (error.keyword === 'type') {