fix: eslint (#1759)

* fix: eslint

* fix: eslint --fix

* fix: changelog
This commit is contained in:
chenos 2023-04-25 13:12:14 +08:00 committed by GitHub
parent fb997bc6b3
commit 883f1e6fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
627 changed files with 11461 additions and 7465 deletions

View File

@ -13,4 +13,11 @@ packages/element
esm esm
doc-site doc-site
public public
package packages/*/*/client.d.ts
packages/*/*/server.d.ts
packages/*/*/client.js
packages/*/*/server.js
packages/core/build
packages/core/dumi-theme-nocobase
packages/core/devtools
packages/core/database/src/sql-parser/index.js

View File

@ -1,20 +1,46 @@
{ {
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:promise/recommended",
// "plugin:import/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser", "parser": "@typescript-eslint/parser",
"env": { "plugins": [
"node": true "@typescript-eslint",
}, "react",
"react-hooks",
"prettier",
"promise"
//"import"
],
"globals": { "globals": {
"sleep": true, "sleep": true,
"prettyFormat": true "prettyFormat": true
}, },
"parserOptions": { "settings": {
"ecmaVersion": 2018, "react": {
"sourceType": "module" "version": "detect"
}
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
}, },
"plugins": [
"react-hooks"
],
"rules": { "rules": {
"react-hooks/rules-of-hooks": "error" "no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": "off",
"react/display-name": "off",
"react/prop-types": "off",
"no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "off"
} }
} }

1614
CHANGELOG.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] } module.exports = { extends: ['@commitlint/config-conventional'] };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ app.acl.define({
role: 'admin', role: 'admin',
actions: { actions: {
'test:export': { 'test:export': {
fields: ['a1', 'b1'] fields: ['a1', 'b1'],
}, },
}, },
}); });

View File

@ -36,4 +36,3 @@ if (require.main === module) {
} }
export default app; export default app;

View File

@ -37,7 +37,7 @@ app.resource({
ctx.body = ctx.body || []; ctx.body = ctx.body || [];
ctx.body.push('test list'); ctx.body.push('test list');
await next(); await next();
} },
}, },
}); });

View File

@ -22,6 +22,10 @@
"postinstall": "nocobase postinstall", "postinstall": "nocobase postinstall",
"lint": "eslint .", "lint": "eslint .",
"clean": "nocobase clean", "clean": "nocobase clean",
"changelog": "yarn changelog:root && yarn changelog:zh-CN && yarn changelog:en-US",
"changelog:root": "auto-changelog -p -t keepachangelog",
"changelog:zh-CN": "auto-changelog -p -t keepachangelog -o docs/zh-CN/welcome/release/index.md",
"changelog:en-US": "auto-changelog -p -t keepachangelog -o docs/en-US/welcome/release/index.md",
"version:alpha": "lerna version prerelease --preid alpha --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"", "version:alpha": "lerna version prerelease --preid alpha --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"",
"release:force": "lerna publish from-package --yes", "release:force": "lerna publish from-package --yes",
"release": "lerna publish", "release": "lerna publish",
@ -40,6 +44,7 @@
"@commitlint/cli": "^16.1.0", "@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.0.0", "@commitlint/config-conventional": "^16.0.0",
"@commitlint/prompt-cli": "^16.1.0", "@commitlint/prompt-cli": "^16.1.0",
"auto-changelog": "^2.4.0",
"ghooks": "^2.0.4", "ghooks": "^2.0.4",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"pretty-format": "^24.0.0", "pretty-format": "^24.0.0",

View File

@ -2,9 +2,7 @@ declare module '*.css';
declare module '*.less'; declare module '*.less';
declare module '*.png'; declare module '*.png';
declare module '*.svg' { declare module '*.svg' {
export function ReactComponent( export function ReactComponent(props: React.SVGProps<SVGSVGElement>): React.ReactElement;
props: React.SVGProps<SVGSVGElement>,
): React.ReactElement;
const url: string; const url: string;
export default url; export default url;
} }

View File

@ -1,5 +1,5 @@
import { createDefaultCacheConfig } from '@nocobase/cache'; import { createDefaultCacheConfig } from '@nocobase/cache';
const cacheConfig = !!process.env.CACHE_CONFIG ? JSON.parse(process.env.CACHE_CONFIG) : createDefaultCacheConfig(); const cacheConfig = process.env.CACHE_CONFIG ? JSON.parse(process.env.CACHE_CONFIG) : createDefaultCacheConfig();
export default cacheConfig; export default cacheConfig;

View File

@ -2,5 +2,5 @@ import { AppLoggerOptions } from '@nocobase/logger';
export default { export default {
transports: process.env.LOGGER_TRANSPORT || ['console', 'dailyRotateFile'], transports: process.env.LOGGER_TRANSPORT || ['console', 'dailyRotateFile'],
level: process.env.LOGGER_LEVEL || (process.env.APP_ENV === 'development' ? 'debug' : 'info') level: process.env.LOGGER_LEVEL || (process.env.APP_ENV === 'development' ? 'debug' : 'info'),
} as AppLoggerOptions; } as AppLoggerOptions;

View File

