Merge branch 'develop' of https://github.com/nocobase/nocobase into develop
This commit is contained in:
		
						commit
						e058c509ea
					
				@ -35,6 +35,7 @@
 | 
			
		||||
    "@types/koa": "^2.13.1",
 | 
			
		||||
    "@types/koa-mount": "^4.0.1",
 | 
			
		||||
    "@types/lodash": "^4.14.169",
 | 
			
		||||
    "@types/marked": "^4.0.1",
 | 
			
		||||
    "@types/mockjs": "^1.0.3",
 | 
			
		||||
    "@types/node": "^12.6.8",
 | 
			
		||||
    "@types/react": "^17.0.0",
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@
 | 
			
		||||
    "flat": "^5.0.2",
 | 
			
		||||
    "html-react-parser": "^1.2.7",
 | 
			
		||||
    "lodash": "^4.17.21",
 | 
			
		||||
    "micromark": "~2.11.0",
 | 
			
		||||
    "marked": "^4.0.5",
 | 
			
		||||
    "monaco-editor": "^0.25.2",
 | 
			
		||||
    "react-big-calendar": "^0.33.6",
 | 
			
		||||
    "react-helmet": "^6.1.0",
 | 
			
		||||
 | 
			
		||||
@ -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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  const actionDataSource = useActionDataSource();
 | 
			
		||||
  const { columns, dataSource, service } = useFieldPermissions();
 | 
			
		||||
  console.log('actionPermissions', field?.value);
 | 
			
		||||
 | 
			
		||||
@ -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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  const { collectionName, fieldNames = {} } = props;
 | 
			
		||||
  console.log('Calendar', props);
 | 
			
		||||
  const { schema } = useDesignable();
 | 
			
		||||
 | 
			
		||||
