From e43da7d0ca24e24fa83a1ffe226fd38372f81368 Mon Sep 17 00:00:00 2001 From: chenos Date: Mon, 29 Nov 2021 11:36:36 +0800 Subject: [PATCH] fix(client): cannot find namespace 'Formily' --- .../admin-layout/Permissions/ActionPermissionField.tsx | 7 ++++--- packages/client/src/schemas/calendar/index.tsx | 4 ++-- packages/client/src/schemas/database-field/index.tsx | 5 +++-- packages/client/src/schemas/display/index.tsx | 9 +++++---- packages/client/src/schemas/input/DesignableBar.tsx | 4 +--- packages/client/src/schemas/select/index.tsx | 2 +- packages/client/src/schemas/table/index.tsx | 8 ++++---- packages/client/src/schemas/upload/index.tsx | 7 ++++--- 8 files changed, 24 insertions(+), 22 deletions(-) diff --git a/packages/client/src/components/admin-layout/Permissions/ActionPermissionField.tsx b/packages/client/src/components/admin-layout/Permissions/ActionPermissionField.tsx index 28c4a8251..36153c0d5 100644 --- a/packages/client/src/components/admin-layout/Permissions/ActionPermissionField.tsx +++ b/packages/client/src/components/admin-layout/Permissions/ActionPermissionField.tsx @@ -19,6 +19,7 @@ import Checkbox from 'antd/lib/checkbox/Checkbox'; import { useState } from 'react'; import { useCompile } from '../../../hooks/useCompile'; import { useTranslation } from 'react-i18next'; +import { ArrayField } from '@formily/core'; const actionTypeMap = new Map( Object.entries({ @@ -30,7 +31,7 @@ const actionTypeMap = new Map( ); const useActionDataSource = () => { - const field = useField(); + const field = useField(); const dataSource = []; for (const [actionName, value] of actionTypeMap) { const item = field?.value?.find((item) => { @@ -50,7 +51,7 @@ const useFieldPermissions = () => { const compile = useCompile(); const role = useContext(RoleContext); const ctx = useContext(TableRowContext); - const field = useField(); + const field = useField(); const [dataSource, setDataSource] = useState([]); const findFieldKeys = (actionName): any[] => { const item = field?.value?.find((item) => { @@ -189,7 +190,7 @@ export const ActionPermissionField = observer((props) => { const compile = useCompile(); const role = useContext(RoleContext); const ctx = useContext(TableRowContext); - const field = useField(); + const field = useField(); const actionDataSource = useActionDataSource(); const { columns, dataSource, service } = useFieldPermissions(); console.log('actionPermissions', field?.value); diff --git a/packages/client/src/schemas/calendar/index.tsx b/packages/client/src/schemas/calendar/index.tsx index 53b8c490c..17561c4fe 100644 --- a/packages/client/src/schemas/calendar/index.tsx +++ b/packages/client/src/schemas/calendar/index.tsx @@ -39,7 +39,7 @@ import { useContext } from 'react'; import { SchemaField, useDesignable } from '../../components/schema-renderer'; import { ActionBar } from './ActionBar'; import { ActionDesignableBar } from './Action'; -import { createForm } from '@formily/core'; +import { ArrayField, createForm } from '@formily/core'; import { get } from 'lodash'; import flatten from 'flat'; import { @@ -145,7 +145,7 @@ const toEvents = (data: any[], fieldNames: any) => { export const Calendar: any = observer((props: any) => { const { t } = useTranslation(); - const field = useField(); + const field = useField(); const { collectionName, fieldNames = {} } = props; console.log('Calendar', props); const { schema } = useDesignable(); diff --git a/packages/client/src/schemas/database-field/index.tsx b/packages/client/src/schemas/database-field/index.tsx index 743d1b18b..730deb809 100644 --- a/packages/client/src/schemas/database-field/index.tsx +++ b/packages/client/src/schemas/database-field/index.tsx @@ -52,6 +52,7 @@ import { import { DndContext, DragOverlay } from '@dnd-kit/core'; import { createPortal } from 'react-dom'; import { useClient } from '../../constate'; +import { ArrayField } from '@formily/core'; interface SelectOptionProps { id: any; @@ -88,7 +89,7 @@ function SelectOption(props: SelectOptionProps) { } export const DatabaseCollection = observer((props) => { - const field = useField(); + const field = useField(); const [visible, setVisible] = useState(false); const [open, setOpen] = useState(false); const schema = useFieldSchema(); @@ -320,7 +321,7 @@ export const DatabaseCollection = observer((props) => { }); export const DatabaseField: any = observer((props) => { - const field = useField(); + const field = useField(); useEffect(() => { if (!field.value) { field.setValue([]); diff --git a/packages/client/src/schemas/display/index.tsx b/packages/client/src/schemas/display/index.tsx index 0874df53f..8c0ce52fe 100644 --- a/packages/client/src/schemas/display/index.tsx +++ b/packages/client/src/schemas/display/index.tsx @@ -20,6 +20,7 @@ import { import { FullscreenOutlined } from '@ant-design/icons'; import moment from 'moment'; import { useCompile } from '../../hooks/useCompile'; +import { Field } from '@formily/core'; const PlaceholderContext = createContext(''); @@ -113,7 +114,7 @@ const TextArea: React.FC = (props) => { }; const Select: React.FC> = observer((props) => { - const field = useField(); + const field = useField(); const prefixCls = usePrefixCls('description-select', props); const dataSource: any[] = field?.dataSource?.length ? field.dataSource @@ -157,7 +158,7 @@ const Select: React.FC> = observer((props) => { }); const ObjectSelect: React.FC> = observer((props) => { - const field = useField(); + const field = useField(); const prefixCls = usePrefixCls('description-select', props); const dataSource: any[] = field?.dataSource?.length ? field.dataSource @@ -201,7 +202,7 @@ const ObjectSelect: React.FC> = observer((props) => { }); const TreeSelect: React.FC> = observer((props) => { - const field = useField(); + const field = useField(); const placeholder = usePlaceholder(); const prefixCls = usePrefixCls('description-tree-select', props); const dataSource = field?.dataSource?.length @@ -259,7 +260,7 @@ const TreeSelect: React.FC> = observer((props) => { }); const Cascader: React.FC = observer((props) => { - const field = useField(); + const field = useField(); const placeholder = usePlaceholder(); const prefixCls = usePrefixCls('description-cascader', props); const dataSource: any[] = field?.dataSource?.length diff --git a/packages/client/src/schemas/input/DesignableBar.tsx b/packages/client/src/schemas/input/DesignableBar.tsx index 376b45f71..188bd7671 100644 --- a/packages/client/src/schemas/input/DesignableBar.tsx +++ b/packages/client/src/schemas/input/DesignableBar.tsx @@ -34,9 +34,7 @@ export const DesignableBar = (props) => { {}}> { - // field.query(key).take((target: Formily.Core.Models.Field) => { - // target.required = checked; - // }); + }} checkedChildren="必填" unCheckedChildren="非必填" diff --git a/packages/client/src/schemas/select/index.tsx b/packages/client/src/schemas/select/index.tsx index 795fa3c38..710598aeb 100644 --- a/packages/client/src/schemas/select/index.tsx +++ b/packages/client/src/schemas/select/index.tsx @@ -439,7 +439,7 @@ Select.Drawer = connect( mapReadPretty( observer((props: any) => { const collectionField = useContext(CollectionFieldContext); - const field = useField(); + const field = useField(); const { ...others } = props; const value = field.value || field.initialValue; const { schema } = useDesignable(); diff --git a/packages/client/src/schemas/table/index.tsx b/packages/client/src/schemas/table/index.tsx index 7e0b50531..75ef11bc5 100644 --- a/packages/client/src/schemas/table/index.tsx +++ b/packages/client/src/schemas/table/index.tsx @@ -55,7 +55,7 @@ import { import { useResource as useGeneralResource } from '../../hooks/useResource'; import SwitchMenuItem from '../../components/SwitchMenuItem'; import { useMemo } from 'react'; -import { createForm,LifeCycleTypes } from '@formily/core'; +import { ArrayField, createForm,LifeCycleTypes } from '@formily/core'; import { ColDraggableContext, SortableBodyCell, @@ -78,7 +78,7 @@ import { useCompile } from '../../hooks/useCompile'; export interface ITableContext { props: any; - field: Formily.Core.Models.ArrayField; + field: ArrayField; schema: Schema; service: BaseResult; selectedRowKeys?: any; @@ -811,7 +811,7 @@ const TableMain = () => { }; const usePagination = () => { - const field = useField(); + const field = useField(); const paginationProps = field.componentProps.pagination; let pagination = paginationProps; @@ -856,7 +856,7 @@ const TableProvider = (props: any) => { ...others } = props; const { schema } = useDesignable(); - const field = useField(); + const field = useField(); const [pagination, setPagination] = usePagination(); const { selectedRowKeys, setSelectedRowKeys } = useSelectedRowKeys(); console.log('props.useSelectedRowKeys', selectedRowKeys); diff --git a/packages/client/src/schemas/upload/index.tsx b/packages/client/src/schemas/upload/index.tsx index aaa88245d..f72a5d659 100644 --- a/packages/client/src/schemas/upload/index.tsx +++ b/packages/client/src/schemas/upload/index.tsx @@ -29,6 +29,7 @@ import './style.less'; import cls from 'classnames'; import { saveAs } from 'file-saver'; import { useTranslation } from 'react-i18next'; +import { Field } from '@formily/core'; const toArr = (value) => { if (!isValid(value)) { @@ -140,7 +141,7 @@ const normalizeFileList = (fileList: UploadFile[]) => { }; const useValidator = (validator: (value: any) => string) => { - const field = useField(); + const field = useField(); useEffect(() => { const dispose = reaction( () => field.value, @@ -196,7 +197,7 @@ export const Upload: ComposedUpload = connect( value: 'fileList', }), mapReadPretty((props) => { - const field = useField(); + const field = useField(); console.log('field.value', field.value); return (field.value || []).map((item) => (
@@ -474,7 +475,7 @@ Upload.Attachment = connect( ); }, mapReadPretty((props) => { - const field = useField(); + const field = useField(); const images = toImages(toArr(field.value)); const [photoIndex, setPhotoIndex] = useState(0); const [visible, setVisible] = useState(false);