@ -87,7 +87,7 @@ export class AllowManager {
aclMiddleware() { aclMiddleware() {
return async (ctx, next) => { return async (ctx, next) => {
const { resourceName, actionName } = ctx.action; const { resourceName, actionName } = ctx.action;
let skip = await this.acl.allowManager.isAllowed(resourceName, actionName, ctx); const skip = await this.acl.allowManager.isAllowed(resourceName, actionName, ctx);
if (skip) { if (skip) {
ctx.permission = { ctx.permission = {

View File

@ -5,4 +5,3 @@ export * from './acl-resource';
export * from './acl-role'; export * from './acl-role';
export * from './no-permission-error'; export * from './no-permission-error';
export * from './skip-middleware'; export * from './skip-middleware';

View File

@ -45,7 +45,7 @@ export class SortAbleCollection {
field: SortField; field: SortField;
scopeKey: string; scopeKey: string;
constructor(collection: Collection, fieldName: string = 'sort') { constructor(collection: Collection, fieldName = 'sort') {
this.collection = collection; this.collection = collection;
this.field = collection.getField(fieldName); this.field = collection.getField(fieldName);
@ -112,7 +112,7 @@ export class SortAbleCollection {
targetSort = targetSort + 1; targetSort = targetSort + 1;
} }
let scopeValue = this.scopeKey ? sourceInstance.get(this.scopeKey) : null; const scopeValue = this.scopeKey ? sourceInstance.get(this.scopeKey) : null;
let updateCondition; let updateCondition;
let change; let change;

View File

@ -20,8 +20,7 @@ describe('cache', () => {
}); });
it('createCache-with-single-config', async () => { it('createCache-with-single-config', async () => {
let cacheConfigStr = let cacheConfigStr = '{"store":"memory","ttl":1,"max":10}';
'{"store":"memory","ttl":1,"max":10}';
let cacheConfig = JSON.parse(cacheConfigStr); let cacheConfig = JSON.parse(cacheConfigStr);
let cache = createCache(cacheConfig); let cache = createCache(cacheConfig);
await cache.set('name', 'Emma'); await cache.set('name', 'Emma');
@ -31,8 +30,7 @@ describe('cache', () => {
await sleep(1005); await sleep(1005);
expect(await cache.get('name')).toBeUndefined(); expect(await cache.get('name')).toBeUndefined();
cacheConfigStr = cacheConfigStr = '[{"store":"memory","ttl":1,"max":10}]';
'[{"store":"memory","ttl":1,"max":10}]';
cacheConfig = JSON.parse(cacheConfigStr); cacheConfig = JSON.parse(cacheConfigStr);
cache = createCache(cacheConfig); cache = createCache(cacheConfig);
await cache.set('name', 'Emma'); await cache.set('name', 'Emma');

View File

@ -50,7 +50,7 @@ export function createCache(cacheConfig: ICacheConfig | ICacheConfig[] = createD
if (cacheConfig.length === 1) { if (cacheConfig.length === 1) {
return createCacheByICacheConfig(cacheConfig[0]); return createCacheByICacheConfig(cacheConfig[0]);
} else { } else {
let caches = []; const caches = [];
for (const cacheConfigEle of cacheConfig) { for (const cacheConfigEle of cacheConfig) {
caches.push(createCacheByICacheConfig(cacheConfigEle)); caches.push(createCacheByICacheConfig(cacheConfigEle));
} }

View File

@ -1,4 +1,3 @@
// @ts-nocheck // @ts-nocheck
export * from './lib/client'; export * from './lib/client';
export { default } from './lib/client'; export { default } from './lib/client';

View File

@ -1,30 +1,65 @@
"use strict"; 'use strict';
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== 'function') return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return { default: obj };
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var _index = _interopRequireWildcard(require("./lib/client")); var _index = _interopRequireWildcard(require('./lib/client'));
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, '__esModule', {
value: true value: true,
}); });
var _exportNames = {}; var _exportNames = {};
Object.defineProperty(exports, "default", { Object.defineProperty(exports, 'default', {
enumerable: true, enumerable: true,
get: function get() { get: function get() {
return _index.default; return _index.default;
} },
}); });
Object.keys(_index).forEach(function (key) { Object.keys(_index).forEach(function (key) {
if (key === "default" || key === "__esModule") return; if (key === 'default' || key === '__esModule') return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index[key]) return; if (key in exports && exports[key] === _index[key]) return;
Object.defineProperty(exports, key, { Object.defineProperty(exports, key, {
enumerable: true, enumerable: true,
get: function get() { get: function get() {
return _index[key]; return _index[key];
} },
}); });
}); });

View File

@ -1,4 +1,3 @@
// @ts-nocheck // @ts-nocheck
export * from './lib/server'; export * from './lib/server';
export { default } from './lib/server'; export { default } from './lib/server';

View File

@ -1,30 +1,65 @@
"use strict"; 'use strict';
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== 'function') return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireWildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
return { default: obj };
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
var _index = _interopRequireWildcard(require("./lib/server")); var _index = _interopRequireWildcard(require('./lib/server'));
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, '__esModule', {
value: true value: true,
}); });
var _exportNames = {}; var _exportNames = {};
Object.defineProperty(exports, "default", { Object.defineProperty(exports, 'default', {
enumerable: true, enumerable: true,
get: function get() { get: function get() {
return _index.default; return _index.default;
} },
}); });
Object.keys(_index).forEach(function (key) { Object.keys(_index).forEach(function (key) {
if (key === "default" || key === "__esModule") return; if (key === 'default' || key === '__esModule') return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index[key]) return; if (key in exports && exports[key] === _index[key]) return;
Object.defineProperty(exports, key, { Object.defineProperty(exports, key, {
enumerable: true, enumerable: true,
get: function get() { get: function get() {
return _index[key]; return _index[key];
} },
}); });
}); });

View File

@ -19,7 +19,7 @@ const getParentKeys = (tree, func, path = []) => {
return []; return [];
}; };
const getChildrenKeys = (data = [], arr = []) => { const getChildrenKeys = (data = [], arr = []) => {
for (let item of data) { for (const item of data) {
arr.push(item.key); arr.push(item.key);
if (item.children && item.children.length) getChildrenKeys(item.children, arr); if (item.children && item.children.length) getChildrenKeys(item.children, arr);
} }

View File

@ -31,7 +31,7 @@ const getParentUids = (tree, func, path = []) => {
return []; return [];
}; };
const getChildrenUids = (data = [], arr = []) => { const getChildrenUids = (data = [], arr = []) => {
for (let item of data) { for (const item of data) {
arr.push(item.uid); arr.push(item.uid);
if (item.children && item.children.length) getChildrenUids(item.children, arr); if (item.children && item.children.length) getChildrenUids(item.children, arr);
} }
@ -116,8 +116,8 @@ export const MenuConfigure = () => {
refresh(); refresh();
message.success(t('Saved successfully')); message.success(t('Saved successfully'));
}} }}
/> />{' '}
{' '}{t('Accessible')} {t('Accessible')}
</> </>
), ),
render: (_, schema) => { render: (_, schema) => {

View File

@ -27,7 +27,10 @@ export const RoleTable = () => {
return ( return (
<div> <div>
<AvailableActionsProver> <AvailableActionsProver>
<SchemaComponent schema={roleSchema} components={{ MenuItemsProvider, SettingCenterPermissionProvider,PermissionProvider }} /> <SchemaComponent
schema={roleSchema}
components={{ MenuItemsProvider, SettingCenterPermissionProvider, PermissionProvider }}
/>
</AvailableActionsProver> </AvailableActionsProver>
</div> </div>
); );

View File

@ -3,4 +3,4 @@ export { RoleConfigure } from './RoleConfigure';
export { RolesResourcesActions } from './RolesResourcesActions'; export { RolesResourcesActions } from './RolesResourcesActions';
export { RoleTable } from './RoleTable'; export { RoleTable } from './RoleTable';
export { StrategyActions } from './StrategyActions'; export { StrategyActions } from './StrategyActions';
export { SettingsCenterConfigure,SettingCenterProvider } from './ConfigureCenter'; export { SettingsCenterConfigure, SettingCenterProvider } from './ConfigureCenter';

View File

@ -22,5 +22,5 @@ describe('APIClient', () => {
const apiClient = new APIClient(instance); const apiClient = new APIClient(instance);
expect(apiClient.axios).toBe(instance); expect(apiClient.axios).toBe(instance);
}); });
}) });
}); });

View File

