feat: upgrade formily and fix type check errors
This commit is contained in:
parent
ce63f0fbe6
commit
e9ddd4fd7e
@ -34,7 +34,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
||||
"@typescript-eslint/parser": "^4.8.2",
|
||||
"@umijs/plugin-antd": "^0.9.1",
|
||||
"antd": "^4.16.3",
|
||||
"antd": "^4.16.11",
|
||||
"dotenv": "^8.2.0",
|
||||
"dumi": "^1.1.16",
|
||||
"eslint": "^7.4.0",
|
||||
|
@ -1,6 +1,4 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
|
||||
export const login: ISchema = {
|
||||
export const login = {
|
||||
key: 'dtf9j0b8p9u',
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
@ -21,9 +21,9 @@
|
||||
"@antv/g2plot": "^2.3.27",
|
||||
"@dnd-kit/core": "^3.1.1",
|
||||
"@dnd-kit/sortable": "^4.0.0",
|
||||
"@formily/antd": "^2.0.0-beta.72",
|
||||
"@formily/core": "^2.0.0-beta.72",
|
||||
"@formily/react": "^2.0.0-beta.72",
|
||||
"@formily/antd": "^2.0.0-rc.1",
|
||||
"@formily/core": "^2.0.0-rc.1",
|
||||
"@formily/react": "^2.0.0-rc.1",
|
||||
"@monaco-editor/react": "^4.2.1",
|
||||
"ahooks": "^2.10.2",
|
||||
"axios": "^0.21.1",
|
||||
|
@ -1,10 +1,11 @@
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { Button } from 'antd';
|
||||
import { SchemaRenderer } from '../schema-renderer';
|
||||
import { ISchema, useForm } from '@formily/react';
|
||||
import { useForm } from '@formily/react';
|
||||
import { Resource } from '../../resource';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { VisibleContext } from '../../context';
|
||||
import { ISchema } from '../../schemas';
|
||||
|
||||
const useResource = ({ onSuccess }) => {
|
||||
const resource = Resource.make({
|
||||
|
@ -11,11 +11,12 @@ import { Resource } from '../../../resource';
|
||||
import { TableRowContext, useTable } from '../../../schemas/table';
|
||||
import { useRequest } from 'ahooks';
|
||||
import { VisibleContext } from '../../../context';
|
||||
import { connect, ISchema, observer, useForm } from '@formily/react';
|
||||
import { connect, observer, useForm } from '@formily/react';
|
||||
import { DescriptionsContext } from '../../../schemas/form';
|
||||
import { createContext } from 'react';
|
||||
import { ActionPermissionField } from './ActionPermissionField';
|
||||
import { MenuPermissionTable } from './MenuPermissionTable';
|
||||
import { ISchema } from '../../../';
|
||||
|
||||
export const RoleContext = createContext(null);
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { useCollectionsContext } from '../../constate/Collections';
|
||||
export const useAsyncDataSource = (service: any) => (field: any) => {
|
||||
field.loading = true;
|
||||
service(field).then(
|
||||
action((data: any) => {
|
||||
action.bound((data: any) => {
|
||||
field.dataSource = data;
|
||||
field.loading = false;
|
||||
}),
|
||||
|
@ -2,7 +2,6 @@ import { createForm } from '@formily/core';
|
||||
import {
|
||||
createSchemaField,
|
||||
FormProvider,
|
||||
ISchema,
|
||||
Schema,
|
||||
SchemaOptionsContext,
|
||||
useFieldSchema,
|
||||
@ -54,6 +53,7 @@ import { Page } from '../../schemas/page';
|
||||
import { Chart } from '../../schemas/chart';
|
||||
import { useDesignableSwitchContext } from '../../constate/DesignableSwitch';
|
||||
import { action } from '@formily/reactive';
|
||||
import { ISchema, FormilyISchema } from '../../schemas';
|
||||
|
||||
export const BlockContext = createContext({ dragRef: null });
|
||||
|
||||
@ -67,7 +67,7 @@ interface DesignableContextProps {
|
||||
export const useAsyncDataSource = (service: any) => (field: any) => {
|
||||
field.loading = true;
|
||||
service(field).then(
|
||||
action((data: any) => {
|
||||
action.bound((data: any) => {
|
||||
field.dataSource = data;
|
||||
field.loading = false;
|
||||
}),
|
||||
@ -163,7 +163,7 @@ export function findPropertyByPath(schema: Schema, path?: any): Schema {
|
||||
return property;
|
||||
}
|
||||
|
||||
export function addPropertyBefore(target: Schema, data: ISchema) {
|
||||
export function addPropertyBefore(target: Schema, data: ISchema | FormilyISchema) {
|
||||
Object.keys(target.parent.properties).forEach((name) => {
|
||||
if (name === target.name) {
|
||||
target.parent.addProperty(data.name, data);
|
||||
@ -174,7 +174,7 @@ export function addPropertyBefore(target: Schema, data: ISchema) {
|
||||
});
|
||||
}
|
||||
|
||||
export function addPropertyAfter(target: Schema, data: ISchema) {
|
||||
export function addPropertyAfter(target: Schema, data: ISchema | FormilyISchema) {
|
||||
Object.keys(target.parent.properties).forEach((name) => {
|
||||
const property = target.parent.properties[name];
|
||||
property.parent.removeProperty(property.name);
|
||||
@ -185,7 +185,7 @@ export function addPropertyAfter(target: Schema, data: ISchema) {
|
||||
});
|
||||
}
|
||||
|
||||
function setKeys(schema: ISchema, parentKey = null) {
|
||||
function setKeys(schema: ISchema | FormilyISchema, parentKey = null) {
|
||||
if (!schema['key']) {
|
||||
schema['key'] = uid();
|
||||
}
|
||||
@ -235,7 +235,7 @@ export function useDesignable(path?: any) {
|
||||
DesignableBar,
|
||||
schema: currentSchema,
|
||||
refresh,
|
||||
prepend: (property: ISchema, targetPath?: any): Schema => {
|
||||
prepend: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {
|
||||
let target = currentSchema;
|
||||
if (targetPath) {
|
||||
target = findPropertyByPath(schema, targetPath);
|
||||
@ -267,7 +267,7 @@ export function useDesignable(path?: any) {
|
||||
refresh();
|
||||
return target.properties[property.name];
|
||||
},
|
||||
appendChild: (property: ISchema, targetPath?: any): Schema => {
|
||||
appendChild: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {
|
||||
let target = currentSchema;
|
||||
if (targetPath) {
|
||||
target = findPropertyByPath(schema, targetPath);
|
||||
@ -294,7 +294,7 @@ export function useDesignable(path?: any) {
|
||||
refresh();
|
||||
return target.properties[property.name];
|
||||
},
|
||||
insertAfter: (property: ISchema, targetPath?: any): Schema => {
|
||||
insertAfter: (property: ISchema | FormilyISchema, targetPath?: any): Schema => {
|
||||
let target = currentSchema;
|
||||
if (targetPath) {
|
||||
target = findPropertyByPath(schema, targetPath);
|
||||
@ -316,7 +316,7 @@ export function useDesignable(path?: any) {
|
||||
refresh();
|
||||
return target.parent.properties[property.name];
|
||||
},
|
||||
insertBefore(property: ISchema, targetPath?: any): Schema {
|
||||
insertBefore(property: ISchema | FormilyISchema, targetPath?: any): Schema {
|
||||
let target = currentSchema;
|
||||
if (targetPath) {
|
||||
target = findPropertyByPath(schema, targetPath);
|
||||
@ -380,7 +380,7 @@ export function useDesignable(path?: any) {
|
||||
},
|
||||
moveToBefore(path1, path2) {
|
||||
const source = findPropertyByPath(schema, path1);
|
||||
const property = source.toJSON();
|
||||
const property = source.toJSON() as ISchema;
|
||||
const target = findPropertyByPath(schema, path2);
|
||||
if (!target) {
|
||||
console.error('target schema does not exist.');
|
||||
@ -400,7 +400,7 @@ export function useDesignable(path?: any) {
|
||||
},
|
||||
moveToAfter(path1, path2) {
|
||||
const source = findPropertyByPath(schema, path1);
|
||||
const property = source.toJSON();
|
||||
const property = source.toJSON() as ISchema;
|
||||
const target = findPropertyByPath(schema, path2);
|
||||
if (!target) {
|
||||
console.error('target schema does not exist.');
|
||||
@ -495,7 +495,7 @@ const CodePreview = ({ schema }) => {
|
||||
};
|
||||
|
||||
export interface SchemaRendererProps {
|
||||
schema: Schema | ISchema;
|
||||
schema: Schema | ISchema | FormilyISchema;
|
||||
form?: any;
|
||||
render?: any;
|
||||
components?: any;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { DndContext, DragOverlay } from '@dnd-kit/core';
|
||||
import { ISchema, observer, RecursionField, Schema } from '@formily/react';
|
||||
import { observer, RecursionField, Schema } from '@formily/react';
|
||||
import React, { useState } from 'react';
|
||||
import { createSchema, removeSchema, updateSchema } from '..';
|
||||
import { createSchema, ISchema, removeSchema, updateSchema } from '..';
|
||||
import {
|
||||
findPropertyByPath,
|
||||
getSchemaPath,
|
||||
|
@ -15,7 +15,6 @@ import {
|
||||
useFieldSchema,
|
||||
RecursionField,
|
||||
Schema,
|
||||
ISchema,
|
||||
useForm,
|
||||
} from '@formily/react';
|
||||
import {
|
||||
@ -51,6 +50,7 @@ import {
|
||||
createCollectionField,
|
||||
createOrUpdateCollection,
|
||||
createSchema,
|
||||
ISchema,
|
||||
removeSchema,
|
||||
useDesignable,
|
||||
useSchemaPath,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { FieldOptions } from '.';
|
||||
import { defaultProps } from './properties';
|
||||
|
||||
export const attachment: ISchema = {
|
||||
export const attachment: FieldOptions = {
|
||||
name: 'attachment',
|
||||
type: 'object',
|
||||
group: 'media',
|
||||
@ -16,7 +16,7 @@ export const attachment: ISchema = {
|
||||
'x-component': 'Upload.Attachment',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Upload.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { omit } from 'lodash';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const checkbox: ISchema = {
|
||||
export const checkbox: FieldOptions = {
|
||||
name: 'checkbox',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -17,7 +16,7 @@ export const checkbox: ISchema = {
|
||||
'x-component': 'Checkbox',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Checkbox.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { multipleSelect } from './multipleSelect';
|
||||
import { defaultProps, dataSource } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const checkboxGroup: ISchema = {
|
||||
export const checkboxGroup: FieldOptions = {
|
||||
name: 'checkboxGroup',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -18,7 +18,7 @@ export const checkboxGroup: ISchema = {
|
||||
'x-component': 'Checkbox.Group',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Checkbox.Group.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const chinaRegion: ISchema = {
|
||||
export const chinaRegion: FieldOptions = {
|
||||
name: 'chinaRegion',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -19,7 +19,7 @@ export const chinaRegion: ISchema = {
|
||||
'x-component-props': {},
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Cascader.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { datetime } from './datetime';
|
||||
import { dateTimeProps, defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const createdAt: ISchema = {
|
||||
export const createdAt: FieldOptions = {
|
||||
name: 'createdAt',
|
||||
type: 'object',
|
||||
group: 'systemInfo',
|
||||
@ -21,7 +21,7 @@ export const createdAt: ISchema = {
|
||||
'x-read-pretty': true,
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'DatePicker.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const createdBy: ISchema = {
|
||||
export const createdBy: FieldOptions = {
|
||||
name: 'createdBy',
|
||||
type: 'object',
|
||||
group: 'systemInfo',
|
||||
@ -20,7 +21,7 @@ export const createdBy: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-read-pretty': true,
|
||||
'x-designable-bar': 'Select.Drawer.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { dateTimeProps, defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const datetime: ISchema = {
|
||||
export const datetime: FieldOptions = {
|
||||
name: 'datetime',
|
||||
type: 'object',
|
||||
group: 'datetime',
|
||||
@ -20,7 +21,7 @@ export const datetime: ISchema = {
|
||||
},
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'DatePicker.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { string } from './string';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const email: ISchema = {
|
||||
export const email: FieldOptions = {
|
||||
name: 'email',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -19,7 +19,7 @@ export const email: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-validator': 'email',
|
||||
'x-designable-bar': 'Input.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const icon: ISchema = {
|
||||
export const icon: FieldOptions = {
|
||||
name: 'icon',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -16,7 +16,7 @@ export const icon: ISchema = {
|
||||
'x-component': 'IconPicker',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'IconPicker.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,18 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { cloneDeep, set } from 'lodash';
|
||||
import * as types from './types';
|
||||
import { uid } from '@formily/shared';
|
||||
import { ISchema } from '../..';
|
||||
|
||||
interface IDefaultSchema {
|
||||
dataType: string;
|
||||
uiSchema?: ISchema;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface FieldOptions extends ISchema {
|
||||
[key: string]: any;
|
||||
default?: IDefaultSchema;
|
||||
}
|
||||
|
||||
export const interfaces = new Map<string, ISchema>();
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { uid } from '@formily/shared';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const linkTo: ISchema = {
|
||||
export const linkTo: FieldOptions = {
|
||||
name: 'linkTo',
|
||||
type: 'object',
|
||||
group: 'relation',
|
||||
@ -18,7 +18,7 @@ export const linkTo: ISchema = {
|
||||
'x-component-props': {},
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Select.Drawer.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
initialize: (values: any) => {
|
||||
if (values.dataType === 'belongsToMany') {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const markdown: ISchema = {
|
||||
export const markdown: FieldOptions = {
|
||||
name: 'markdown',
|
||||
type: 'object',
|
||||
title: 'Markdown',
|
||||
@ -15,7 +15,7 @@ export const markdown: ISchema = {
|
||||
'x-component': 'Markdown',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Markdown.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps, dataSource } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const multipleSelect: ISchema = {
|
||||
export const multipleSelect: FieldOptions = {
|
||||
name: 'multipleSelect',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -20,7 +20,7 @@ export const multipleSelect: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Select.DesignableBar',
|
||||
enum: [],
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const number: ISchema = {
|
||||
export const number: FieldOptions = {
|
||||
name: 'number',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -21,7 +21,7 @@ export const number: ISchema = {
|
||||
},
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'InputNumber.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const password: ISchema = {
|
||||
export const password: FieldOptions = {
|
||||
name: 'password',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -16,7 +16,7 @@ export const password: ISchema = {
|
||||
'x-component': 'Password',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Password.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { number } from './number';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const percent: ISchema = {
|
||||
export const percent: FieldOptions = {
|
||||
name: 'percent',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -23,7 +23,7 @@ export const percent: ISchema = {
|
||||
},
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'InputNumber.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { string } from './string';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const phone: ISchema = {
|
||||
export const phone: FieldOptions = {
|
||||
name: 'phone',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -19,7 +19,7 @@ export const phone: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
"x-validator": 'phone',
|
||||
'x-designable-bar': 'Input.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps, dataSource } from './properties';
|
||||
import { select } from './select';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const radioGroup: ISchema = {
|
||||
export const radioGroup: FieldOptions = {
|
||||
name: 'radioGroup',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -17,7 +17,7 @@ export const radioGroup: ISchema = {
|
||||
'x-component': 'Radio.Group',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Radio.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps, dataSource } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const select: ISchema = {
|
||||
export const select: FieldOptions = {
|
||||
name: 'select',
|
||||
type: 'object',
|
||||
group: 'choices',
|
||||
@ -17,7 +17,7 @@ export const select: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Select.DesignableBar',
|
||||
enum: [],
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const string: ISchema = {
|
||||
export const string: FieldOptions = {
|
||||
name: 'string',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -18,7 +18,7 @@ export const string: ISchema = {
|
||||
'x-component': 'Input',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'Input.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { uid } from '@formily/shared';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const subTable: ISchema = {
|
||||
export const subTable: FieldOptions = {
|
||||
name: 'subTable',
|
||||
type: 'object',
|
||||
group: 'relation',
|
||||
@ -19,7 +19,7 @@ export const subTable: ISchema = {
|
||||
'x-component-props': {},
|
||||
'x-designable-bar': 'Table.DesignableBar',
|
||||
enum: [],
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
initialize: (values: any) => {
|
||||
if (!values.target) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const textarea: ISchema = {
|
||||
export const textarea: FieldOptions = {
|
||||
name: 'textarea',
|
||||
type: 'object',
|
||||
group: 'basic',
|
||||
@ -16,7 +16,7 @@ export const textarea: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Input.TextArea',
|
||||
'x-designable-bar': 'Input.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const time: ISchema = {
|
||||
export const time: FieldOptions = {
|
||||
name: 'time',
|
||||
type: 'object',
|
||||
group: 'datetime',
|
||||
@ -17,7 +17,7 @@ export const time: ISchema = {
|
||||
'x-component': 'TimePicker',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'TimePicker.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { datetime } from './datetime';
|
||||
import { dateTimeProps, defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const updatedAt: ISchema = {
|
||||
export const updatedAt: FieldOptions = {
|
||||
name: 'updatedAt',
|
||||
type: 'object',
|
||||
group: 'systemInfo',
|
||||
@ -21,7 +21,7 @@ export const updatedAt: ISchema = {
|
||||
'x-read-pretty': true,
|
||||
'x-decorator': 'FormItem',
|
||||
'x-designable-bar': 'DatePicker.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { defaultProps } from './properties';
|
||||
import { FieldOptions } from '.';
|
||||
|
||||
export const updatedBy: ISchema = {
|
||||
export const updatedBy: FieldOptions = {
|
||||
name: 'updatedBy',
|
||||
type: 'object',
|
||||
group: 'systemInfo',
|
||||
@ -20,7 +20,7 @@ export const updatedBy: ISchema = {
|
||||
'x-decorator': 'FormItem',
|
||||
'x-read-pretty': true,
|
||||
'x-designable-bar': 'Select.Drawer.DesignableBar',
|
||||
} as ISchema,
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...defaultProps,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useContext, useMemo, useState } from 'react';
|
||||
import { SchemaField } from '..';
|
||||
import { ISchema, SchemaField } from '..';
|
||||
import {
|
||||
createForm,
|
||||
onFieldChange,
|
||||
@ -12,7 +12,6 @@ import {
|
||||
useFieldSchema,
|
||||
Schema,
|
||||
SchemaOptionsContext,
|
||||
ISchema,
|
||||
SchemaKey,
|
||||
RecursionField,
|
||||
} from '@formily/react';
|
||||
@ -172,6 +171,8 @@ export const FilterItem = (props) => {
|
||||
[],
|
||||
);
|
||||
|
||||
const columnEnum: any = [...columns.values()].map((column) => column.toJSON());
|
||||
|
||||
return (
|
||||
<FormProvider form={form}>
|
||||
<FormLayout layout={'inline'}>
|
||||
@ -195,7 +196,7 @@ export const FilterItem = (props) => {
|
||||
value: 'name',
|
||||
},
|
||||
}}
|
||||
enum={[...columns.values()].map((column) => column.toJSON())}
|
||||
enum={columnEnum}
|
||||
/>
|
||||
<SchemaField.String
|
||||
name="operation"
|
||||
|
@ -7,12 +7,11 @@ import {
|
||||
observer,
|
||||
SchemaExpressionScopeContext,
|
||||
FormProvider,
|
||||
ISchema,
|
||||
useField,
|
||||
useForm,
|
||||
RecursionField,
|
||||
} from '@formily/react';
|
||||
import { useSchemaPath, SchemaField, useDesignable, removeSchema } from '../';
|
||||
import { useSchemaPath, SchemaField, useDesignable, removeSchema, ISchema } from '../';
|
||||
import get from 'lodash/get';
|
||||
import { Button, Dropdown, Menu, message, Space } from 'antd';
|
||||
import { MenuOutlined, DragOutlined } from '@ant-design/icons';
|
||||
@ -78,13 +77,7 @@ const FormMain = (props: any) => {
|
||||
console.log(displayed.map, 'displayed.map', collection?.name);
|
||||
}
|
||||
}, [displayed.map]);
|
||||
const content = (
|
||||
<FormProvider form={form}>
|
||||
{schema['x-decorator'] === 'Form' ? (
|
||||
<SchemaField
|
||||
components={options.components}
|
||||
scope={scope}
|
||||
schema={{
|
||||
const s: ISchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
[schema.name]: {
|
||||
@ -94,7 +87,14 @@ const FormMain = (props: any) => {
|
||||
'x-decorator': 'Form.__Decorator',
|
||||
},
|
||||
},
|
||||
}}
|
||||
}
|
||||
const content = (
|
||||
<FormProvider form={form}>
|
||||
{schema['x-decorator'] === 'Form' ? (
|
||||
<SchemaField
|
||||
components={options.components}
|
||||
scope={scope}
|
||||
schema={s}
|
||||
/>
|
||||
) : (
|
||||
<FormLayout layout={'vertical'} {...others}>
|
||||
@ -196,7 +196,7 @@ Form.Field = observer((props: any) => {
|
||||
'x-decorator': 'FormilyFormItem',
|
||||
},
|
||||
},
|
||||
})
|
||||
} as ISchema)
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { ISchema, observer, Schema, useField } from '@formily/react';
|
||||
import { ISchema as FormilyISchema, observer, Schema, useField } from '@formily/react';
|
||||
import constate from 'constate';
|
||||
import { useState } from 'react';
|
||||
import { createContext } from 'react';
|
||||
@ -8,6 +8,15 @@ import { extend } from 'umi-request';
|
||||
import { isVoidField } from '@formily/core';
|
||||
import { useCookieState, useRequest } from 'ahooks';
|
||||
|
||||
export { FormilyISchema };
|
||||
|
||||
export interface ISchema extends FormilyISchema {
|
||||
[key: string]: any;
|
||||
properties?: {
|
||||
[key: string]: ISchema | FormilyISchema;
|
||||
};
|
||||
}
|
||||
|
||||
export * from '../components/schema-renderer';
|
||||
|
||||
export function useDefaultAction() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ISchema } from '@formily/react';
|
||||
import { uid } from '@formily/shared';
|
||||
import { ISchema } from '..';
|
||||
|
||||
export function generateDefaultSchema(component) {
|
||||
const defaultSchemas: { [key: string]: ISchema } = {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {
|
||||
FormProvider,
|
||||
ISchema,
|
||||
observer,
|
||||
RecursionField,
|
||||
Schema,
|
||||
@ -18,6 +17,7 @@ import {
|
||||
removeSchema,
|
||||
createSchema,
|
||||
createCollectionField,
|
||||
ISchema,
|
||||
} from '..';
|
||||
import { uid } from '@formily/shared';
|
||||
import useRequest from '@ahooksjs/use-request';
|
||||
|
Loading…
Reference in New Issue
Block a user