@ -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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  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<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    if (!field.value) {
 | 
			
		||||
      field.setValue([]);
 | 
			
		||||
 | 
			
		||||
@ -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<string>('');
 | 
			
		||||
 | 
			
		||||
@ -113,7 +114,7 @@ const TextArea: React.FC<any> = (props) => {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const Select: React.FC<SelectProps<any>> = observer((props) => {
 | 
			
		||||
  const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
  const field = useField<Field>();
 | 
			
		||||
  const prefixCls = usePrefixCls('description-select', props);
 | 
			
		||||
  const dataSource: any[] = field?.dataSource?.length
 | 
			
		||||
    ? field.dataSource
 | 
			
		||||
@ -157,7 +158,7 @@ const Select: React.FC<SelectProps<any>> = observer((props) => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const ObjectSelect: React.FC<SelectProps<any>> = observer((props) => {
 | 
			
		||||
  const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
  const field = useField<Field>();
 | 
			
		||||
  const prefixCls = usePrefixCls('description-select', props);
 | 
			
		||||
  const dataSource: any[] = field?.dataSource?.length
 | 
			
		||||
    ? field.dataSource
 | 
			
		||||
@ -201,7 +202,7 @@ const ObjectSelect: React.FC<SelectProps<any>> = observer((props) => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const TreeSelect: React.FC<TreeSelectProps<any>> = observer((props) => {
 | 
			
		||||
  const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
  const field = useField<Field>();
 | 
			
		||||
  const placeholder = usePlaceholder();
 | 
			
		||||
  const prefixCls = usePrefixCls('description-tree-select', props);
 | 
			
		||||
  const dataSource = field?.dataSource?.length
 | 
			
		||||
@ -259,7 +260,7 @@ const TreeSelect: React.FC<TreeSelectProps<any>> = observer((props) => {
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const Cascader: React.FC<CascaderProps> = observer((props) => {
 | 
			
		||||
  const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
  const field = useField<Field>();
 | 
			
		||||
  const placeholder = usePlaceholder();
 | 
			
		||||
  const prefixCls = usePrefixCls('description-cascader', props);
 | 
			
		||||
  const dataSource: any[] = field?.dataSource?.length
 | 
			
		||||
 | 
			
		||||
@ -34,9 +34,7 @@ export const DesignableBar = (props) => {
 | 
			
		||||
      <Menu.Item onClick={() => {}}>
 | 
			
		||||
        <Switch
 | 
			
		||||
          onChange={(checked) => {
 | 
			
		||||
            // field.query(key).take((target: Formily.Core.Models.Field) => {
 | 
			
		||||
            //   target.required = checked;
 | 
			
		||||
            // });
 | 
			
		||||
            
 | 
			
		||||
          }}
 | 
			
		||||
          checkedChildren="必填"
 | 
			
		||||
          unCheckedChildren="非必填"
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,6 @@ import { Button, Dropdown, Input as AntdInput, Menu, Modal, Space } from 'antd';
 | 
			
		||||
import { InputProps, TextAreaProps } from 'antd/lib/input';
 | 
			
		||||
import { Display } from '../display';
 | 
			
		||||
import { LoadingOutlined, MenuOutlined, DragOutlined } from '@ant-design/icons';
 | 
			
		||||
import micromark from 'micromark';
 | 
			
		||||
import { useDesignable } from '../../components/schema-renderer';
 | 
			
		||||
import { useContext, useState } from 'react';
 | 
			
		||||
import AddNew from '../add-new';
 | 
			
		||||
@ -23,6 +22,14 @@ import { isGridRowOrCol } from '../grid';
 | 
			
		||||
import './style.less';
 | 
			
		||||
import { DragHandle } from '../../components/Sortable';
 | 
			
		||||
import { useTranslation } from 'react-i18next';
 | 
			
		||||
import { marked } from 'marked';
 | 
			
		||||
 | 
			
		||||
export function markdown(text) {
 | 
			
		||||
  if (!text) {
 | 
			
		||||
    return '';
 | 
			
		||||
  }
 | 
			
		||||
  return marked.parse(text);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const Markdown: any = connect(
 | 
			
		||||
  AntdInput.TextArea,
 | 
			
		||||
@ -45,7 +52,7 @@ export const Markdown: any = connect(
 | 
			
		||||
    let value = (
 | 
			
		||||
      <div
 | 
			
		||||
        className={'nb-markdown'}
 | 
			
		||||
        dangerouslySetInnerHTML={{ __html: micromark(text || '') }}
 | 
			
		||||
        dangerouslySetInnerHTML={{ __html: markdown(text) }}
 | 
			
		||||
      />
 | 
			
		||||
    );
 | 
			
		||||
    return <Display.TextArea {...props} text={text} value={value} />;
 | 
			
		||||
@ -93,7 +100,7 @@ Markdown.Void = observer((props: any) => {
 | 
			
		||||
  let value = (
 | 
			
		||||
    <div
 | 
			
		||||
      className={'nb-markdown'}
 | 
			
		||||
      dangerouslySetInnerHTML={{ __html: micromark(text || '') }}
 | 
			
		||||
      dangerouslySetInnerHTML={{ __html: markdown(text) }}
 | 
			
		||||
    />
 | 
			
		||||
  );
 | 
			
		||||
  return field?.pattern !== 'readPretty' ? (
 | 
			
		||||
 | 
			
		||||
@ -439,7 +439,7 @@ Select.Drawer = connect(
 | 
			
		||||
  mapReadPretty(
 | 
			
		||||
    observer((props: any) => {
 | 
			
		||||
      const collectionField = useContext(CollectionFieldContext);
 | 
			
		||||
      const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
      const field = useField<Field>();
 | 
			
		||||
      const { ...others } = props;
 | 
			
		||||
      const value = field.value || field.initialValue;
 | 
			
		||||
      const { schema } = useDesignable();
 | 
			
		||||
 | 
			
		||||
@ -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<any, any>;
 | 
			
		||||
  selectedRowKeys?: any;
 | 
			
		||||
@ -811,7 +811,7 @@ const TableMain = () => {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const usePagination = () => {
 | 
			
		||||
  const field = useField<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  const paginationProps = field.componentProps.pagination;
 | 
			
		||||
 | 
			
		||||
  let pagination = paginationProps;
 | 
			
		||||
@ -856,7 +856,7 @@ const TableProvider = (props: any) => {
 | 
			
		||||
    ...others
 | 
			
		||||
  } = props;
 | 
			
		||||
  const { schema } = useDesignable();
 | 
			
		||||
  const field = useField<Formily.Core.Models.ArrayField>();
 | 
			
		||||
  const field = useField<ArrayField>();
 | 
			
		||||
  const [pagination, setPagination] = usePagination();
 | 
			
		||||
  const { selectedRowKeys, setSelectedRowKeys } = useSelectedRowKeys();
 | 
			
		||||
  console.log('props.useSelectedRowKeys', selectedRowKeys);
 | 
			
		||||
 | 
			
		||||
@ -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<Formily.Core.Models.Field>();
 | 
			
		||||
  const field = useField<Field>();
 | 
			
		||||
  useEffect(() => {
 | 
			
		||||
    const dispose = reaction(
 | 
			
		||||
      () => field.value,
 | 
			
		||||
@ -196,7 +197,7 @@ export const Upload: ComposedUpload = connect(
 | 
			
		||||
    value: 'fileList',
 | 
			
		||||
  }),
 | 
			
		||||
  mapReadPretty((props) => {
 | 
			
		||||
    const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
    const field = useField<Field>();
 | 
			
		||||
    console.log('field.value', field.value);
 | 
			
		||||
    return (field.value || []).map((item) => (
 | 
			
		||||
      <div>
 | 
			
		||||
@ -474,7 +475,7 @@ Upload.Attachment = connect(
 | 
			
		||||
    );
 | 
			
		||||
  },
 | 
			
		||||
  mapReadPretty((props) => {
 | 
			
		||||
    const field = useField<Formily.Core.Models.Field>();
 | 
			
		||||
    const field = useField<Field>();
 | 
			
		||||
    const images = toImages(toArr(field.value));
 | 
			
		||||
    const [photoIndex, setPhotoIndex] = useState(0);
 | 
			
		||||
    const [visible, setVisible] = useState(false);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								yarn.lock
									
									
									
									
									
								
							@ -3884,6 +3884,11 @@
 | 
			
		||||
  resolved "https://registry.npmmirror.com/@types/lodash/download/@types/lodash-4.14.176.tgz?cache=0&sync_timestamp=1634771944515&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40types%2Flodash%2Fdownload%2F%40types%2Flodash-4.14.176.tgz#641150fc1cda36fbfa329de603bbb175d7ee20c0"
 | 
			
		||||
  integrity sha1-ZBFQ/BzaNvv6Mp3mA7uxddfuIMA=
 | 
			
		||||
 | 
			
		||||
"@types/marked@^4.0.1":
 | 
			
		||||
  version "4.0.1"
 | 
			
		||||
  resolved "https://registry.npmjs.org/@types/marked/-/marked-4.0.1.tgz#d588a7bbc4d6551c5e75249bc106ffda96ae33c5"
 | 
			
		||||
  integrity sha512-ZigEmCWdNUU7IjZEuQ/iaimYdDHWHfTe3kg8ORfKjyGYd9RWumPoOJRQXB0bO+XLkNwzCthW3wUIQtANaEZ1ag==
 | 
			
		||||
 | 
			
		||||
"@types/mathjax@^0.0.36":
 | 
			
		||||
  version "0.0.36"
 | 
			
		||||
  resolved "https://registry.nlark.com/@types/mathjax/download/@types/mathjax-0.0.36.tgz?cache=0&sync_timestamp=1629708335229&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fmathjax%2Fdownload%2F%40types%2Fmathjax-0.0.36.tgz#18cf766f88ac0cd4e7ee8282b1286049bb6aa682"
 | 
			
		||||
@ -13159,6 +13164,11 @@ markdown-table@^2.0.0:
 | 
			
		||||
  dependencies:
 | 
			
		||||
    repeat-string "^1.0.0"
 | 
			
		||||
 | 
			
		||||
marked@^4.0.5:
 | 
			
		||||
  version "4.0.5"
 | 
			
		||||
  resolved "https://registry.npmjs.org/marked/-/marked-4.0.5.tgz#85f46937f6a4616de7cbe0e1433e1640c320c729"
 | 
			
		||||
  integrity sha512-eUToMA5d5lunnipkCN7zFD0RiunCF2Uo6bImEt/Qx8LZMW7oPXTw7R+f+M5V3eS7164HjEDPfW8/TrefuFhDfw==
 | 
			
		||||
 | 
			
		||||
mathjax-full@^3.0.0:
 | 
			
		||||
  version "3.2.0"
 | 
			
		||||
  resolved "https://registry.nlark.com/mathjax-full/download/mathjax-full-3.2.0.tgz#e53269842a943d4df10502937518991268996c5c"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user