@ -10,9 +10,7 @@ mock.onGet('/users:get').reply(200, {
data: { id: 1, name: 'John Smith' }, data: { id: 1, name: 'John Smith' },
}); });
const providers = [ const providers = [[APIClientProvider, { apiClient }]];
[APIClientProvider, { apiClient }]
];
export default compose(...providers)(() => { export default compose(...providers)(() => {
const { data } = useRequest({ const { data } = useRequest({

View File

@ -10,9 +10,7 @@ mock.onGet('/users:get').reply(200, {
data: { id: 1, name: 'John Smith' }, data: { id: 1, name: 'John Smith' },
}); });
const providers = [ const providers = [[APIClientProvider, { apiClient }]];
[APIClientProvider, { apiClient }]
];
export default compose(...providers)(() => { export default compose(...providers)(() => {
const { data } = useRequest({ const { data } = useRequest({

View File

@ -1,4 +1,3 @@
export * from './useAPIClient'; export * from './useAPIClient';
export * from './useRequest'; export * from './useRequest';
export * from './useResource'; export * from './useResource';

View File

@ -21,7 +21,7 @@ import {
SignupPage, SignupPage,
SystemSettingsProvider, SystemSettingsProvider,
SystemSettingsShortcut, SystemSettingsShortcut,
useRequest useRequest,
} from '@nocobase/client'; } from '@nocobase/client';
import { Spin } from 'antd'; import { Spin } from 'antd';
import React from 'react'; import React from 'react';

View File

@ -144,7 +144,7 @@ export default (apiClient: APIClient) => {
const response = { const response = {
data: { data: {
type: 'void', type: 'void',
name: uid(), name: uid(),
'x-uid': uid(), 'x-uid': uid(),
'x-component': 'Page', 'x-component': 'Page',
properties: { properties: {

View File

@ -1,3 +1,2 @@
export * from './Application'; export * from './Application';
export * from './compose'; export * from './compose';

View File

@ -12,7 +12,7 @@ const formatData = (
fieldNames, fieldNames,
tasks: any[] = [], tasks: any[] = [],
projectId: any = undefined, projectId: any = undefined,
hideChildren: boolean = false, hideChildren = false,
checkPermassion?: Function, checkPermassion?: Function,
) => { ) => {
data.forEach((item: any) => { data.forEach((item: any) => {

View File

@ -187,7 +187,7 @@ export const useTableBlockProps = () => {
ctx.service.refresh(); ctx.service.refresh();
}, },
onChange({ current, pageSize }, filters, sorter) { onChange({ current, pageSize }, filters, sorter) {
let sort = sorter.order const sort = sorter.order
? sorter.order === `ascend` ? sorter.order === `ascend`
? [sorter.field] ? [sorter.field]
: [`-${sorter.field}`] : [`-${sorter.field}`]

View File

@ -86,7 +86,7 @@ function getFormValues(filterByTk, field, form, fieldNames, getField, resource)
} }
console.log('form.values', form.values); console.log('form.values', form.values);
return form.values; return form.values;
let values = {}; const values = {};
for (const key in form.values) { for (const key in form.values) {
if (fieldNames.includes(key)) { if (fieldNames.includes(key)) {
const collectionField = getField(key); const collectionField = getField(key);
@ -494,7 +494,7 @@ export const useCustomizeBulkEditActionProps = () => {
if (!skipValidator) { if (!skipValidator) {
await form.submit(); await form.submit();
} }
let values = cloneDeep(form.values); const values = cloneDeep(form.values);
actionField.data = field.data || {}; actionField.data = field.data || {};
actionField.data.loading = true; actionField.data.loading = true;
for (const key in values) { for (const key in values) {
@ -668,7 +668,7 @@ export const useUpdateActionProps = () => {
await form.submit(); await form.submit();
} }
const fieldNames = fields.map((field) => field.name); const fieldNames = fields.map((field) => field.name);
let values = getFormValues(filterByTk, field, form, fieldNames, getField, resource); const values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
actionField.data = field.data || {}; actionField.data = field.data || {};
actionField.data.loading = true; actionField.data.loading = true;
try { try {

View File

@ -9,5 +9,5 @@ export * from './TableBlockProvider';
export * from './TableFieldProvider'; export * from './TableFieldProvider';
export * from './TableSelectorProvider'; export * from './TableSelectorProvider';
export * from './FormFieldProvider'; export * from './FormFieldProvider';
export * from './GanttBlockProvider' export * from './GanttBlockProvider';
export * from './SharedFilterProvider'; export * from './SharedFilterProvider';

View File

@ -3,22 +3,22 @@ import CardForm from './CardForm';
function CardAdder({ column, onConfirm }) { function CardAdder({ column, onConfirm }) {
function confirmCard(card) { function confirmCard(card) {
onConfirm(column, card) onConfirm(column, card);
setAddingCard(false) setAddingCard(false);
} }
const [addingCard, setAddingCard] = useState(false) const [addingCard, setAddingCard] = useState(false);
return ( return (
<> <>
{addingCard ? ( {addingCard ? (
<CardForm onConfirm={confirmCard} onCancel={() => setAddingCard(false)} /> <CardForm onConfirm={confirmCard} onCancel={() => setAddingCard(false)} />
) : ( ) : (
<button className='react-kanban-card-adder-button' onClick={() => setAddingCard(!addingCard)}> <button className="react-kanban-card-adder-button" onClick={() => setAddingCard(!addingCard)}>
+ +
</button> </button>
)} )}
</> </>
) );
} }
export default CardAdder; export default CardAdder;

View File

@ -3,25 +3,25 @@ import { when } from './utils';
function ColumnForm({ onConfirm, onCancel }) { function ColumnForm({ onConfirm, onCancel }) {
// FIXME use hook // FIXME use hook
const inputColumnTitle = createRef<any>() const inputColumnTitle = createRef<any>();
function addColumn(event) { function addColumn(event) {
event.preventDefault() event.preventDefault();
when(inputColumnTitle.current.value)(onConfirm) when(inputColumnTitle.current.value)(onConfirm);
} }
return ( return (
<div className='react-kanban-column' style={{ minWidth: '230px' }}> <div className="react-kanban-column" style={{ minWidth: '230px' }}>
<form style={{ display: 'flex', justifyContent: 'space-between' }} onSubmit={addColumn}> <form style={{ display: 'flex', justifyContent: 'space-between' }} onSubmit={addColumn}>
<input type='text' ref={inputColumnTitle} autoFocus /> <input type="text" ref={inputColumnTitle} autoFocus />
<button type='submit'>Add</button> <button type="submit">Add</button>
<button type='button' onClick={onCancel}> <button type="button" onClick={onCancel}>
Cancel Cancel
</button> </button>
</form> </form>
</div> </div>
) );
} }
export default ColumnForm export default ColumnForm;

View File

@ -7,52 +7,58 @@ function ColumnTitle({ allowRenameColumn, onClick, children: title }) {
</span> </span>
) : ( ) : (
<span>{title}</span> <span>{title}</span>
) );
} }
function useRenameMode(state) { function useRenameMode(state) {
const [renameMode, setRenameMode] = useState(state) const [renameMode, setRenameMode] = useState(state);
function toggleRenameMode() { function toggleRenameMode() {
setRenameMode(!renameMode) setRenameMode(!renameMode);
} }
return [renameMode, toggleRenameMode] return [renameMode, toggleRenameMode];
} }
function DefaultColumnHeader({ children: column, allowRemoveColumn, onColumnRemove, allowRenameColumn, onColumnRename }) { function DefaultColumnHeader({
const [renameMode, toggleRenameMode] = useRenameMode(false) children: column,
const [titleInput, setTitleInput] = useState('') allowRemoveColumn,
onColumnRemove,
allowRenameColumn,
onColumnRename,
}) {
const [renameMode, toggleRenameMode] = useRenameMode(false);
const [titleInput, setTitleInput] = useState('');
function handleRenameColumn(event) { function handleRenameColumn(event) {
event.preventDefault() event.preventDefault();
onColumnRename(column, titleInput) onColumnRename(column, titleInput);
toggleRenameMode() toggleRenameMode();
} }
function handleRenameMode() { function handleRenameMode() {
setTitleInput(column.title) setTitleInput(column.title);
toggleRenameMode() toggleRenameMode();
} }
return ( return (
<div className='react-kanban-column-header'> <div className="react-kanban-column-header">
{renameMode ? ( {renameMode ? (
<form onSubmit={handleRenameColumn}> <form onSubmit={handleRenameColumn}>
<span> <span>
<input <input
type='text' type="text"
value={titleInput} value={titleInput}
onChange={({ target: { value } }) => setTitleInput(value)} onChange={({ target: { value } }) => setTitleInput(value)}
autoFocus autoFocus
/> />
</span> </span>
<span> <span>
<button className='react-kanban-column-header__button' type='submit'> <button className="react-kanban-column-header__button" type="submit">
Rename Rename
</button> </button>
<button className='react-kanban-column-header__button' type='button' onClick={handleRenameMode}> <button className="react-kanban-column-header__button" type="button" onClick={handleRenameMode}>
Cancel Cancel
</button> </button>
</span> </span>
@ -66,7 +72,7 @@ function DefaultColumnHeader({ children: column, allowRemoveColumn, onColumnRemo
</> </>
)} )}
</div> </div>
) );
} }
export default DefaultColumnHeader; export default DefaultColumnHeader;

View File

@ -2,7 +2,7 @@ import {
addInArrayAtPosition, addInArrayAtPosition,
changeElementOfPositionInArray, changeElementOfPositionInArray,
removeFromArrayAtPosition, removeFromArrayAtPosition,
replaceElementOfArray replaceElementOfArray,
} from './utils'; } from './utils';
function reorderCardsOnColumn(column, reorderCards) { function reorderCardsOnColumn(column, reorderCards) {

View File

@ -1,2 +1 @@
export { default as Board } from './Board'; export { default as Board } from './Board';

View File

@ -1,41 +1,41 @@
function getCoordinates(event, board) { function getCoordinates(event, board) {
if (event.destination === null) return {} if (event.destination === null) return {};
const columnSource = { fromPosition: event.source.index } const columnSource = { fromPosition: event.source.index };
const columnDestination = { toPosition: event.destination.index } const columnDestination = { toPosition: event.destination.index };
if (isAColumnMove(event.type)) { if (isAColumnMove(event.type)) {
return { source: columnSource, destination: columnDestination } return { source: columnSource, destination: columnDestination };
} }
return { return {
source: { ...columnSource, fromColumnId: getColumn(board, event.source.droppableId).id }, source: { ...columnSource, fromColumnId: getColumn(board, event.source.droppableId).id },
destination: { ...columnDestination, toColumnId: getColumn(board, event.destination.droppableId).id }, destination: { ...columnDestination, toColumnId: getColumn(board, event.destination.droppableId).id },
} };
} }
function isAColumnMove(type) { function isAColumnMove(type) {
return type === 'BOARD' return type === 'BOARD';
} }
function getCard(board, sourceCoordinate) { function getCard(board, sourceCoordinate) {
const column = board.columns.find((column) => column.id === sourceCoordinate.fromColumnId) const column = board.columns.find((column) => column.id === sourceCoordinate.fromColumnId);
return column.cards[sourceCoordinate.fromPosition] return column.cards[sourceCoordinate.fromPosition];
} }
function getColumn(board, droppableId) { function getColumn(board, droppableId) {
return board.columns.find(({ id }) => String(id) === droppableId) return board.columns.find(({ id }) => String(id) === droppableId);
} }
function isMovingAColumnToAnotherPosition(coordinates) { function isMovingAColumnToAnotherPosition(coordinates) {
return coordinates.source.fromPosition !== coordinates.destination.toPosition return coordinates.source.fromPosition !== coordinates.destination.toPosition;
} }
function isMovingACardToAnotherPosition(coordinates) { function isMovingACardToAnotherPosition(coordinates) {
return !( return !(
coordinates.source.fromPosition === coordinates.destination.toPosition && coordinates.source.fromPosition === coordinates.destination.toPosition &&
coordinates.source.fromColumnId === coordinates.destination.toColumnId coordinates.source.fromColumnId === coordinates.destination.toColumnId
) );
} }
export { getCard, getCoordinates, isAColumnMove, isMovingAColumnToAnotherPosition, isMovingACardToAnotherPosition } export { getCard, getCoordinates, isAColumnMove, isMovingAColumnToAnotherPosition, isMovingACardToAnotherPosition };

View File

@ -1,48 +1,48 @@
function compose(...fns) { function compose(...fns) {
return (arg) => fns.reduce((acc, fn) => fn(acc), arg) return (arg) => fns.reduce((acc, fn) => fn(acc), arg);
} }
function partialRight(fn, ...args) { function partialRight(fn, ...args) {
return (...leftArgs) => fn(...leftArgs, ...args) return (...leftArgs) => fn(...leftArgs, ...args);
} }
function addInArrayAtPosition(array, element, position) { function addInArrayAtPosition(array, element, position) {
const arrayCopy = [...array] const arrayCopy = [...array];
arrayCopy.splice(position, 0, element) arrayCopy.splice(position, 0, element);
return arrayCopy return arrayCopy;
} }
function removeFromArrayAtPosition(array, position) { function removeFromArrayAtPosition(array, position) {
return array.reduce((acc, value, idx) => (idx === position ? acc : [...acc, value]), []) return array.reduce((acc, value, idx) => (idx === position ? acc : [...acc, value]), []);
} }
function changeElementOfPositionInArray(array, from, to) { function changeElementOfPositionInArray(array, from, to) {
const removeFromArrayAtPositionFrom = partialRight(removeFromArrayAtPosition, from) const removeFromArrayAtPositionFrom = partialRight(removeFromArrayAtPosition, from);
const addInArrayAtPositionTo = partialRight(addInArrayAtPosition, array[from], to) const addInArrayAtPositionTo = partialRight(addInArrayAtPosition, array[from], to);
return compose(removeFromArrayAtPositionFrom, addInArrayAtPositionTo)(array) return compose(removeFromArrayAtPositionFrom, addInArrayAtPositionTo)(array);
} }
function identity(value) { function identity(value) {
return value return value;
} }
function when(value, predicate = identity) { function when(value, predicate = identity) {
return function callback(callback) { return function callback(callback) {
if (predicate(value)) return callback(value) if (predicate(value)) return callback(value);
} };
} }
function replaceElementOfArray(array) { function replaceElementOfArray(array) {
return function (options) { return function (options) {
return array.map((element) => (options.when(element) ? options.for(element) : element)) return array.map((element) => (options.when(element) ? options.for(element) : element));
} };
} }
function pickPropOut(object, prop) { function pickPropOut(object, prop) {
return Object.keys(object).reduce((obj, key) => { return Object.keys(object).reduce((obj, key) => {
return key === prop ? obj : { ...obj, [key]: object[key] } return key === prop ? obj : { ...obj, [key]: object[key] };
}, {}) }, {});
} }
export { export {
@ -53,4 +53,4 @@ export {
replaceElementOfArray, replaceElementOfArray,
partialRight, partialRight,
pickPropOut, pickPropOut,
} };

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react';
import { Droppable } from 'react-beautiful-dnd' import { Droppable } from 'react-beautiful-dnd';
function withDroppable(Component) { function withDroppable(Component) {
return function WrapperComponent({ children, ...droppableProps }) { return function WrapperComponent({ children, ...droppableProps }) {
@ -12,8 +12,8 @@ function withDroppable(Component) {
</Component> </Component>
)} )}
</Droppable> </Droppable>
) );
} };
} }
export default withDroppable export default withDroppable;

View File

@ -100,9 +100,9 @@ export const InternalFallbackField = () => {
// 当字段被删除时,显示一个提示占位符 // 当字段被删除时,显示一个提示占位符
const DeletedField = () => { const DeletedField = () => {
const { t } = useTranslation() const { t } = useTranslation();
return <div style={{ color: '#ccc' }}>{t('The field has bee deleted')}</div>; return <div style={{ color: '#ccc' }}>{t('The field has bee deleted')}</div>;
} };
export const CollectionField = connect((props) => { export const CollectionField = connect((props) => {
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();

View File

@ -5,7 +5,7 @@ import {
CollectionFieldProvider, CollectionFieldProvider,
CollectionProvider, CollectionProvider,
ResourceActionProvider, ResourceActionProvider,
useDataSourceFromRAC useDataSourceFromRAC,
} from './'; } from './';
import * as hooks from './action-hooks'; import * as hooks from './action-hooks';
import { DataSourceProvider, ds, SubFieldDataSourceProvider } from './sub-table'; import { DataSourceProvider, ds, SubFieldDataSourceProvider } from './sub-table';

View File

@ -27,7 +27,7 @@ import {
EditCategory, EditCategory,
EditCategoryAction, EditCategoryAction,
SyncFieldsAction, SyncFieldsAction,
SyncFieldsActionCom SyncFieldsActionCom,
} from './Configuration'; } from './Configuration';
import { CollectionCategroriesProvider } from './CollectionManagerProvider'; import { CollectionCategroriesProvider } from './CollectionManagerProvider';
@ -61,32 +61,32 @@ const schema2: ISchema = {
export const CollectionManagerPane = () => { export const CollectionManagerPane = () => {
return ( return (
// <Card bordered={false}> // <Card bordered={false}>
<SchemaComponent <SchemaComponent
schema={schema2} schema={schema2}
components={{ components={{
CollectionCategroriesProvider, CollectionCategroriesProvider,
ConfigurationTable, ConfigurationTable,
ConfigurationTabs, ConfigurationTabs,
AddFieldAction, AddFieldAction,
AddCollectionField, AddCollectionField,
AddCollection, AddCollection,
AddCollectionAction, AddCollectionAction,
AddCategoryAction, AddCategoryAction,
AddCategory, AddCategory,
EditCollection, EditCollection,
EditCollectionAction, EditCollectionAction,
EditFieldAction, EditFieldAction,
EditCollectionField, EditCollectionField,
OverridingCollectionField, OverridingCollectionField,
OverridingFieldAction, OverridingFieldAction,
ViewCollectionField, ViewCollectionField,
ViewFieldAction, ViewFieldAction,
EditCategory, EditCategory,
EditCategoryAction, EditCategoryAction,
SyncFieldsAction, SyncFieldsAction,
SyncFieldsActionCom SyncFieldsActionCom,
}} }}
/> />
// </Card> // </Card>
); );
}; };

View File

@ -41,7 +41,7 @@ export const AddCategoryAction = (props) => {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<ActionContext.Provider value={{ visible, setVisible }}> <ActionContext.Provider value={{ visible, setVisible }}>
<div onClick={() => setVisible(true)} title={t('Add category')}> <div onClick={() => setVisible(true)} title={t('Add category')}>
{children || <PlusOutlined />} {children || <PlusOutlined />}
</div> </div>
<SchemaComponent <SchemaComponent

View File

@ -98,7 +98,7 @@ const getSchema = (schema, category, compile): ISchema => {
}; };
const useDefaultCollectionFields = (values) => { const useDefaultCollectionFields = (values) => {
let defaults = values.fields ? [...values.fields] : []; const defaults = values.fields ? [...values.fields] : [];
const { autoGenId = true, createdAt = true, createdBy = true, updatedAt = true, updatedBy = true } = values; const { autoGenId = true, createdAt = true, createdBy = true, updatedAt = true, updatedBy = true } = values;
if (autoGenId) { if (autoGenId) {
const pk = values.fields.find((f) => f.primaryKey); const pk = values.fields.find((f) => f.primaryKey);

View File

@ -359,18 +359,20 @@ export const CollectionFields = (props) => {
]; ];
dataSource.push( dataSource.push(
...inherits.map((key) => { ...inherits
const collection = getCollection(key); .map((key) => {
if (!collection) { const collection = getCollection(key);
return; if (!collection) {
} return;
return { }
key, return {
title: `${t('Inherited fields')} - ` + compile(collection?.title), key,
inherit: true, title: `${t('Inherited fields')} - ` + compile(collection?.title),
fields: collection?.fields || [], inherit: true,
}; fields: collection?.fields || [],
}).filter(Boolean), };
})
.filter(Boolean),
); );
const resourceActionProps = { const resourceActionProps = {

View File

@ -7,7 +7,7 @@ import {
useDraggable, useDraggable,
useDroppable, useDroppable,
useSensor, useSensor,
useSensors useSensors,
} from '@dnd-kit/core'; } from '@dnd-kit/core';
import { RecursionField, observer } from '@formily/react'; import { RecursionField, observer } from '@formily/react';
import { uid } from '@formily/shared'; import { uid } from '@formily/shared';

View File

@ -115,7 +115,11 @@ export const EditSubFieldAction = (props) => {
> >
{t('Edit')} {t('Edit')}
</a> </a>
<SchemaComponent schema={schema} components={{ ...components, ArrayTable }} scope={{ useUpdateCollectionField }} /> <SchemaComponent
schema={schema}
components={{ ...components, ArrayTable }}
scope={{ useUpdateCollectionField }}
/>
</ActionContext.Provider> </ActionContext.Provider>
); );
}; };

View File

@ -58,8 +58,6 @@ const getSchema = (schema: IField, record: any, compile, getContainer): ISchema
}; };
}; };
export const ViewCollectionField = (props) => { export const ViewCollectionField = (props) => {
const record = useRecord(); const record = useRecord();
return <ViewFieldAction item={record} {...props} />; return <ViewFieldAction item={record} {...props} />;

View File

@ -10,5 +10,5 @@ export const CollectionTemplate = observer((props: any) => {
const compile = useCompile(); const compile = useCompile();
const schema = getTemplate(value); const schema = getTemplate(value);
return <Tag>{compile(schema?.title||'{{t("General collection")}}')}</Tag>; return <Tag>{compile(schema?.title || '{{t("General collection")}}')}</Tag>;
}); });

View File

@ -23,7 +23,9 @@ export const FieldSummary = observer((props: any) => {
padding: 16px; padding: 16px;
`} `}
> >
<div className={css``}>{t('Field interface')}: <Tag>{compile(schema.title)}</Tag></div> <div className={css``}>
{t('Field interface')}: <Tag>{compile(schema.title)}</Tag>
</div>
{schema.description ? ( {schema.description ? (
<div <div
className={css` className={css`

View File

@ -23,7 +23,9 @@ export const TemplateSummay = observer((props: any) => {
padding: 16px; padding: 16px;
`} `}
> >
<div className={css``}>{t('Collection template')}: <Tag>{compile(schema.title)}</Tag></div> <div className={css``}>
{t('Collection template')}: <Tag>{compile(schema.title)}</Tag>
</div>
{schema.description ? ( {schema.description ? (
<div <div
className={css` className={css`

View File

@ -20,12 +20,14 @@ export const SourceForeignKey = observer(() => {
placeholder={'留空时,自动生成 FK 字段'} placeholder={'留空时,自动生成 FK 字段'}
disabled={field.disabled} disabled={field.disabled}
value={field.value} value={field.value}
options={getCollectionFields(collection.name).filter(field => field.type).map((field) => { options={getCollectionFields(collection.name)
return { .filter((field) => field.type)
label: field?.uiSchema?.title || field.name, .map((field) => {
value: field.name, return {
}; label: field?.uiSchema?.title || field.name,
})} value: field.name,
};
})}
/> />
</div> </div>
); );
@ -42,18 +44,19 @@ export const ThroughForeignKey = observer(() => {
placeholder={'留空时,自动生成 FK 字段'} placeholder={'留空时,自动生成 FK 字段'}
disabled={field.disabled} disabled={field.disabled}
value={field.value} value={field.value}
options={getCollectionFields(form.values.through).filter(field => field.type).map((field) => { options={getCollectionFields(form.values.through)
return { .filter((field) => field.type)
label: field?.uiSchema?.title || field.name, .map((field) => {
value: field.name, return {
}; label: field?.uiSchema?.title || field.name,
})} value: field.name,
};
})}
/> />
</div> </div>
); );
}); });
export const TargetForeignKey = observer(() => { export const TargetForeignKey = observer(() => {
const field = useField<Field>(); const field = useField<Field>();
const form = useForm(); const form = useForm();
@ -65,12 +68,14 @@ export const TargetForeignKey = observer(() => {
placeholder={'留空时,自动生成 FK 字段'} placeholder={'留空时,自动生成 FK 字段'}
disabled={field.disabled} disabled={field.disabled}
value={field.value} value={field.value}
options={getCollectionFields(form.values.target).filter(field => field.type).map((field) => { options={getCollectionFields(form.values.target)
return { .filter((field) => field.type)
label: field?.uiSchema?.title || field.name, .map((field) => {
value: field.name, return {
}; label: field?.uiSchema?.title || field.name,
})} value: field.name,
};
})}
/> />
</div> </div>
); );
@ -83,7 +88,11 @@ export const SourceCollection = observer(() => {
const compile = useCompile(); const compile = useCompile();
return ( return (
<div> <div>
<Select disabled value={collection.name} options={[{ value: collection.name, label: compile(collection.title) }]} /> <Select
disabled
value={collection.name}
options={[{ value: collection.name, label: compile(collection.title) }]}
/>
</div> </div>
); );
}); });

View File

@ -20,7 +20,7 @@ interface ResourceActionProviderProps {
const ResourceContext = createContext<any>(null); const ResourceContext = createContext<any>(null);
const CollectionResourceActionProvider = (props) => { const CollectionResourceActionProvider = (props) => {
let { collection, request, uid, dragSort } = props; const { collection, request, uid, dragSort } = props;
const api = useAPIClient(); const api = useAPIClient();
const record = useRecord(); const record = useRecord();
const actionName = request?.action; const actionName = request?.action;
@ -52,7 +52,7 @@ const CollectionResourceActionProvider = (props) => {
}; };
const AssociationResourceActionProvider = (props) => { const AssociationResourceActionProvider = (props) => {
let { collection, association, request, uid, dragSort } = props; const { collection, association, request, uid, dragSort } = props;
const api = useAPIClient(); const api = useAPIClient();
const record = useRecord(); const record = useRecord();
const resourceOf = record[association.sourceKey]; const resourceOf = record[association.sourceKey];

View File

@ -3,7 +3,7 @@ import {
AntdSchemaComponentProvider, AntdSchemaComponentProvider,
CollectionManagerProvider, CollectionManagerProvider,
SchemaComponent, SchemaComponent,
SchemaComponentProvider SchemaComponentProvider,
} from '@nocobase/client'; } from '@nocobase/client';
import React from 'react'; import React from 'react';

View File

@ -18,7 +18,7 @@ import {
SchemaComponentProvider, SchemaComponentProvider,
SchemaInitializer, SchemaInitializer,
SchemaInitializerProvider, SchemaInitializerProvider,
useCollectionManager useCollectionManager,
} from '@nocobase/client'; } from '@nocobase/client';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
import React, { useContext } from 'react'; import React, { useContext } from 'react';

View File

@ -1,7 +1,7 @@
import { action } from '@formily/reactive'; import { action } from '@formily/reactive';
import { useCollectionManager } from "."; import { useCollectionManager } from '.';
import { useCompile } from "../../schema-component"; import { useCompile } from '../../schema-component';
export function useCollectionDataSource(filter?: Function) { export function useCollectionDataSource(filter?: Function) {
return (field: any) => { return (field: any) => {
@ -9,10 +9,10 @@ export function useCollectionDataSource(filter?: Function) {
const { collections = [] } = useCollectionManager(); const { collections = [] } = useCollectionManager();
action.bound((data: any) => { action.bound((data: any) => {
const filtered = typeof filter === 'function' ? data.filter(filter) : data; const filtered = typeof filter === 'function' ? data.filter(filter) : data;
field.dataSource = filtered.map(item => ({ field.dataSource = filtered.map((item) => ({
label: compile(item.title), label: compile(item.title),
value: item.name value: item.name,
})); }));
})(collections); })(collections);
} };
} }

View File

@ -276,7 +276,7 @@ export const useCollectionManager = () => {
getInterface(name: string) { getInterface(name: string) {
return interfaces[name] ? clone(interfaces[name]) : null; return interfaces[name] ? clone(interfaces[name]) : null;
}, },
getTemplate(name: string = 'general') { getTemplate(name = 'general') {
return templates[name] ? clone(templates[name] || templates['general']) : null; return templates[name] ? clone(templates[name] || templates['general']) : null;
}, },
getParentCollectionFields: (parentCollection, currentCollection) => { getParentCollectionFields: (parentCollection, currentCollection) => {

View File

@ -22,7 +22,7 @@ export const attachment: IField = {
}, },
}, },
}, },
availableTypes:['belongsToMany'], availableTypes: ['belongsToMany'],
schemaInitialize(schema: ISchema, { block }) { schemaInitialize(schema: ISchema, { block }) {
if (['Table', 'Kanban'].includes(block)) { if (['Table', 'Kanban'].includes(block)) {
schema['x-component-props'] = schema['x-component-props'] || {}; schema['x-component-props'] = schema['x-component-props'] || {};

View File

@ -34,7 +34,7 @@ export const chinaRegion: IField = {
}, },
}, },
}, },
availableTypes:['belongsToMany'], availableTypes: ['belongsToMany'],
initialize: (values: any) => { initialize: (values: any) => {
if (!values.through) { if (!values.through) {
values.through = `t_${uid()}`; values.through = `t_${uid()}`;

View File

@ -2,33 +2,26 @@ import { Switch } from 'antd';
import React from 'react'; import React from 'react';
export const TargetKey = () => { export const TargetKey = () => {
return ( return <div>Target key</div>;
<div>
Target key
</div>
);
}; };
export const ThroughCollection = () => { export const ThroughCollection = () => {
return ( return (
<div> <div>
Through collection <Switch size={'small'} defaultChecked checkedChildren="Auto fill" unCheckedChildren="Customize"/> Through collection{' '}
<Switch size={'small'} defaultChecked checkedChildren="Auto fill" unCheckedChildren="Customize" />
</div> </div>
); );
}; };
export const SourceKey = () => { export const SourceKey = () => {
return ( return <div>Source key</div>;
<div>
Source key
</div>
);
}; };
export const ForeignKey = () => { export const ForeignKey = () => {
return ( return (
<div> <div>
Foreign key <Switch size={'small'} defaultChecked checkedChildren="Auto fill" unCheckedChildren="Customize"/> Foreign key <Switch size={'small'} defaultChecked checkedChildren="Auto fill" unCheckedChildren="Customize" />
</div> </div>
); );
}; };

View File

@ -20,7 +20,7 @@ export const createdAt: IField = {
'x-read-pretty': true, 'x-read-pretty': true,
}, },
}, },
availableTypes:['date'], availableTypes: ['date'],
properties: { properties: {
...defaultProps, ...defaultProps,
...dateTimeProps, ...dateTimeProps,

View File

@ -28,7 +28,7 @@ export const createdBy: IField = {
'x-read-pretty': true, 'x-read-pretty': true,
}, },
}, },
availableTypes:['belongsTo'], availableTypes: ['belongsTo'],
properties: { properties: {
...defaultProps, ...defaultProps,
}, },

View File

@ -20,7 +20,7 @@ export const datetime: IField = {
}, },
}, },
}, },
availableTypes:['date'], availableTypes: ['date'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,

View File

@ -16,7 +16,7 @@ export const icon: IField = {
'x-component': 'IconPicker', 'x-component': 'IconPicker',
}, },
}, },
availableTypes:['string'], availableTypes: ['string'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,

View File

@ -21,7 +21,7 @@ export const id: IField = {
'x-read-pretty': true, 'x-read-pretty': true,
}, },
}, },
availableTypes:['bigInt','integer','string'], availableTypes: ['bigInt', 'integer', 'string'],
properties: { properties: {
'uiSchema.title': { 'uiSchema.title': {
type: 'string', type: 'string',

View File

@ -31,4 +31,3 @@ export * from './time';
export * from './updatedAt'; export * from './updatedAt';
export * from './updatedBy'; export * from './updatedBy';
export * from './url'; export * from './url';

View File

@ -18,7 +18,7 @@ export const input: IField = {
'x-component': 'Input', 'x-component': 'Input',
}, },
}, },
availableTypes:['string'], availableTypes: ['string'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
@ -42,12 +42,14 @@ export const input: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value(); const targetValue = field.query('.min').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Max length must greater than min length')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Max length must greater than min length',
)}' : ''
}}}`, }}}`,
}, },
min: { min: {
@ -57,13 +59,15 @@ export const input: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.max'], dependencies: ['.max'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Min length must less than max length')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Min length must less than max length',
)}' : ''}}`,
}, },
}, },
}, },
@ -75,7 +79,7 @@ export const input: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
}, },
format: { format: {
@ -86,46 +90,60 @@ export const input: IField = {
'x-component-props': { 'x-component-props': {
allowClear: true, allowClear: true,
}, },
enum: [{ enum: [
label: '{{ t("url") }}', {
value: 'url', label: '{{ t("url") }}',
}, { value: 'url',
label: '{{ t("email") }}', },
value: 'email', {
}, { label: '{{ t("email") }}',
label: '{{ t("ipv6") }}', value: 'email',
value: 'ipv6', },
}, { {
label: '{{ t("ipv4") }}', label: '{{ t("ipv6") }}',
value: 'ipv4', value: 'ipv6',
}, { },
label: '{{ t("number") }}', {
value: 'number', label: '{{ t("ipv4") }}',
}, { value: 'ipv4',
label: '{{ t("integer") }}', },
value: 'integer', {
}, { label: '{{ t("number") }}',
label: '{{ t("idcard") }}', value: 'number',
value: 'idcard', },
}, { {
label: '{{ t("qq") }}', label: '{{ t("integer") }}',
value: 'qq', value: 'integer',
}, { },
label: '{{ t("phone") }}', {
value: 'phone', label: '{{ t("idcard") }}',
}, { value: 'idcard',
label: '{{ t("money") }}', },
value: 'money', {
}, { label: '{{ t("qq") }}',
label: '{{ t("zh") }}', value: 'qq',
value: 'zh', },
}, { {
label: '{{ t("date") }}', label: '{{ t("phone") }}',
value: 'date', value: 'phone',
}, { },
label: '{{ t("zip") }}', {
value: 'zip', label: '{{ t("money") }}',
}] value: 'money',
},
{
label: '{{ t("zh") }}',
value: 'zh',
},
{
label: '{{ t("date") }}',
value: 'date',
},
{
label: '{{ t("zip") }}',
value: 'zip',
},
],
}, },
pattern: { pattern: {
type: 'string', type: 'string',
@ -135,8 +153,8 @@ export const input: IField = {
'x-component-props': { 'x-component-props': {
prefix: '/', prefix: '/',
suffix: '/', suffix: '/',
} },
}, },
}; };
} },
}; };

View File

@ -5,7 +5,7 @@ import { IField } from './types';
registerValidateFormats({ registerValidateFormats({
odd: /^-?\d*[13579]$/, odd: /^-?\d*[13579]$/,
even: /^-?\d*[02468]$/ even: /^-?\d*[02468]$/,
}); });
export const integer: IField = { export const integer: IField = {
@ -29,7 +29,7 @@ export const integer: IField = {
'x-validator': 'integer', 'x-validator': 'integer',
}, },
}, },
availableTypes:['bigInt','integer'], availableTypes: ['bigInt', 'integer'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
@ -46,12 +46,14 @@ export const integer: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.minimum').value(); const targetValue = field.query('.minimum').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Maximum must greater than minimum')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Maximum must greater than minimum',
)}' : ''
}}}`, }}}`,
}, },
minimum: { minimum: {
@ -60,13 +62,15 @@ export const integer: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.maximum'], dependencies: ['.maximum'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Minimum must less than maximum')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Minimum must less than maximum',
)}' : ''}}`,
}, },
}, },
}, },
@ -79,13 +83,16 @@ export const integer: IField = {
'x-component-props': { 'x-component-props': {
allowClear: true, allowClear: true,
}, },
enum: [{ enum: [
label: '{{ t("Odd") }}', {
value: 'odd', label: '{{ t("Odd") }}',
}, { value: 'odd',
label: '{{ t("Even") }}', },
value: 'even', {
}] label: '{{ t("Even") }}',
value: 'even',
},
],
}, },
pattern: { pattern: {
type: 'string', type: 'string',
@ -95,8 +102,8 @@ export const integer: IField = {
'x-component-props': { 'x-component-props': {
prefix: '/', prefix: '/',
suffix: '/', suffix: '/',
} },
}, },
}; };
} },
}; };

