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
doc-site
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",
"env": {
"node": true
},
"plugins": [
"@typescript-eslint",
"react",
"react-hooks",
"prettier",
"promise"
//"import"
],
"globals": {
"sleep": true,
"prettyFormat": true
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
"settings": {
"react": {
"version": "detect"
}
},
"parserOptions": {
"ecmaVersion": 11,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react-hooks"
],
"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

@ -17,7 +17,7 @@ const api = new APIClient({
(async () => {
const response = await api.resource('test').list();
// 等价于
// 等价于
// const response = await api.request({
// url: 'test:list',
// });

View File

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

View File

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

View File

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

View File

@ -22,6 +22,10 @@
"postinstall": "nocobase postinstall",
"lint": "eslint .",
"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\"",
"release:force": "lerna publish from-package --yes",
"release": "lerna publish",
@ -40,6 +44,7 @@
"@commitlint/cli": "^16.1.0",
"@commitlint/config-conventional": "^16.0.0",
"@commitlint/prompt-cli": "^16.1.0",
"auto-changelog": "^2.4.0",
"ghooks": "^2.0.4",
"prettier": "^2.2.1",
"pretty-format": "^24.0.0",

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-charts/client';
export { default } from '@nocobase/plugin-charts/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-duplicator/client';
export { default } from '@nocobase/plugin-duplicator/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-iframe-block/client';
export { default } from '@nocobase/plugin-iframe-block/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-import/client';
export { default } from '@nocobase/plugin-import/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-multi-app-manager/client';
export { default } from '@nocobase/plugin-multi-app-manager/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-oidc/client';
export { default } from '@nocobase/plugin-oidc/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-saml/client';
export { default } from '@nocobase/plugin-saml/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-sample-hello/client';
export { default } from '@nocobase/plugin-sample-hello/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-sequence-field/client';
export { default } from '@nocobase/plugin-sequence-field/client';

View File

@ -1 +1 @@
export { default } from '@nocobase/plugin-snapshot-field/client';
export { default } from '@nocobase/plugin-snapshot-field/client';

View File

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

View File

@ -1,5 +1,5 @@
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;

View File

@ -2,5 +2,5 @@ import { AppLoggerOptions } from '@nocobase/logger';
export default {
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;

View File

@ -87,7 +87,7 @@ export class AllowManager {
aclMiddleware() {
return async (ctx, next) => {
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) {
ctx.permission = {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
// @ts-nocheck
export * 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", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _exportNames = {};
Object.defineProperty(exports, "default", {
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function get() {
return _index.default;
}
},
});
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 (key in exports && exports[key] === _index[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _index[key];
}
},
});
});

View File

@ -1,4 +1,3 @@
// @ts-nocheck
export * 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", {
value: true
Object.defineProperty(exports, '__esModule', {
value: true,
});
var _exportNames = {};
Object.defineProperty(exports, "default", {
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function get() {
return _index.default;
}
},
});
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 (key in exports && exports[key] === _index[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _index[key];
}
},
});
});

View File

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

View File

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

View File

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

View File

@ -3,4 +3,4 @@ export { RoleConfigure } from './RoleConfigure';
export { RolesResourcesActions } from './RolesResourcesActions';
export { RoleTable } from './RoleTable';
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);
expect(apiClient.axios).toBe(instance);
});
})
});
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,22 +3,22 @@ import CardForm from './CardForm';
function CardAdder({ column, onConfirm }) {
function confirmCard(card) {
onConfirm(column, card)
setAddingCard(false)
onConfirm(column, card);
setAddingCard(false);
}
const [addingCard, setAddingCard] = useState(false)
const [addingCard, setAddingCard] = useState(false);
return (
<>
{addingCard ? (
<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>
)}
</>
)
);
}
export default CardAdder;

View File