View File

@ -10,10 +10,10 @@ registerValidateRules({
} catch (error) { } catch (error) {
return { return {
type: 'error', type: 'error',
message: error.message message: error.message,
}; };
} }
} },
}); });
export const json: IField = { export const json: IField = {
@ -36,14 +36,13 @@ export const json: IField = {
// maxRows: 20, // maxRows: 20,
}, },
}, },
default: null default: null,
}, },
}, },
availableTypes:['json','array'], availableTypes: ['json', 'array'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
}, },
filterable: { filterable: {},
}
}; };

View File

@ -5,7 +5,7 @@ import {
recordPickerSelector, recordPickerSelector,
recordPickerViewer, recordPickerViewer,
relationshipType, relationshipType,
reverseFieldProperties reverseFieldProperties,
} from './properties'; } from './properties';
import { IField } from './types'; import { IField } from './types';
@ -50,7 +50,7 @@ export const m2o: IField = {
}, },
}, },
}, },
availableTypes:['belongsTo'], availableTypes: ['belongsTo'],
schemaInitialize(schema: ISchema, { block, readPretty, targetCollection }) { schemaInitialize(schema: ISchema, { block, readPretty, targetCollection }) {
if (targetCollection?.titleField && schema['x-component-props']) { if (targetCollection?.titleField && schema['x-component-props']) {
schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' }; schema['x-component-props'].fieldNames = schema['x-component-props'].fieldNames || { value: 'id' };

View File

@ -1,7 +1,7 @@
import { ISchema } from '@formily/react'; import { ISchema } from '@formily/react';
import { defaultProps } from './properties'; import { defaultProps } from './properties';
import { IField } from './types'; import { IField } from './types';
import { i18n } from '../../i18n' import { i18n } from '../../i18n';
export const markdown: IField = { export const markdown: IField = {
name: 'markdown', name: 'markdown',
@ -17,7 +17,7 @@ export const markdown: IField = {
'x-component': 'Markdown', 'x-component': 'Markdown',
}, },
}, },
availableTypes:['text'], availableTypes: ['text'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
@ -37,12 +37,14 @@ export const markdown: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value(); const targetValue = field.query('.min').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Max length must greater than min length')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Max length must greater than min length',
)}' : ''
}}}`, }}}`,
}, },
min: { min: {
@ -52,17 +54,19 @@ export const markdown: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.max'], dependencies: ['.max'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Min length must less than max length')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Min length must less than max length',
)}' : ''}}`,
}, },
}, },
}, },
}, },
}; };
} },
}; };

View File

@ -22,7 +22,7 @@ export const number: IField = {
}, },
}, },
}, },
availableTypes:['double'], availableTypes: ['double'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
@ -56,7 +56,9 @@ export const number: IField = {
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.minimum').value(); const targetValue = field.query('.minimum').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Maximum must greater than minimum')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Maximum must greater than minimum',
)}' : ''
}}}`, }}}`,
}, },
minimum: { minimum: {
@ -68,7 +70,9 @@ export const number: IField = {
dependencies: ['.maximum'], dependencies: ['.maximum'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Minimum must less than maximum')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Minimum must less than maximum',
)}' : ''}}`,
}, },
}, },
}, },
@ -81,16 +85,20 @@ export const number: IField = {
'x-component-props': { 'x-component-props': {
allowClear: true, allowClear: true,
}, },
enum: [{ enum: [
label: '{{ t("Integer") }}', {
value: 'integer', label: '{{ t("Integer") }}',
}, { value: 'integer',
label: '{{ t("Odd") }}', },
value: 'odd', {
}, { label: '{{ t("Odd") }}',
label: '{{ t("Even") }}', value: 'odd',
value: 'even', },
}] {
label: '{{ t("Even") }}',
value: 'even',
},
],
}, },
pattern: { pattern: {
type: 'string', type: 'string',
@ -100,8 +108,8 @@ export const number: IField = {
'x-component-props': { 'x-component-props': {
prefix: '/', prefix: '/',
suffix: '/', suffix: '/',
} },
}, },
}; };
} },
}; };