@ -3,25 +3,25 @@ import { when } from './utils';
function ColumnForm({ onConfirm, onCancel }) {
// FIXME use hook
const inputColumnTitle = createRef<any>()
const inputColumnTitle = createRef<any>();
function addColumn(event) {
event.preventDefault()
event.preventDefault();
when(inputColumnTitle.current.value)(onConfirm)
when(inputColumnTitle.current.value)(onConfirm);
}
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}>
<input type='text' ref={inputColumnTitle} autoFocus />
<button type='submit'>Add</button>
<button type='button' onClick={onCancel}>
<input type="text" ref={inputColumnTitle} autoFocus />
<button type="submit">Add</button>
<button type="button" onClick={onCancel}>
Cancel
</button>
</form>
</div>
)
);
}
export default ColumnForm
export default ColumnForm;

View File

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

View File

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

View File

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

View File

@ -1,41 +1,41 @@
function getCoordinates(event, board) {
if (event.destination === null) return {}
if (event.destination === null) return {};
const columnSource = { fromPosition: event.source.index }
const columnDestination = { toPosition: event.destination.index }
const columnSource = { fromPosition: event.source.index };
const columnDestination = { toPosition: event.destination.index };
if (isAColumnMove(event.type)) {
return { source: columnSource, destination: columnDestination }
return { source: columnSource, destination: columnDestination };
}
return {
source: { ...columnSource, fromColumnId: getColumn(board, event.source.droppableId).id },
destination: { ...columnDestination, toColumnId: getColumn(board, event.destination.droppableId).id },
}
};
}
function isAColumnMove(type) {
return type === 'BOARD'
return type === 'BOARD';
}
function getCard(board, sourceCoordinate) {
const column = board.columns.find((column) => column.id === sourceCoordinate.fromColumnId)
return column.cards[sourceCoordinate.fromPosition]
const column = board.columns.find((column) => column.id === sourceCoordinate.fromColumnId);
return column.cards[sourceCoordinate.fromPosition];
}
function getColumn(board, droppableId) {
return board.columns.find(({ id }) => String(id) === droppableId)
return board.columns.find(({ id }) => String(id) === droppableId);
}
function isMovingAColumnToAnotherPosition(coordinates) {
return coordinates.source.fromPosition !== coordinates.destination.toPosition
return coordinates.source.fromPosition !== coordinates.destination.toPosition;
}
function isMovingACardToAnotherPosition(coordinates) {
return !(
coordinates.source.fromPosition === coordinates.destination.toPosition &&
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) {
return (arg) => fns.reduce((acc, fn) => fn(acc), arg)
return (arg) => fns.reduce((acc, fn) => fn(acc), arg);
}
function partialRight(fn, ...args) {
return (...leftArgs) => fn(...leftArgs, ...args)
return (...leftArgs) => fn(...leftArgs, ...args);
}
function addInArrayAtPosition(array, element, position) {
const arrayCopy = [...array]
arrayCopy.splice(position, 0, element)
return arrayCopy
const arrayCopy = [...array];
arrayCopy.splice(position, 0, element);
return arrayCopy;
}
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) {
const removeFromArrayAtPositionFrom = partialRight(removeFromArrayAtPosition, from)
const addInArrayAtPositionTo = partialRight(addInArrayAtPosition, array[from], to)
const removeFromArrayAtPositionFrom = partialRight(removeFromArrayAtPosition, from);
const addInArrayAtPositionTo = partialRight(addInArrayAtPosition, array[from], to);
return compose(removeFromArrayAtPositionFrom, addInArrayAtPositionTo)(array)
return compose(removeFromArrayAtPositionFrom, addInArrayAtPositionTo)(array);
}
function identity(value) {
return value
return value;
}
function when(value, predicate = identity) {
return function callback(callback) {
if (predicate(value)) return callback(value)
}
if (predicate(value)) return callback(value);
};
}
function replaceElementOfArray(array) {
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) {
return Object.keys(object).reduce((obj, key) => {
return key === prop ? obj : { ...obj, [key]: object[key] }
}, {})
return key === prop ? obj : { ...obj, [key]: object[key] };
}, {});
}
export {
@ -53,4 +53,4 @@ export {
replaceElementOfArray,
partialRight,
pickPropOut,
}
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -98,7 +98,7 @@ const getSchema = (schema, category, compile): ISchema => {
};
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;
if (autoGenId) {
const pk = values.fields.find((f) => f.primaryKey);

View File

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

View File

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

View File

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

View File

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

View File

@ -10,5 +10,5 @@ export const CollectionTemplate = observer((props: any) => {
const compile = useCompile();
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;
`}
>
<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 ? (
<div
className={css`

View File

@ -23,7 +23,9 @@ export const TemplateSummay = observer((props: any) => {
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 ? (
<div
className={css`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@ export const attachment: IField = {
},
},
},
availableTypes:['belongsToMany'],
availableTypes: ['belongsToMany'],
schemaInitialize(schema: ISchema, { block }) {
if (['Table', 'Kanban'].includes(block)) {
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) => {
if (!values.through) {
values.through = `t_${uid()}`;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,7 +18,7 @@ export const input: IField = {
'x-component': 'Input',
},
},
availableTypes:['string'],
availableTypes: ['string'],
hasDefaultValue: true,
properties: {
...defaultProps,
@ -42,12 +42,14 @@ export const input: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value();
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: {
@ -57,13 +59,15 @@ export const input: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': {
dependencies: ['.max'],
fulfill: {
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-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
},
format: {
@ -86,46 +90,60 @@ export const input: IField = {
'x-component-props': {
allowClear: true,
},
enum: [{
label: '{{ t("url") }}',
value: 'url',
}, {
label: '{{ t("email") }}',
value: 'email',
}, {
label: '{{ t("ipv6") }}',
value: 'ipv6',
}, {
label: '{{ t("ipv4") }}',
value: 'ipv4',
}, {
label: '{{ t("number") }}',
value: 'number',
}, {
label: '{{ t("integer") }}',
value: 'integer',
}, {
label: '{{ t("idcard") }}',
value: 'idcard',
}, {
label: '{{ t("qq") }}',
value: 'qq',
}, {
label: '{{ t("phone") }}',
value: 'phone',
}, {
label: '{{ t("money") }}',
value: 'money',
}, {
label: '{{ t("zh") }}',
value: 'zh',
}, {
label: '{{ t("date") }}',
value: 'date',
}, {
label: '{{ t("zip") }}',
value: 'zip',
}]
enum: [
{
label: '{{ t("url") }}',
value: 'url',
},
{
label: '{{ t("email") }}',
value: 'email',
},
{
label: '{{ t("ipv6") }}',
value: 'ipv6',
},
{
label: '{{ t("ipv4") }}',
value: 'ipv4',
},
{
label: '{{ t("number") }}',
value: 'number',
},
{
label: '{{ t("integer") }}',
value: 'integer',
},
{
label: '{{ t("idcard") }}',
value: 'idcard',
},
{
label: '{{ t("qq") }}',
value: 'qq',
},
{
label: '{{ t("phone") }}',
value: 'phone',
},
{
label: '{{ t("money") }}',
value: 'money',
},
{
label: '{{ t("zh") }}',
value: 'zh',
},
{
label: '{{ t("date") }}',
value: 'date',
},
{
label: '{{ t("zip") }}',
value: 'zip',
},
],
},
pattern: {
type: 'string',
@ -135,8 +153,8 @@ export const input: IField = {
'x-component-props': {
prefix: '/',
suffix: '/',
}
},
},
};
}
},
};

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
import { ISchema } from '@formily/react';
import { defaultProps } from './properties';
import { IField } from './types';
import { i18n } from '../../i18n'
import { i18n } from '../../i18n';
export const markdown: IField = {
name: 'markdown',
@ -17,7 +17,7 @@ export const markdown: IField = {
'x-component': 'Markdown',
},
},
availableTypes:['text'],
availableTypes: ['text'],
hasDefaultValue: true,
properties: {
...defaultProps,
@ -37,12 +37,14 @@ export const markdown: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value();
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: {
@ -52,17 +54,19 @@ export const markdown: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': {
dependencies: ['.max'],
fulfill: {
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,
properties: {
...defaultProps,
@ -56,7 +56,9 @@ export const number: IField = {
'x-reactions': `{{(field) => {
const targetValue = field.query('.minimum').value();
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: {
@ -68,7 +70,9 @@ export const number: IField = {
dependencies: ['.maximum'],
fulfill: {
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': {
allowClear: true,
},
enum: [{
label: '{{ t("Integer") }}',
value: 'integer',
}, {
label: '{{ t("Odd") }}',
value: 'odd',
}, {
label: '{{ t("Even") }}',
value: 'even',
}]
enum: [
{
label: '{{ t("Integer") }}',
value: 'integer',
},
{
label: '{{ t("Odd") }}',
value: 'odd',
},
{
label: '{{ t("Even") }}',
value: 'even',
},
],
},
pattern: {
type: 'string',
@ -100,8 +108,8 @@ export const number: IField = {
'x-component-props': {
prefix: '/',
suffix: '/',
}
},
},
};
}
},
};

View File

@ -18,7 +18,7 @@ export const password: IField = {
'x-component': 'Password',
},
},
availableTypes:['password'],
availableTypes: ['password'],
hasDefaultValue: true,
properties: {
...defaultProps,
@ -33,12 +33,14 @@ export const password: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value();
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: {
@ -48,17 +50,19 @@ export const password: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': {
dependencies: ['.max'],
fulfill: {
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,
'x-component': 'Input',
'x-component-props': {
type: 'tel'
type: 'tel',
},
// 'x-validator': 'phone',
},

View File

@ -38,12 +38,14 @@ export const richText: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value();
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: {
@ -53,17 +55,19 @@ export const richText: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': {
dependencies: ['.max'],
fulfill: {
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-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': `{{(field) => {
const targetValue = field.query('.min').value();
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: {
@ -53,17 +55,19 @@ export const textarea: IField = {
'x-decorator': 'FormItem',
'x-component': 'InputNumber',
'x-component-props': {
precision: 0
precision: 0,
},
'x-reactions': {
dependencies: ['.max'],
fulfill: {
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 {
default?: IDefault;
operators?: any[];
filterable?: any,
filterable?: any;
[key: string]: any;
}

View File

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

View File

@ -51,5 +51,5 @@ export const calendar: ICollectionTemplate = {
availableFieldInterfaces: {
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);
};
const PreviewCom = (props) => {
const { databaseView, viewName,sources, schema } = props;
const { databaseView, viewName, sources, schema } = props;
const { data: fields } = useContext(ResourceActionContext);
const api = useAPIClient();
const { t } = useTranslation();
@ -175,7 +175,7 @@ const PreviewCom = (props) => {
const item = dataSource[index];
return (
<Input
defaultValue={record?.uiSchema?.title||text}
defaultValue={record?.uiSchema?.title || text}
onChange={(e) =>
handleFieldChange({ ...item, uiSchema: { ...item?.uiSchema, title: e.target.value } }, index)
}

View File

@ -35,9 +35,9 @@ export const expression: ICollectionTemplate = {
title: '{{t("Collection")}}',
'x-component': 'CollectionSelect',
'x-component-props': {
multiple: true
multiple: true,
},
}
},
},
{
name: 'expression',
@ -47,12 +47,12 @@ export const expression: ICollectionTemplate = {
type: 'string',
title: '{{t("Expression")}}',
'x-component': 'DynamicExpression',
}
}
},
},
],
},
availableFieldInterfaces: {
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 './expression';
export * from './view';

View File

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

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