View File

@ -18,7 +18,7 @@ export const password: IField = {
'x-component': 'Password', 'x-component': 'Password',
}, },
}, },
availableTypes:['password'], availableTypes: ['password'],
hasDefaultValue: true, hasDefaultValue: true,
properties: { properties: {
...defaultProps, ...defaultProps,
@ -33,12 +33,14 @@ export const password: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value(); const targetValue = field.query('.min').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Max length must greater than min length')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Max length must greater than min length',
)}' : ''
}}}`, }}}`,
}, },
min: { min: {
@ -48,17 +50,19 @@ export const password: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.max'], dependencies: ['.max'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Min length must less than max length')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Min length must less than max length',
)}' : ''}}`,
}, },
}, },
}, },
}, },
}; };
} },
}; };

View File

@ -16,7 +16,7 @@ export const phone: IField = {
// title, // title,
'x-component': 'Input', 'x-component': 'Input',
'x-component-props': { 'x-component-props': {
type: 'tel' type: 'tel',
}, },
// 'x-validator': 'phone', // 'x-validator': 'phone',
}, },

View File

@ -38,12 +38,14 @@ export const richText: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value(); const targetValue = field.query('.min').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Max length must greater than min length')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Max length must greater than min length',
)}' : ''
}}}`, }}}`,
}, },
min: { min: {
@ -53,17 +55,19 @@ export const richText: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.max'], dependencies: ['.max'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Min length must less than max length')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Min length must less than max length',
)}' : ''}}`,
}, },
}, },
}, },
}, },
}; };
} },
}; };

View File

@ -38,12 +38,14 @@ export const textarea: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': `{{(field) => { 'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value(); const targetValue = field.query('.min').value();
field.selfErrors = field.selfErrors =
!!targetValue && !!field.value && targetValue > field.value ? '${i18n.t('Max length must greater than min length')}' : '' !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
'Max length must greater than min length',
)}' : ''
}}}`, }}}`,
}, },
min: { min: {
@ -53,17 +55,19 @@ export const textarea: IField = {
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'InputNumber', 'x-component': 'InputNumber',
'x-component-props': { 'x-component-props': {
precision: 0 precision: 0,
}, },
'x-reactions': { 'x-reactions': {
dependencies: ['.max'], dependencies: ['.max'],
fulfill: { fulfill: {
state: { state: {
selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t('Min length must less than max length')}' : ''}}`, selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
'Min length must less than max length',
)}' : ''}}`,
}, },
}, },
}, },
}, },
}; };
} },
}; };

View File

@ -9,6 +9,6 @@ interface IDefault {
export interface IField extends ISchema { export interface IField extends ISchema {
default?: IDefault; default?: IDefault;
operators?: any[]; operators?: any[];
filterable?: any, filterable?: any;
[key: string]: any; [key: string]: any;
} }

View File

@ -8,7 +8,7 @@ import {
useCollectionManager, useCollectionManager,
useRecord, useRecord,
useRecordIndex, useRecordIndex,
useRequest useRequest,
} from '../'; } from '../';
import { useAPIClient } from '../api-client'; import { useAPIClient } from '../api-client';

View File

@ -51,5 +51,5 @@ export const calendar: ICollectionTemplate = {
availableFieldInterfaces: { availableFieldInterfaces: {
include: [], include: [],
}, },
configurableProperties: getConfigurableProperties('title', 'name', 'inherits','category'), configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
}; };

View File

@ -21,7 +21,7 @@ const getInterfaceOptions = (data, type) => {
return interfaceOptions.filter((v) => v.children.length > 0); return interfaceOptions.filter((v) => v.children.length > 0);
}; };
const PreviewCom = (props) => { const PreviewCom = (props) => {
const { databaseView, viewName,sources, schema } = props; const { databaseView, viewName, sources, schema } = props;
const { data: fields } = useContext(ResourceActionContext); const { data: fields } = useContext(ResourceActionContext);
const api = useAPIClient(); const api = useAPIClient();
const { t } = useTranslation(); const { t } = useTranslation();
@ -175,7 +175,7 @@ const PreviewCom = (props) => {
const item = dataSource[index]; const item = dataSource[index];
return ( return (
<Input <Input
defaultValue={record?.uiSchema?.title||text} defaultValue={record?.uiSchema?.title || text}
onChange={(e) => onChange={(e) =>
handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index) handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index)
} }

View File

@ -35,9 +35,9 @@ export const expression: ICollectionTemplate = {
title: '{{t("Collection")}}', title: '{{t("Collection")}}',
'x-component': 'CollectionSelect', 'x-component': 'CollectionSelect',
'x-component-props': { 'x-component-props': {
multiple: true multiple: true,
}, },
} },
}, },
{ {
name: 'expression', name: 'expression',
@ -47,12 +47,12 @@ export const expression: ICollectionTemplate = {
type: 'string', type: 'string',
title: '{{t("Expression")}}', title: '{{t("Expression")}}',
'x-component': 'DynamicExpression', 'x-component': 'DynamicExpression',
} },
} },
], ],
}, },
availableFieldInterfaces: { availableFieldInterfaces: {
include: [], include: [],
}, },
configurableProperties: getConfigurableProperties('title', 'name', 'inherits','category'), configurableProperties: getConfigurableProperties('title', 'name', 'inherits', 'category'),
}; };

View File

@ -3,4 +3,3 @@ export * from './general';
export * from './tree'; export * from './tree';
export * from './expression'; export * from './expression';
export * from './view'; export * from './view';

View File

@ -35,11 +35,7 @@ export const DocumentTitleProvider: React.FC<{ addonBefore?: string; addonAfter?
export const RemoteDocumentTitleProvider: React.FC = (props) => { export const RemoteDocumentTitleProvider: React.FC = (props) => {
const ctx = useSystemSettings(); const ctx = useSystemSettings();
return ( return <DocumentTitleProvider addonAfter={ctx?.data?.data?.title}>{props.children}</DocumentTitleProvider>;
<DocumentTitleProvider addonAfter={ctx?.data?.data?.title}>
{props.children}
</DocumentTitleProvider>
);
}; };
export const useDocumentTitle = () => { export const useDocumentTitle = () => {

View File

@ -1,3 +1,2 @@
export * from './FilterProvider'; export * from './FilterProvider';
export * from './utils'; export * from './utils';

View File

@ -6,7 +6,7 @@ import React, { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
function pasteHtml(html, selectPastedContent = false) { function pasteHtml(html, selectPastedContent = false) {
var sel, range; let sel, range;
if (window.getSelection) { if (window.getSelection) {
// IE9 and non-IE // IE9 and non-IE
sel = window.getSelection(); sel = window.getSelection();
@ -17,15 +17,15 @@ function pasteHtml(html, selectPastedContent = false) {
// Range.createContextualFragment() would be useful here but is // Range.createContextualFragment() would be useful here but is
// only relatively recently standardized and is not supported in // only relatively recently standardized and is not supported in
// some browsers (IE9, for one) // some browsers (IE9, for one)
var el = document.createElement('div'); const el = document.createElement('div');
el.innerHTML = html; el.innerHTML = html;
var frag = document.createDocumentFragment(), let frag = document.createDocumentFragment(),
node, node,
lastNode; lastNode;
while ((node = el.firstChild)) { while ((node = el.firstChild)) {
lastNode = frag.appendChild(node); lastNode = frag.appendChild(node);
} }
var firstNode = frag.firstChild; const firstNode = frag.firstChild;
range.insertNode(frag); range.insertNode(frag);
// Preserve the selection // Preserve the selection

View File

@ -27,4 +27,3 @@ export * from './schema-templates';
export * from './settings-form'; export * from './settings-form';
export * from './system-settings'; export * from './system-settings';
export * from './user'; export * from './user';

View File

@ -2,4 +2,3 @@ export * from './context';
export * from './PinnedPluginListProvider'; export * from './PinnedPluginListProvider';
export * from './PluginManager'; export * from './PluginManager';
export * from './PluginManagerProvider'; export * from './PluginManagerProvider';

View File

@ -1,4 +1,3 @@
export * from './admin-layout'; export * from './admin-layout';
export * from './auth-layout'; export * from './auth-layout';
export * from './route-schema-component'; export * from './route-schema-component';

View File

@ -4,4 +4,3 @@ export * from './hooks';
export * from './RouteSwitch'; export * from './RouteSwitch';
export * from './RouteSwitchProvider'; export * from './RouteSwitchProvider';
export * from './types'; export * from './types';

View File

@ -7,5 +7,12 @@ import { requestChartData } from './g2plot/requestChartData';
export const AntdSchemaComponentProvider = (props) => { export const AntdSchemaComponentProvider = (props) => {
const { children } = props; const { children } = props;
return <SchemaComponentOptions scope={{ requestChartData, useFilterActionProps }} components={{ ...components, ...common } as any}>{children}</SchemaComponentOptions>; return (
<SchemaComponentOptions
scope={{ requestChartData, useFilterActionProps }}
components={{ ...components, ...common } as any}
>
{children}
</SchemaComponentOptions>
);
}; };

View File

@ -6,7 +6,7 @@ import {
Form, Form,
SchemaComponent, SchemaComponent,
SchemaComponentProvider, SchemaComponentProvider,
useActionContext useActionContext,
} from '@nocobase/client'; } from '@nocobase/client';
import React, { useState } from 'react'; import React, { useState } from 'react';

View File

@ -8,7 +8,7 @@ import {
FormLayout, FormLayout,
Input, Input,
NumberPicker, NumberPicker,
Submit Submit,
} from '@formily/antd'; } from '@formily/antd';
import { Select } from 'antd'; import { Select } from 'antd';
import { createForm, Field, onFieldValueChange } from '@formily/core'; import { createForm, Field, onFieldValueChange } from '@formily/core';
@ -62,8 +62,10 @@ function TypeSelect(props) {
return ( return (
<Select {...props}> <Select {...props}>
{Object.keys(types).map(key => ( {Object.keys(types).map((key) => (
<Select.Option key={key} value={key}>{types[key].title}</Select.Option> <Select.Option key={key} value={key}>
{types[key].title}
</Select.Option>
))} ))}
</Select> </Select>
); );
@ -163,7 +165,7 @@ const schema = {
type: { type: {
type: 'string', type: 'string',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': TypeSelect 'x-component': TypeSelect,
}, },
}, },
}, },
@ -176,7 +178,7 @@ const schema = {
properties: { properties: {
options: { options: {
type: 'object', type: 'object',
'x-component': 'ViewOptions' 'x-component': 'ViewOptions',
}, },
}, },
}, },

View File

@ -6,7 +6,7 @@ import {
SchemaComponent, SchemaComponent,
SchemaComponentProvider, SchemaComponentProvider,
SchemaInitializer, SchemaInitializer,
SchemaInitializerProvider SchemaInitializerProvider,
} from '@nocobase/client'; } from '@nocobase/client';
import React from 'react'; import React from 'react';
@ -16,7 +16,7 @@ export const AddActionButton = (props: any) => {
<SchemaInitializer.Button <SchemaInitializer.Button
insertPosition={insertPosition} insertPosition={insertPosition}
style={{ style={{
marginLeft: 8 marginLeft: 8,
}} }}
items={[ items={[
{ {

View File

@ -2,4 +2,3 @@ export * from './Action';
export * from './ActionBar'; export * from './ActionBar';
export * from './context'; export * from './context';
export * from './hooks'; export * from './hooks';

Some files were not shown because too many files have changed in this diff Show More