base_commit stringlengths 40 40 | created_at stringdate 2013-07-19 17:10:26 2025-07-23 01:54:17 | hints_text stringlengths 0 525k | instance_id stringlengths 10 60 | patch stringlengths 174 256k | pr_description stringlengths 3 99.8k | problem_statement stringlengths 0 6.69k | pull_number int64 1 61.8k | repo stringlengths 5 54 | test_patch stringlengths 173 254k | FAIL_TO_PASS listlengths 1 122k | PASS_TO_PASS listlengths 0 190k | interface stringlengths 4 33.3k | license stringclasses 11 values | install_config dict | meta dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6885663c1110693e29ecc7736f75f1a466952982 | 2023-10-11 08:03:57 | baidu__amis-8354 | diff --git a/docs/zh-CN/components/crud.md b/docs/zh-CN/components/crud.md
index 7a3db1a77..971314e2c 100755
--- a/docs/zh-CN/components/crud.md
+++ b/docs/zh-CN/components/crud.md
@@ -2795,7 +2795,6 @@ CRUD 中不限制有多少个单条操作、添加一个操作对应的添加一
> 本文中的例子为了不相互影响都关闭了这个功能。
> 另外如果需要使用接口联动,需要设置`syncLocation: false`
-
`syncLocation`开启后,数据域经过地址栏同步后,原始值被转化为字符串同步回数据域,但布尔值(boolean)同步后不符合预期数据结构,导致组件渲染出错。比如查询条件表单中包含[Checkbox](./form/checkbox)组件,此时可以设置`{"trueValue": "1", "falseValue": "0"}`,将真值和假值设置为字符串格式规避。
## 前端一次性加载
@@ -2846,8 +2845,6 @@ CRUD 中不限制有多少个单条操作、添加一个操作对应的添加一
"syncLocation": false,
"api": "/api/mock2/sample",
"loadDataOnce": true,
- "autoGenerateFilter": true,
- "filterSettingSource": ["browser", "version"],
"columns": [
{
"name": "id",
@@ -2895,6 +2892,131 @@ CRUD 中不限制有多少个单条操作、添加一个操作对应的添加一
> **注意:**如果你的数据量较大,请务必使用服务端分页的方案,过多的前端数据展示,会显著影响前端页面的性能
+另外前端一次性加载当有查寻条件的时候,默认还是会重新请求一次,如果配置 `loadDataOnceFetchOnFilter` 为 `false` 则为前端过滤。
+
+```schema: scope="body"
+{
+ "type": "crud",
+ "syncLocation": false,
+ "api": "/api/mock2/sample",
+ "loadDataOnce": true,
+ "loadDataOnceFetchOnFilter": false,
+ "autoGenerateFilter": true,
+ "columns": [
+ {
+ "name": "id",
+ "label": "ID"
+ },
+ {
+ "name": "engine",
+ "label": "Rendering engine"
+ },
+ {
+ "name": "browser",
+ "label": "Browser"
+ },
+ {
+ "name": "platform",
+ "label": "Platform(s)"
+ },
+ {
+ "name": "version",
+ "label": "Engine version",
+ "searchable": {
+ "type": "select",
+ "name": "version",
+ "label": "Engine version",
+ "clearable": true,
+ "multiple": true,
+ "searchable": true,
+ "checkAll": true,
+ "options": [
+ "1.7",
+ "3.3",
+ "5.6"
+ ],
+ "maxTagCount": 10,
+ "extractValue": true,
+ "joinValues": false,
+ "delimiter": ",",
+ "defaultCheckAll": false,
+ "checkAllLabel": "全选"
+ }
+ },
+ {
+ "name": "grade",
+ "label": "CSS grade"
+ }
+ ]
+}
+```
+
+`loadDataOnceFetchOnFilter` 配置成 `true` 则会强制重新请求接口比如以下用法
+
+> 此时如果不配置或者配置为 `false` 是前端直接过滤,不过记得配置 name 为行数据中的属性,如果行数据中没有对应属性则不会起作用
+
+```schema: scope="body"
+{
+ "type": "crud",
+ "syncLocation": false,
+ "api": "/api/mock2/sample",
+ "loadDataOnce": true,
+ "loadDataOnceFetchOnFilter": true,
+ "headerToolbar": [
+ {
+ "type": "search-box",
+ "name": "keywords"
+ }
+ ],
+ "columns": [
+ {
+ "name": "id",
+ "label": "ID"
+ },
+ {
+ "name": "engine",
+ "label": "Rendering engine"
+ },
+ {
+ "name": "browser",
+ "label": "Browser"
+ },
+ {
+ "name": "platform",
+ "label": "Platform(s)"
+ },
+ {
+ "name": "version",
+ "label": "Engine version",
+ "searchable": {
+ "type": "select",
+ "name": "version",
+ "label": "Engine version",
+ "clearable": true,
+ "multiple": true,
+ "searchable": true,
+ "checkAll": true,
+ "options": [
+ "1.7",
+ "3.3",
+ "5.6"
+ ],
+ "maxTagCount": 10,
+ "extractValue": true,
+ "joinValues": false,
+ "delimiter": ",",
+ "defaultCheckAll": false,
+ "checkAllLabel": "全选"
+ }
+ },
+ {
+ "name": "grade",
+ "label": "CSS grade"
+ }
+ ]
+}
+```
+
## 动态列
> since 1.1.6
diff --git a/examples/components/CRUD/List.jsx b/examples/components/CRUD/List.jsx
index 15d65c389..18aef7409 100644
--- a/examples/components/CRUD/List.jsx
+++ b/examples/components/CRUD/List.jsx
@@ -3,32 +3,18 @@ export default {
remark: 'bla bla bla',
body: {
type: 'crud',
- api: '/api/sample',
+ name: 'thelist',
+ api: {
+ method: 'get',
+ url: '/api/sample',
+ sendOn: '${mode}'
+ },
mode: 'list',
draggable: true,
saveOrderApi: {
url: '/api/sample/saveOrder'
},
orderField: 'weight',
- filter: {
- title: '条件搜索',
- submitText: '',
- body: [
- {
- type: 'input-text',
- name: 'keywords',
- placeholder: '通过关键字搜索',
- addOn: {
- label: '搜索',
- type: 'submit'
- }
- },
- {
- type: 'plain',
- text: '这只是个示例, 目前搜索对查询结果无效.'
- }
- ]
- },
affixHeader: true,
bulkActions: [
{
@@ -63,6 +49,44 @@ export default {
],
quickSaveApi: '/api/sample/bulkUpdate',
quickSaveItemApi: '/api/sample/$id',
+ headerToolbar: [
+ {
+ type: 'form',
+ mode: 'inline',
+ wrapWithPanel: false,
+ submitOnChange: true,
+ submitOnInit: true,
+ target: 'thelist',
+ body: [
+ {
+ type: 'select',
+ name: 'mode',
+ className: 'mb-0',
+ selectFirst: true,
+ options: [
+ {
+ label: '模式 1',
+ value: 'mode1'
+ },
+ {
+ label: '模式 2',
+ value: 'mode2'
+ }
+ ]
+ },
+ {
+ type: 'input-text',
+ name: 'keywords',
+ placeholder: '通过关键字搜索',
+ className: 'mb-0',
+ addOn: {
+ label: '搜索',
+ type: 'submit'
+ }
+ }
+ ]
+ }
+ ],
listItem: {
actions: [
{
diff --git a/fis-conf.js b/fis-conf.js
index 98590a300..fb70f4d97 100644
--- a/fis-conf.js
+++ b/fis-conf.js
@@ -253,7 +253,7 @@ fis.match('*.html:jsx', {
// 这些用了 esm
fis.match(
- '{echarts/**.js,zrender/**.js,echarts-wordcloud/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js,axios/**.js}',
+ '{echarts/**.js,zrender/**.js,echarts-wordcloud/**.js,markdown-it-html5-media/**.js,react-hook-form/**.js,qrcode.react/**.js,axios/**.js,downshift/**.js,react-intersection-observer/**.js}',
{
parser: fis.plugin('typescript', {
sourceMap: false,
diff --git a/packages/amis-core/src/WithStore.tsx b/packages/amis-core/src/WithStore.tsx
index 6e1c37aee..6c9a0d4b9 100644
--- a/packages/amis-core/src/WithStore.tsx
+++ b/packages/amis-core/src/WithStore.tsx
@@ -252,7 +252,7 @@ export function HocStoreFactory(renderer: {
props.store?.storeType === 'ComboStore'
? undefined
: syncDataFromSuper(
- store.data,
+ props.data,
(props.data as any).__super,
(prevProps.data as any).__super,
store,
diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx
index 3f88f3910..e33734f60 100644
--- a/packages/amis-core/src/renderers/Form.tsx
+++ b/packages/amis-core/src/renderers/Form.tsx
@@ -1154,6 +1154,8 @@ export default class Form extends React.Component<FormProps, object> {
if (target) {
this.submitToTarget(filterTarget(target, values), values);
+ /** 可能配置页面跳转事件,页面路由变化导致persistKey不一致,无法清除持久化数据,所以提交成功事件之前先清理一下 */
+ clearPersistDataAfterSubmit && store.clearLocalPersistData();
dispatchEvent('submitSucc', createObject(this.props.data, values));
} else if (action.actionType === 'reload') {
action.target &&
@@ -1185,6 +1187,7 @@ export default class Form extends React.Component<FormProps, object> {
? filter(saveFailed, store.data)
: undefined,
onSuccess: async (result: Payload) => {
+ clearPersistDataAfterSubmit && store.clearLocalPersistData();
// result为提交接口返回的内容
const dispatcher = await dispatchEvent(
'submitSucc',
@@ -1245,6 +1248,7 @@ export default class Form extends React.Component<FormProps, object> {
});
});
} else {
+ clearPersistDataAfterSubmit && store.clearLocalPersistData();
// type为submit,但是没有配api以及target时,只派发事件
dispatchEvent('submitSucc', createObject(this.props.data, values));
}
diff --git a/packages/amis-core/src/store/crud.ts b/packages/amis-core/src/store/crud.ts
index e7c546a94..d254a63f5 100644
--- a/packages/amis-core/src/store/crud.ts
+++ b/packages/amis-core/src/store/crud.ts
@@ -61,12 +61,11 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
// 因为会把数据呈现在地址栏上。
return createObject(
createObject(self.data, {
- ...self.query,
items: self.items.concat(),
selectedItems: self.selectedItems.concat(),
unSelectedItems: self.unSelectedItems.concat()
}),
- {}
+ {...self.query}
);
},
@@ -145,8 +144,7 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
data?: object,
options?: fetchOptions & {
forceReload?: boolean;
- loadDataOnce?: boolean; // 配置数据是否一次性加载,如果是这样,由前端来完成分页,排序等功能。
- loadDataOnceFetchOnFilter?: boolean; // 在开启loadDataOnce时,filter时是否去重新请求api
+ loadDataOnce?: boolean; // 配置数据是否一次性加载,如果是这样,由前端来完成分页,排序等
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
loadDataMode?: boolean;
syncResponse2Query?: boolean;
@@ -159,7 +157,6 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
options: fetchOptions & {
forceReload?: boolean;
loadDataOnce?: boolean; // 配置数据是否一次性加载,如果是这样,由前端来完成分页,排序等功能。
- loadDataOnceFetchOnFilter?: boolean; // 在开启loadDataOnce时,filter时是否去重新请求api
source?: string; // 支持自定义属于映射,默认不配置,读取 rows 或者 items
loadDataMode?: boolean;
syncResponse2Query?: boolean;
@@ -181,36 +178,36 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
if (Array.isArray(options.columns)) {
options.columns.forEach((column: any) => {
- let value: any;
+ let value: any =
+ typeof column.name === 'string'
+ ? getVariable(self.query, column.name)
+ : undefined;
const key = column.name;
- if ((column.searchable || column.filterable) && key) {
+ if (value != null && key) {
// value可能为null、undefined、''、0
- value = getVariable(self.query, key);
- if (value != null) {
- if (Array.isArray(value)) {
- if (value.length > 0) {
- const arr = [...items];
- let arrItems: Array<any> = [];
- value.forEach(item => {
- arrItems = [
- ...arrItems,
- ...matchSorter(arr, item, {
- keys: [key],
- threshold: matchSorter.rankings.CONTAINS
- })
- ];
- });
- items = items.filter((item: any) =>
- arrItems.find(a => a === item)
- );
- }
- } else {
- items = matchSorter(items, value, {
- keys: [key],
- threshold: matchSorter.rankings.CONTAINS
+ if (Array.isArray(value)) {
+ if (value.length > 0) {
+ const arr = [...items];
+ let arrItems: Array<any> = [];
+ value.forEach(item => {
+ arrItems = [
+ ...arrItems,
+ ...matchSorter(arr, item, {
+ keys: [key],
+ threshold: matchSorter.rankings.CONTAINS
+ })
+ ];
});
+ items = items.filter((item: any) =>
+ arrItems.find(a => a === item)
+ );
}
+ } else {
+ items = matchSorter(items, value, {
+ keys: [key],
+ threshold: matchSorter.rankings.CONTAINS
+ });
}
}
});
diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts
index bd7ec4a84..af99148db 100644
--- a/packages/amis-core/src/store/table.ts
+++ b/packages/amis-core/src/store/table.ts
@@ -1017,6 +1017,7 @@ export const TableStore = iRendererStore
index,
width: origin?.width || 0,
minWidth: origin?.minWidth || 0,
+ realWidth: origin?.realWidth || 0,
rawIndex: index - PARTITION_INDEX,
type: item.type || 'plain',
pristine: item.pristine || item,
diff --git a/packages/amis-core/src/utils/debug.tsx b/packages/amis-core/src/utils/debug.tsx
index c15e9507b..8f4a23371 100644
--- a/packages/amis-core/src/utils/debug.tsx
+++ b/packages/amis-core/src/utils/debug.tsx
@@ -8,10 +8,12 @@ import {findDOMNode, render, unmountComponentAtNode} from 'react-dom';
// import {createRoot} from 'react-dom/client';
import {autorun, observable} from 'mobx';
import {observer} from 'mobx-react';
-import {uuidv4} from './helper';
+import {uuidv4, importLazyComponent} from './helper';
import position from './position';
-export const JsonView = React.lazy(() => import('react-json-view'));
+export const JsonView = React.lazy(() =>
+ import('react-json-view').then(importLazyComponent)
+);
class Log {
@observable cat = '';
diff --git a/packages/amis-core/src/utils/helper.ts b/packages/amis-core/src/utils/helper.ts
index 3d4fa48b4..71ddc701d 100644
--- a/packages/amis-core/src/utils/helper.ts
+++ b/packages/amis-core/src/utils/helper.ts
@@ -1587,7 +1587,7 @@ export function mapObject(
}
if (Array.isArray(value)) {
- return value.map(item => mapObject(item, fn));
+ return value.map(item => mapObject(item, fn, skipFn));
}
if (isObject(value)) {
@@ -1595,7 +1595,8 @@ export function mapObject(
Object.keys(tmpValue).forEach(key => {
(tmpValue as PlainObject)[key] = mapObject(
(tmpValue as PlainObject)[key],
- fn
+ fn,
+ skipFn
);
});
return tmpValue;
@@ -2174,3 +2175,8 @@ export function evalTrackExpression(
})
.join('');
}
+
+// 很奇怪的问题,react-json-view import 有些情况下 mod.default 才是 esModule
+export function importLazyComponent(mod: any) {
+ return mod.default.__esModule ? mod.default : mod;
+}
diff --git a/packages/amis-editor-core/src/component/Preview.tsx b/packages/amis-editor-core/src/component/Preview.tsx
index c8e62b71e..66ce6f045 100644
--- a/packages/amis-editor-core/src/component/Preview.tsx
+++ b/packages/amis-editor-core/src/component/Preview.tsx
@@ -413,24 +413,37 @@ export default class Preview extends Component<PreviewProps> {
@autobind
handleDragEnter(e: React.DragEvent) {
+ if (!this.props.editable) {
+ // 非编辑态下不监听拖拽事件
+ return;
+ }
const manager = this.props.manager;
manager.dnd.dragEnter(e.nativeEvent);
}
@autobind
handleDragLeave(e: React.DragEvent) {
+ if (!this.props.editable) {
+ return;
+ }
const manager = this.props.manager;
manager.dnd.dragLeave(e.nativeEvent);
}
@autobind
handleDragOver(e: React.DragEvent) {
+ if (!this.props.editable) {
+ return;
+ }
const manager = this.props.manager;
manager.dnd.dragOver(e.nativeEvent);
}
@autobind
handleDrop(e: React.DragEvent) {
+ if (!this.props.editable) {
+ return;
+ }
const manager = this.props.manager;
manager.dnd.drop(e.nativeEvent);
}
diff --git a/packages/amis-editor-core/src/component/base/SearchPanel.tsx b/packages/amis-editor-core/src/component/base/SearchPanel.tsx
index c486defea..a71c74d30 100644
--- a/packages/amis-editor-core/src/component/base/SearchPanel.tsx
+++ b/packages/amis-editor-core/src/component/base/SearchPanel.tsx
@@ -4,6 +4,7 @@ import {Icon, InputBox, resolveVariable} from 'amis';
import cx from 'classnames';
import {autobind, stringRegExp} from '../../util';
import isString from 'lodash/isString';
+import {matchSorter} from 'match-sorter';
/**
* 通用搜索功能组件,附带以下功能:
@@ -182,7 +183,7 @@ export default class SearchPanel extends React.Component<
/**
* 根据关键字过滤数据,按分组存放
*/
- groupedResultByKeyword(keywords?: string) {
+ groupedResultByKeyword(keywords: string = '') {
const {allResult} = this.props;
let curSearchResult: any[] = [];
let curSearchResultByTag: {
@@ -194,21 +195,15 @@ export default class SearchPanel extends React.Component<
? new RegExp(stringRegExp(curKeyword), 'i')
: null;
- allResult.forEach(item => {
- if (isString(item) && regular && regular.test(item)) {
+ if (allResult.length && isString(allResult[0])) {
+ matchSorter(allResult, keywords).forEach(item => {
// 兼容字符串类型
curSearchResult.push(item);
- } else if (
- !keywords ||
- ['name', 'description', 'scaffold.type', 'searchKeywords'].some(key => {
- return (
- resolveVariable(key, item) &&
- regular &&
- (regular.test(resolveVariable(key, item)) ||
- regular.test(resolveVariable(key, item)?.replaceAll('-', '')))
- );
- })
- ) {
+ });
+ } else {
+ matchSorter(allResult, keywords, {
+ keys: ['name', 'description', 'scaffold.type', 'searchKeywords']
+ }).forEach(item => {
if (item[curTagKey]) {
const tags = Array.isArray(item[curTagKey])
? item[curTagKey].concat()
@@ -222,8 +217,8 @@ export default class SearchPanel extends React.Component<
} else {
curSearchResult.push(item);
}
- }
- });
+ });
+ }
// 更新当前搜索结果数据(备注: 附带重置功能)
this.setState({
diff --git a/packages/amis-editor-core/src/plugin/DataDebug.tsx b/packages/amis-editor-core/src/plugin/DataDebug.tsx
index b68429d0d..0e26fc97a 100644
--- a/packages/amis-editor-core/src/plugin/DataDebug.tsx
+++ b/packages/amis-editor-core/src/plugin/DataDebug.tsx
@@ -1,7 +1,10 @@
import {registerEditorPlugin} from '../manager';
import {BaseEventContext, BasePlugin, BasicToolbarItem} from '../plugin';
import React from 'react';
-export const JsonView = React.lazy(() => import('react-json-view'));
+import {importLazyComponent} from 'amis-core';
+export const JsonView = React.lazy(() =>
+ import('react-json-view').then(importLazyComponent)
+);
/**
* 添加调试功能
diff --git a/packages/amis-editor-core/src/store/editor.ts b/packages/amis-editor-core/src/store/editor.ts
index 8a9cadd25..62fa33294 100644
--- a/packages/amis-editor-core/src/store/editor.ts
+++ b/packages/amis-editor-core/src/store/editor.ts
@@ -53,6 +53,7 @@ import isPlainObject from 'lodash/isPlainObject';
import {EditorManagerConfig} from '../manager';
import {EditorNode, EditorNodeType} from './node';
import findIndex from 'lodash/findIndex';
+import {matchSorter} from 'match-sorter';
export interface SchemaHistory {
versionId: number;
@@ -684,39 +685,26 @@ export const MainStore = types
/** 根据关键字过滤组件 */
groupedRenderersByKeyword(
_subRenderers: Array<SubRendererInfo>,
- keywords?: string
+ keywords: string = ''
) {
const subRenderers = _subRenderers;
const grouped: {
[propName: string]: Array<SubRendererInfo>;
} = {};
- const regular = keywords
- ? new RegExp(stringRegExp(keywords), 'i')
- : null;
-
- subRenderers.forEach(item => {
- if (
- !keywords ||
- ['name', 'description', 'scaffold.type', 'searchKeywords'].some(
- key =>
- resolveVariable(key, item) &&
- regular &&
- (regular.test(resolveVariable(key, item)) ||
- regular.test(resolveVariable(key, item)?.replaceAll('-', '')))
- )
- ) {
- const tags = Array.isArray(item.tags)
- ? item.tags.concat()
- : item.tags
- ? [item.tags]
- : ['其他'];
-
- tags.forEach(tag => {
- grouped[tag] = grouped[tag] || [];
- grouped[tag].push(item);
- });
- }
+ matchSorter(subRenderers, keywords, {
+ keys: ['name', 'description', 'scaffold.type', 'searchKeywords']
+ }).forEach(item => {
+ const tags = Array.isArray(item.tags)
+ ? item.tags.concat()
+ : item.tags
+ ? [item.tags]
+ : ['其他'];
+
+ tags.forEach(tag => {
+ grouped[tag] = grouped[tag] || [];
+ grouped[tag].push(item);
+ });
});
return grouped;
diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts
index 65f87f69b..4529381b8 100644
--- a/packages/amis-editor-core/src/util.ts
+++ b/packages/amis-editor-core/src/util.ts
@@ -1063,14 +1063,12 @@ export function getI18nEnabled() {
}
/** schema 翻译方法 */
-export function translateSchema(schema: any, replaceData?: any) {
+export function translateSchema(schema: any, replaceData?: any, skipFn?: any) {
replaceData = replaceData || (window as any)?.editorStore?.appCorpusData;
if (!isPlainObject(replaceData)) {
return schema;
}
- return mapObject(schema, (item: any) => {
- return replaceData[item] || item;
- });
+ return mapObject(schema, (item: any) => replaceData[item] || item, skipFn);
}
/** 应用级别的翻译方法 */
diff --git a/packages/amis-editor/src/renderer/FormulaControl.tsx b/packages/amis-editor/src/renderer/FormulaControl.tsx
index f00316787..b6c03d110 100644
--- a/packages/amis-editor/src/renderer/FormulaControl.tsx
+++ b/packages/amis-editor/src/renderer/FormulaControl.tsx
@@ -515,16 +515,16 @@ export default class FormulaControl extends React.Component<
} else {
curRendererSchema.placeholder = '请输入静态值';
}
- // 设置popOverContainer
- curRendererSchema.popOverContainer = window.document.body;
}
+ JSONPipeOut(curRendererSchema);
+
// 对 schema 进行国际化翻译
if (this.appLocale && this.appCorpusData) {
return translateSchema(curRendererSchema, this.appCorpusData);
}
- return JSONPipeOut(curRendererSchema);
+ return curRendererSchema;
}
@autobind
diff --git a/packages/amis-formula/src/doc.md b/packages/amis-formula/src/doc.md
index f571ac097..37b95f335 100644
--- a/packages/amis-formula/src/doc.md
+++ b/packages/amis-formula/src/doc.md
@@ -268,6 +268,17 @@
取数据最后一个。
+### POW
+
+用法:`POW(base, exponent)`
+
+ * `base:number` 基数
+ * `exponent:number` 指数
+
+返回:`number` 基数的指数次幂
+
+返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。
+
## 文本函数
### LEFT
diff --git a/packages/amis-formula/src/doc.ts b/packages/amis-formula/src/doc.ts
index c3a72cf65..5291b3029 100644
--- a/packages/amis-formula/src/doc.ts
+++ b/packages/amis-formula/src/doc.ts
@@ -465,6 +465,29 @@ export const doc: {
},
namespace: '数学函数'
},
+ {
+ name: 'POW',
+ description:
+ '返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。',
+ example: 'POW(base, exponent)',
+ params: [
+ {
+ type: 'number',
+ name: 'base',
+ description: '基数'
+ },
+ {
+ type: 'number',
+ name: 'exponent',
+ description: '指数'
+ }
+ ],
+ returns: {
+ type: 'number',
+ description: '基数的指数次幂'
+ },
+ namespace: '数学函数'
+ },
{
name: 'LEFT',
description: '返回传入文本左侧的指定长度字符串。',
diff --git a/packages/amis-formula/src/evalutor.ts b/packages/amis-formula/src/evalutor.ts
index 7befa4b79..8e44dc051 100644
--- a/packages/amis-formula/src/evalutor.ts
+++ b/packages/amis-formula/src/evalutor.ts
@@ -13,6 +13,7 @@ import uniqBy from 'lodash/uniqBy';
import isEqual from 'lodash/isEqual';
import isPlainObject from 'lodash/isPlainObject';
import get from 'lodash/get';
+import isNumber from 'lodash/isNumber';
import {EvaluatorOptions, FilterContext, FilterMap, FunctionMap} from './types';
import {FormulaEvalError} from './error';
@@ -978,6 +979,24 @@ export class Evaluator {
return arr.length ? arr[arr.length - 1] : null;
}
+ /**
+ * 返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。
+ *
+ * @example POW(base, exponent)
+ * @param {number} base 基数
+ * @param {number} exponent 指数
+ * @namespace 数学函数
+ *
+ * @returns {number} 基数的指数次幂
+ */
+ fnPOW(base: number, exponent: number) {
+ if (!isNumber(base) || !isNumber(exponent)) {
+ return base;
+ }
+
+ return Math.pow(base, exponent);
+ }
+
// 文本函数
normalizeText(raw: any) {
diff --git a/packages/amis-ui/scss/components/form/_result-list.scss b/packages/amis-ui/scss/components/form/_result-list.scss
index de4de56a6..08de5947a 100644
--- a/packages/amis-ui/scss/components/form/_result-list.scss
+++ b/packages/amis-ui/scss/components/form/_result-list.scss
@@ -53,6 +53,7 @@
> label {
flex-basis: px2rem(50px);
flex-grow: 1;
+ width: px2rem(50px);
&.is-invalid {
color: var(--Form-selectValue-onInvalid-color);
diff --git a/packages/amis-ui/scss/components/form/_selection.scss b/packages/amis-ui/scss/components/form/_selection.scss
index b1bae3fae..ae5b59927 100644
--- a/packages/amis-ui/scss/components/form/_selection.scss
+++ b/packages/amis-ui/scss/components/form/_selection.scss
@@ -38,6 +38,12 @@
margin-right: var(--Checkbox-gap);
}
}
+
+ &-ellipsis-line {
+ display: inline-block;
+ width: 100%;
+ @include truncate();
+ }
}
.#{$ns}GroupedSelection {
@@ -104,6 +110,7 @@
&-itemLabel {
flex-grow: 1;
+ overflow: hidden;
span {
vertical-align: middle;
diff --git a/packages/amis-ui/src/components/ChainedSelection.tsx b/packages/amis-ui/src/components/ChainedSelection.tsx
index 9cc4b9efc..30b110e1b 100644
--- a/packages/amis-ui/src/components/ChainedSelection.tsx
+++ b/packages/amis-ui/src/components/ChainedSelection.tsx
@@ -106,7 +106,8 @@ export class ChainedSelection extends BaseSelection<
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled,
- labelField
+ labelField,
+ classnames: cx
})}
</div>
</div>
@@ -153,7 +154,8 @@ export class ChainedSelection extends BaseSelection<
checked: !!~this.state.selected.indexOf(id),
onChange: () => this.selectOption(option, depth, id),
disabled: disabled || option.disabled,
- labelField
+ labelField,
+ classnames: cx
})}
</div>
diff --git a/packages/amis-ui/src/components/GroupedSelection.tsx b/packages/amis-ui/src/components/GroupedSelection.tsx
index 636574547..d8ee8ee46 100644
--- a/packages/amis-ui/src/components/GroupedSelection.tsx
+++ b/packages/amis-ui/src/components/GroupedSelection.tsx
@@ -48,7 +48,8 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
checked: false,
onChange: () => undefined,
disabled: disabled || option.disabled,
- labelField
+ labelField,
+ classnames: cx
})}
</div>
@@ -92,7 +93,8 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
checked: false,
onChange: () => undefined,
disabled: disabled || option.disabled,
- labelField
+ labelField,
+ classnames: cx
})}
</div>
</div>
@@ -161,7 +163,8 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled,
- labelField
+ labelField,
+ classnames: cx
})}
</div>
</div>
diff --git a/packages/amis-ui/src/components/ResultList.tsx b/packages/amis-ui/src/components/ResultList.tsx
index a331cca1a..a97fbbadc 100644
--- a/packages/amis-ui/src/components/ResultList.tsx
+++ b/packages/amis-ui/src/components/ResultList.tsx
@@ -5,13 +5,13 @@ import React from 'react';
import Sortable from 'sortablejs';
import {findDOMNode} from 'react-dom';
import cloneDeep from 'lodash/cloneDeep';
+import cx from 'classnames';
import {Option, Options} from './Select';
import {ThemeProps, themeable} from 'amis-core';
import {Icon} from './icons';
import {autobind, guid} from 'amis-core';
-import {LocaleProps, localeable} from 'amis-core';
-import {BaseSelection, BaseSelectionProps} from './Selection';
+import {LocaleProps, localeable, ClassNamesFn} from 'amis-core';
import TransferSearch from './TransferSearch';
import VirtualList, {AutoSizer} from './virtual-list';
@@ -39,6 +39,7 @@ export interface ItemRenderStates {
index: number;
disabled?: boolean;
labelField?: string;
+ classnames: ClassNamesFn;
onChange: (value: any, name: string) => void;
}
@@ -51,10 +52,20 @@ export class ResultList extends React.Component<
ResultListState
> {
static itemRender(option: Option, states: ItemRenderStates) {
+ const scopeLabel = option.scopeLabel || '';
+ const label = option[states?.labelField || 'label'];
+ const canScopeLabelTitle =
+ typeof scopeLabel === 'string' || typeof scopeLabel === 'number';
+ const canLabelTitle =
+ typeof label === 'string' || typeof label === 'number';
+ const title =
+ canScopeLabelTitle && canLabelTitle ? `${scopeLabel}${label}` : '';
+ const classnames = states.classnames;
return (
- <span>{`${option.scopeLabel || ''}${
- option[states?.labelField || 'label']
- }`}</span>
+ <span title={title} className={classnames('Selection-ellipsis-line')}>
+ {scopeLabel}
+ {label}
+ </span>
);
}
@@ -286,7 +297,8 @@ export class ResultList extends React.Component<
index,
disabled,
onChange: this.handleValueChange.bind(this, index),
- labelField
+ labelField,
+ classnames: cx
})}
</label>
diff --git a/packages/amis-ui/src/components/Selection.tsx b/packages/amis-ui/src/components/Selection.tsx
index 4e9cf8679..b8b6e4753 100644
--- a/packages/amis-ui/src/components/Selection.tsx
+++ b/packages/amis-ui/src/components/Selection.tsx
@@ -17,7 +17,8 @@ import {
findTree,
flattenTree,
getOptionValue,
- getOptionValueBindField
+ getOptionValueBindField,
+ ClassNamesFn
} from 'amis-core';
import Checkbox from './Checkbox';
import {Option, Options} from './Select';
@@ -56,6 +57,7 @@ export interface ItemRenderStates {
checked: boolean;
onChange: () => void;
disabled?: boolean;
+ classnames: ClassNamesFn;
}
export class BaseSelection<
@@ -63,10 +65,24 @@ export class BaseSelection<
S = any
> extends React.Component<T, S> {
static itemRender(option: Option, states: ItemRenderStates) {
+ const label = option[states?.labelField || 'label'];
+ const tip = option.tip || '';
+ const classnames = states.classnames;
+
+ const canlabelTitle =
+ typeof label === 'string' || typeof label === 'number';
+ const canTipTitle = typeof tip === 'string' || typeof label === 'number';
+ const title = canlabelTitle && canTipTitle ? `${label} ${tip}` : '';
+
return (
- <span className={cx({'is-invalid': option?.__unmatched})}>
- {option[states?.labelField || 'label']}
- {option.tip || ''}
+ <span
+ title={title}
+ className={`${cx({'is-invalid': option?.__unmatched})} ${classnames(
+ 'Selection-ellipsis-line'
+ )}`}
+ >
+ {label}
+ {tip}
</span>
);
}
@@ -255,6 +271,7 @@ export class BaseSelection<
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
labelField,
+ classnames: cx,
disabled: disabled || option.disabled
})}
</Checkbox>
diff --git a/packages/amis-ui/src/components/Transfer.tsx b/packages/amis-ui/src/components/Transfer.tsx
index 17da84e71..a8010072e 100644
--- a/packages/amis-ui/src/components/Transfer.tsx
+++ b/packages/amis-ui/src/components/Transfer.tsx
@@ -420,18 +420,21 @@ export class Transfer<
@autobind
optionItemRender(option: Option, states: ItemRenderStates) {
- const {optionItemRender, labelField = 'label'} = this.props;
+ const {optionItemRender, labelField = 'label', classnames} = this.props;
return optionItemRender
? optionItemRender(option, states)
- : BaseSelection.itemRender(option, {labelField, ...states});
+ : BaseSelection.itemRender(option, {labelField, ...states, classnames});
}
@autobind
resultItemRender(option: Option, states: ItemRenderStates) {
- const {resultItemRender} = this.props;
+ const {resultItemRender, classnames} = this.props;
return resultItemRender
? resultItemRender(option, states)
- : ResultList.itemRender(option, states);
+ : ResultList.itemRender(option, {
+ ...states,
+ classnames
+ });
}
renderSelect(
diff --git a/packages/amis-ui/src/components/Tree.tsx b/packages/amis-ui/src/components/Tree.tsx
index 3f0842151..5766cbf71 100644
--- a/packages/amis-ui/src/components/Tree.tsx
+++ b/packages/amis-ui/src/components/Tree.tsx
@@ -1261,7 +1261,8 @@ export class TreeSelector extends React.Component<
checked: checked,
labelField: labelField,
onChange: () => this.handleCheck(item, !checked),
- disabled: disabled || item.disabled
+ disabled: disabled || item.disabled,
+ classnames: cx
})
: highlightTxt
? highlight(`${item[labelField]}`, highlightTxt)
diff --git a/packages/amis-ui/src/components/TreeSelection.tsx b/packages/amis-ui/src/components/TreeSelection.tsx
index 29dd9873a..5145caabc 100644
--- a/packages/amis-ui/src/components/TreeSelection.tsx
+++ b/packages/amis-ui/src/components/TreeSelection.tsx
@@ -267,7 +267,8 @@ export class TreeSelection extends BaseSelection<
multiple: multiple,
checked: checked,
onChange: () => this.toggleOption(option),
- disabled: disabled || option.disabled
+ disabled: disabled || option.disabled,
+ classnames: cx
})}
</div>
diff --git a/packages/amis/src/renderers/CRUD.tsx b/packages/amis/src/renderers/CRUD.tsx
index 6daa3d5bc..d5dbfd218 100644
--- a/packages/amis/src/renderers/CRUD.tsx
+++ b/packages/amis/src/renderers/CRUD.tsx
@@ -315,7 +315,11 @@ export interface CRUDCommonSchema extends BaseSchema, SpinnerExtraProps {
loadDataOnce?: boolean;
/**
- * 在开启loadDataOnce时,filter时是否去重新请求api
+ * 在开启loadDataOnce时,当修改过滤条件时是否重新请求api
+ *
+ * 如果没有配置,当查询条件表单触发的会重新请求 api,当是列过滤或者是 search-box 触发的则不重新请求 api
+ * 如果配置为 true,则不管是什么触发都会重新请求 api
+ * 如果配置为 false 则不管是什么触发都不会重新请求 api
*/
loadDataOnceFetchOnFilter?: boolean;
@@ -474,7 +478,6 @@ export default class CRUD extends React.Component<CRUDProps, any> {
filterTogglable: false,
filterDefaultVisible: true,
loadDataOnce: false,
- loadDataOnceFetchOnFilter: true,
autoFillHeight: false
};
@@ -997,7 +1000,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
undefined,
undefined,
undefined,
- loadDataOnceFetchOnFilter,
+ loadDataOnceFetchOnFilter !== false,
isInit
);
}
@@ -1190,7 +1193,6 @@ export default class CRUD extends React.Component<CRUDProps, any> {
pickerMode,
env,
loadDataOnce,
- loadDataOnceFetchOnFilter,
source,
columns,
dispatchEvent
@@ -1228,7 +1230,6 @@ export default class CRUD extends React.Component<CRUDProps, any> {
autoAppend: true,
forceReload,
loadDataOnce,
- loadDataOnceFetchOnFilter,
source,
silent,
pageField,
@@ -1670,11 +1671,18 @@ export default class CRUD extends React.Component<CRUDProps, any> {
handleQuery(
values: object,
- forceReload: boolean = false,
+ forceReload?: boolean,
replace?: boolean,
resetPage?: boolean
) {
- const {store, syncLocation, env, pageField, perPageField} = this.props;
+ const {
+ store,
+ syncLocation,
+ env,
+ pageField,
+ perPageField,
+ loadDataOnceFetchOnFilter
+ } = this.props;
store.updateQuery(
resetPage
? {
@@ -1690,7 +1698,12 @@ export default class CRUD extends React.Component<CRUDProps, any> {
perPageField,
replace
);
- this.search(undefined, undefined, replace, forceReload);
+ this.search(
+ undefined,
+ undefined,
+ replace,
+ forceReload ?? loadDataOnceFetchOnFilter === true
+ );
}
reload(
diff --git a/packages/amis/src/renderers/CRUD2.tsx b/packages/amis/src/renderers/CRUD2.tsx
index 366d2bb5d..b5cd55a15 100644
--- a/packages/amis/src/renderers/CRUD2.tsx
+++ b/packages/amis/src/renderers/CRUD2.tsx
@@ -537,7 +537,6 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
env,
loadType,
loadDataOnce,
- loadDataOnceFetchOnFilter,
source,
columns,
perPage
@@ -574,7 +573,6 @@ export default class CRUD2 extends React.Component<CRUD2Props, any> {
autoAppend: true,
forceReload,
loadDataOnce,
- loadDataOnceFetchOnFilter,
source,
silent,
pageField,
diff --git a/packages/amis/src/renderers/Form/TabsTransfer.tsx b/packages/amis/src/renderers/Form/TabsTransfer.tsx
index e24186f84..efe1c6d88 100644
--- a/packages/amis/src/renderers/Form/TabsTransfer.tsx
+++ b/packages/amis/src/renderers/Form/TabsTransfer.tsx
@@ -242,7 +242,7 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
@autobind
optionItemRender(option: any, states: ItemRenderStates) {
- const {menuTpl, render, data} = this.props;
+ const {menuTpl, render, data, classnames} = this.props;
const ctx = arguments[2] || {};
if (menuTpl) {
@@ -257,7 +257,7 @@ export class TabsTransferRenderer extends BaseTabsTransferRenderer<TabsTransferP
});
}
- return BaseSelection.itemRender(option, states);
+ return BaseSelection.itemRender(option, {...states, classnames});
}
// 动作
diff --git a/packages/amis/src/renderers/Form/TabsTransferPicker.tsx b/packages/amis/src/renderers/Form/TabsTransferPicker.tsx
index cdca05272..53166e0e2 100644
--- a/packages/amis/src/renderers/Form/TabsTransferPicker.tsx
+++ b/packages/amis/src/renderers/Form/TabsTransferPicker.tsx
@@ -53,7 +53,7 @@ export class TabsTransferPickerRenderer extends BaseTabsTransferRenderer<TabsTra
@autobind
optionItemRender(option: any, states: ItemRenderStates) {
- const {menuTpl, render, data} = this.props;
+ const {menuTpl, render, data, classnames} = this.props;
const ctx = arguments[2] || {};
if (menuTpl) {
@@ -68,7 +68,7 @@ export class TabsTransferPickerRenderer extends BaseTabsTransferRenderer<TabsTra
});
}
- return BaseSelection.itemRender(option, states);
+ return BaseSelection.itemRender(option, {...states, classnames});
}
// 动作
diff --git a/packages/amis/src/renderers/Json.tsx b/packages/amis/src/renderers/Json.tsx
index 87b3735f6..31bdee6fc 100644
--- a/packages/amis/src/renderers/Json.tsx
+++ b/packages/amis/src/renderers/Json.tsx
@@ -4,9 +4,15 @@ import {Renderer, RendererProps} from 'amis-core';
import type {InteractionProps} from 'react-json-view';
import {autobind, getPropValue, noop} from 'amis-core';
import {BaseSchema} from '../Schema';
-import {resolveVariableAndFilter, isPureVariable} from 'amis-core';
-
-export const JsonView = React.lazy(() => import('react-json-view'));
+import {
+ resolveVariableAndFilter,
+ isPureVariable,
+ importLazyComponent
+} from 'amis-core';
+
+export const JsonView = React.lazy(() =>
+ import('react-json-view').then(importLazyComponent)
+);
/**
* JSON 数据展示控件。
* 文档:https://aisuda.bce.baidu.com/amis/zh-CN/components/json
diff --git a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
index 8553ae3c3..258f07b2d 100644
--- a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
+++ b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
@@ -3,9 +3,7 @@ import {RendererProps} from 'amis-core';
import {ActionObject} from 'amis-core';
import {Icon} from 'amis-ui';
import {Overlay} from 'amis-core';
-import {findDOMNode} from 'react-dom';
import {PopOver} from 'amis-core';
-import {ITableStore} from 'amis-core';
import {setVariable, createObject} from 'amis-core';
export interface QuickSearchConfig {
@@ -23,35 +21,31 @@ export interface HeadCellSearchProps extends RendererProps {
onQuery: (values: object) => void;
}
-export class HeadCellSearchDropDown extends React.Component<
- HeadCellSearchProps,
- any
-> {
- state = {
- isOpened: false
- };
-
- formItems: Array<string> = [];
- constructor(props: HeadCellSearchProps) {
- super(props);
-
- this.open = this.open.bind(this);
- this.close = this.close.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
- this.handleAction = this.handleAction.bind(this);
- }
-
- buildSchema() {
- const {searchable, sortable, name, label, translate: __} = this.props;
-
+export function HeadCellSearchDropDown({
+ searchable,
+ name,
+ label,
+ onQuery,
+ data,
+ dispatchEvent,
+ onAction,
+ classnames: cx,
+ translate: __,
+ classPrefix: ns,
+ popOverContainer,
+ render
+}: HeadCellSearchProps) {
+ const ref = React.createRef<HTMLElement>();
+ const [formSchema, formItems] = React.useMemo(() => {
let schema: any;
+ const formItems: Array<string> = [];
if (searchable === true) {
schema = {
title: '',
- controls: [
+ body: [
{
- type: 'text',
+ type: 'input-text',
name,
placeholder: label,
clearable: true
@@ -59,21 +53,22 @@ export class HeadCellSearchDropDown extends React.Component<
]
};
} else if (searchable) {
- if (searchable.controls || searchable.tabs || searchable.fieldSet) {
+ if (searchable.body || searchable.tabs || searchable.fieldSet) {
+ // todo 删除此处代码,这些都是不推荐的用法
schema = {
title: '',
...searchable,
- controls: Array.isArray(searchable.controls)
- ? searchable.controls.concat()
+ body: Array.isArray(searchable.body)
+ ? searchable.body.concat()
: undefined
};
} else {
schema = {
title: '',
className: searchable.formClassName,
- controls: [
+ body: [
{
- type: searchable.type || 'text',
+ type: searchable.type || 'input-text',
name: searchable.name || name,
placeholder: label,
...searchable
@@ -83,41 +78,11 @@ export class HeadCellSearchDropDown extends React.Component<
}
}
- if (schema && schema.controls && sortable) {
- schema.controls.unshift(
- {
- type: 'hidden',
- name: 'orderBy',
- value: name
- },
- {
- type: 'button-group',
- name: 'orderDir',
- label: __('sort'),
- options: [
- {
- label: __('asc'),
- value: 'asc'
- },
- {
- label: __('desc'),
- value: 'desc'
- }
- ]
- }
- );
- }
-
if (schema) {
- const formItems: Array<string> = [];
- schema.controls?.forEach(
- (item: any) =>
- item.name &&
- item.name !== 'orderBy' &&
- item.name !== 'orderDir' &&
- formItems.push(item.name)
- );
- this.formItems = formItems;
+ Array.isArray(schema.body) &&
+ schema.body.forEach(
+ (item: any) => item.name && formItems.push(item.name)
+ );
schema = {
...schema,
type: 'form',
@@ -144,64 +109,13 @@ export class HeadCellSearchDropDown extends React.Component<
};
}
- return schema || 'error';
- }
-
- handleClickOutside() {
- this.close();
- }
-
- open() {
- this.setState({
- isOpened: true
- });
- }
-
- close() {
- this.setState({
- isOpened: false
- });
- }
-
- handleAction(e: any, action: ActionObject, ctx: object) {
- const {onAction} = this.props;
-
- if (action.actionType === 'cancel' || action.actionType === 'close') {
- this.close();
- return;
- }
-
- if (action.actionType === 'reset') {
- this.close();
- this.handleReset();
- return;
- }
-
- onAction && onAction(e, action, ctx);
- }
-
- handleReset() {
- const {onQuery, data, name} = this.props;
- const values = {...data};
- this.formItems.forEach(key => setVariable(values, key, undefined));
-
- if (values.orderBy === name) {
- values.orderBy = '';
- values.orderDir = 'asc';
- }
- onQuery(values);
- }
-
- async handleSubmit(values: any) {
- const {onQuery, name, data, dispatchEvent} = this.props;
-
- if (values.orderDir) {
- values = {
- ...values,
- orderBy: name
- };
- }
+ return [schema || 'error', formItems];
+ }, [searchable, name, label]);
+ const [isOpened, setIsOpened] = React.useState(false);
+ const open = React.useCallback(() => setIsOpened(true), []);
+ const close = React.useCallback(() => setIsOpened(false), []);
+ const handleSubmit = React.useCallback(async (values: any) => {
const rendererEvent = await dispatchEvent(
'columnSearch',
createObject(data, {
@@ -214,78 +128,81 @@ export class HeadCellSearchDropDown extends React.Component<
return;
}
- this.close();
-
+ close();
onQuery(values);
- }
+ }, []);
- isActive() {
- const {data, name, orderBy} = this.props;
+ const handleAction = React.useCallback(
+ (e: any, action: ActionObject, ctx: object) => {
+ if (action.actionType === 'cancel' || action.actionType === 'close') {
+ close();
+ return;
+ }
- return orderBy === name || this.formItems.some(key => data?.[key]);
- }
+ if (action.actionType === 'reset') {
+ close();
+ handleReset();
+ return;
+ }
- render() {
- const {
- render,
- name,
- data,
- searchable,
- store,
- orderBy,
- popOverContainer,
- classPrefix: ns,
- classnames: cx
- } = this.props;
+ onAction && onAction(e, action, ctx);
+ },
+ []
+ );
- const formSchema = this.buildSchema();
- const isActive = this.isActive();
+ const handleReset = React.useCallback(() => {
+ const values = {...data};
+ // todo 这里不精准,如果表单项有容器嵌套,这里将不正确
+ formItems.forEach(key => setVariable(values, key, undefined));
- return (
- <span
- className={cx(
- `${ns}TableCell-searchBtn`,
- isActive ? 'is-active' : '',
- this.state.isOpened ? 'is-opened' : ''
- )}
- >
- <span onClick={this.open}>
- <Icon icon="search" className="icon" />
- </span>
- {this.state.isOpened ? (
- <Overlay
- container={popOverContainer || (() => findDOMNode(this))}
- placement="left-bottom-left-top right-bottom-right-top"
- target={
- popOverContainer ? () => findDOMNode(this)!.parentNode : null
- }
- show
- >
- <PopOver
- classPrefix={ns}
- onHide={this.close}
- className={cx(
- `${ns}TableCell-searchPopOver`,
- (searchable as any).className
- )}
- overlay
- >
- {
- render('quick-search-form', formSchema, {
- data: {
- ...data,
- orderBy: orderBy,
- orderDir:
- orderBy === name ? (store as ITableStore).orderDir : ''
- },
- onSubmit: this.handleSubmit,
- onAction: this.handleAction
- }) as JSX.Element
- }
- </PopOver>
- </Overlay>
- ) : null}
+ onQuery(values);
+ }, [data]);
+
+ const isActive = React.useMemo(() => {
+ // todo 这里不精准,如果表单项有容器嵌套,这里将不正确
+ return formItems.some(key => data?.[key]);
+ }, [data]);
+
+ return (
+ <span
+ ref={ref}
+ className={cx(
+ `${ns}TableCell-searchBtn`,
+ isActive ? 'is-active' : '',
+ isOpened ? 'is-opened' : ''
+ )}
+ >
+ <span onClick={open}>
+ <Icon icon="search" className="icon" />
</span>
- );
- }
+ {isOpened ? (
+ <Overlay
+ container={popOverContainer || (() => ref.current)}
+ placement="left-bottom-left-top right-bottom-right-top"
+ target={popOverContainer ? () => ref.current?.parentNode : null}
+ show
+ >
+ <PopOver
+ classPrefix={ns}
+ onHide={close}
+ className={cx(
+ `${ns}TableCell-searchPopOver`,
+ (searchable as any).className
+ )}
+ overlay
+ >
+ {
+ render('quick-search-form', formSchema, {
+ data: {
+ ...data
+ },
+ onSubmit: handleSubmit,
+ onAction: handleAction
+ }) as JSX.Element
+ }
+ </PopOver>
+ </Overlay>
+ ) : null}
+ </span>
+ );
}
diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx
index 62ddc298b..f07dcc238 100644
--- a/packages/amis/src/renderers/Table/index.tsx
+++ b/packages/amis/src/renderers/Table/index.tsx
@@ -1860,11 +1860,8 @@ export default class Table extends React.Component<TableProps, object> {
onQuery={onQuery}
name={column.name}
searchable={column.searchable}
- sortable={false}
type={column.type}
data={query}
- orderBy={store.orderBy}
- orderDir={store.orderDir}
popOverContainer={this.getPopOverContainer}
/>
);
| fix: Form组件配置页面跳转事件可能会导致持久化数据无法清除问题
### What
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 6556104</samp>
This pull request introduces a new feature for the form renderer to clear the local persist data of the form store. This can help avoid data inconsistency issues when the form data is submitted to the server or the page route changes.
<!--
copilot:poem
-->
### <samp>🤖 Generated by Copilot at 6556104</samp>
> _To clear the persist data of the form_
> _We added a prop to the renderer norm_
> _`clearPersistDataAfterSubmit`_
> _Will do the trick, bit by bit_
> _And keep the form store and route in good form_
### Why
<!-- author to complete -->
### How
<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 6556104</samp>
* Add a feature to clear the local persist data of the form store before or after submitting the form data, depending on the user's preference and the outcome of the submission. ([link](https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1157-R1158), [link](https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1190), [link](https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1251))
* In `packages/amis-core/src/renderers/Form.tsx`, check the `clearPersistDataAfterSubmit` prop of the form before calling the `submitToTarget` method. If it is true, clear the persist data using the `store.clearPersistData` method. ([link](https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1157-R1158))
| **Title**
Fix form persistence leakage on navigation and improve CRUD filtering, UI rendering, and formula support
**Problem**
- After a form submission that triggers a page route change, the form’s locally persisted data is not cleared, leading to stale values when the user returns.
- CRUD components exhibit inconsistent behavior when `loadDataOnce` is enabled, especially regarding whether filter actions re‑request data.
- Several UI components suffer from label overflow, missing ellipsis handling, and drag‑event handling in non‑editable mode.
**Root Cause**
- The form store clears persisted data only after asynchronous submit handling, so a route change can leave the previous `persistKey` active.
- The `loadDataOnceFetchOnFilter` flag’s default handling was ambiguous, causing unexpected API calls during filtering.
- Search and selection components relied on ad‑hoc regex matching and lacked proper class name handling for truncation and accessibility.
**Fix / Expected Behavior**
- Clear the form store’s local persisted data immediately when `clearPersistDataAfterSubmit` is enabled, before any navigation occurs.
- Honor the `loadDataOnceFetchOnFilter` property explicitly, allowing developers to control whether filter actions trigger a new API request.
- Replace fragile regex filtering with fuzzy matching via `match-sorter` for CRUD, editor search panels, and component lists.
- Add the `POW` mathematical function to the formula engine with documentation.
- Adjust UI styles to enforce label width, apply ellipsis truncation, and correctly pass class‑name utilities to selection components.
- Restrict drag‑and‑drop event listeners in the editor preview to editable mode only and improve lazy loading of `react‑json‑view`.
**Risk & Validation**
- Verify that form submissions no longer retain stale persisted data after navigation and that other store operations remain unaffected.
- Test CRUD pages with `loadDataOnce` enabled to confirm filter behavior matches the configured `loadDataOnceFetchOnFilter` setting.
- Run UI regression tests to ensure label truncation, selection rendering, and drag‑and‑drop behave as expected across editable and read‑only modes. | 8,354 | baidu/amis | diff --git a/packages/amis-formula/__tests__/evalute.test.ts b/packages/amis-formula/__tests__/evalute.test.ts
index 4670b3906..2fb97d99a 100644
--- a/packages/amis-formula/__tests__/evalute.test.ts
+++ b/packages/amis-formula/__tests__/evalute.test.ts
@@ -539,3 +539,26 @@ test('evalute:ISTYPE', () => {
expect(evaluate('${ISTYPE(f, "plain-object")}', data)).toBe(true);
expect(evaluate('${ISTYPE(g, "date")}', data)).toBe(true);
});
+
+test('evalute:Math', () => {
+ const data = {
+ float: 0.5,
+ integer1: 2,
+ integer2: 4,
+ negativeInteger: -2,
+ array: [1, 2 ,3],
+ infinity: Infinity
+ }
+
+ expect(evaluate('${POW(integer1, integer2)}', data)).toBe(16);
+ expect(evaluate('${POW(integer2, 0.5)}', data)).toBe(2);
+ expect(evaluate('${POW(integer1, -2)}', data)).toBe(0.25);
+ /** 计算结果不合法,则返回NaN */
+ expect(evaluate('${POW(negativeInteger, 0.5)}', data)).toBe(NaN);
+ /** 参数值不合法,则返回基数本身*/
+ expect(evaluate('${POW(array, 2)}', data)).toBe(data.array);
+ /** 测试Infinity */
+ expect(evaluate('${POW(infinity, 2)}', data)).toBe(data.infinity);
+ expect(evaluate('${POW(1, infinity)}', data)).toBe(NaN);
+ expect(evaluate('${POW(2, infinity)}', data)).toBe(data.infinity);
+})
diff --git a/packages/amis/__tests__/renderers/CRUD.test.tsx b/packages/amis/__tests__/renderers/CRUD.test.tsx
index d6b34c6b5..043ea6389 100644
--- a/packages/amis/__tests__/renderers/CRUD.test.tsx
+++ b/packages/amis/__tests__/renderers/CRUD.test.tsx
@@ -166,7 +166,6 @@ test('3. Renderer:crud loadDataOnce', async () => {
columnsNum: 4,
showBtnToolbar: false
},
- filterSettingSource: ['version'],
columns: [
{
name: 'id',
diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/select.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/select.test.tsx.snap
index 1a6c79084..57a2487ef 100644
--- a/packages/amis/__tests__/renderers/Form/__snapshots__/select.test.tsx.snap
+++ b/packages/amis/__tests__/renderers/Form/__snapshots__/select.test.tsx.snap
@@ -471,7 +471,8 @@ exports[`Renderer:select associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1 "
>
group-1
</span>
@@ -491,7 +492,8 @@ exports[`Renderer:select associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-1 "
>
group-1-option-1
</span>
@@ -513,7 +515,8 @@ exports[`Renderer:select associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-2 "
>
group-1-option-2
</span>
@@ -535,7 +538,8 @@ exports[`Renderer:select associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-3 "
>
group-1-option-3
</span>
@@ -1157,7 +1161,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1 "
>
group-1
</span>
@@ -1171,7 +1176,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2 "
>
group-2
</span>
@@ -1185,7 +1191,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-3 "
>
group-3
</span>
@@ -1199,7 +1206,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-4 "
>
group-4
</span>
@@ -1268,7 +1276,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-1 "
>
group-1-option-1
</span>
@@ -1282,7 +1291,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-2 "
>
group-1-option-2
</span>
@@ -1296,7 +1306,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-3 "
>
group-1-option-3
</span>
@@ -1310,7 +1321,8 @@ exports[`Renderer:select chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1-option-4 "
>
group-1-option-4
</span>
@@ -1771,7 +1783,8 @@ exports[`Renderer:select group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1 "
>
group-1
</span>
@@ -1791,7 +1804,8 @@ exports[`Renderer:select group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-1 "
>
option-1
</span>
@@ -1813,7 +1827,8 @@ exports[`Renderer:select group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-2 "
>
option-2
</span>
@@ -1835,7 +1850,8 @@ exports[`Renderer:select group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-3 "
>
option-3
</span>
diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/tabsTransfer.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/tabsTransfer.test.tsx.snap
index 3e3cadfc1..3fbb9b87e 100644
--- a/packages/amis/__tests__/renderers/Form/__snapshots__/tabsTransfer.test.tsx.snap
+++ b/packages/amis/__tests__/renderers/Form/__snapshots__/tabsTransfer.test.tsx.snap
@@ -538,7 +538,8 @@ exports[`Renderer:tabsTransfer 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师2 "
>
法师2
</span>
@@ -551,7 +552,8 @@ exports[`Renderer:tabsTransfer 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="战士2 "
>
战士2
</span>
@@ -564,7 +566,8 @@ exports[`Renderer:tabsTransfer 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="打野2 "
>
打野2
</span>
@@ -1134,7 +1137,8 @@ exports[`Renderer:tabsTransfer with deferApi 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师2 "
>
法师2
</span>
diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap
index 1819c39f3..f2abb89c4 100644
--- a/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap
+++ b/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap
@@ -119,7 +119,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="诸葛亮 "
>
诸葛亮
</span>
@@ -144,7 +145,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="曹操 "
>
曹操
</span>
@@ -169,7 +171,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="钟无艳 "
>
钟无艳
</span>
@@ -194,7 +197,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="李白 "
>
李白
</span>
@@ -219,7 +223,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="韩信 "
>
韩信
</span>
@@ -244,7 +249,8 @@ exports[`Renderer:transfer 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="云中君 "
>
云中君
</span>
@@ -669,7 +675,8 @@ exports[`Renderer:transfer associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="label-1 "
>
label-1
</span>
@@ -695,7 +702,8 @@ exports[`Renderer:transfer associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="label-2 "
>
label-2
</span>
@@ -721,7 +729,8 @@ exports[`Renderer:transfer associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="label-3 "
>
label-3
</span>
@@ -747,7 +756,8 @@ exports[`Renderer:transfer associated mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="label-4 "
>
label-4
</span>
@@ -1018,7 +1028,8 @@ exports[`Renderer:transfer chained 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师 "
>
法师
</span>
@@ -1031,7 +1042,8 @@ exports[`Renderer:transfer chained 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="战士 "
>
战士
</span>
@@ -1044,7 +1056,8 @@ exports[`Renderer:transfer chained 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="打野 "
>
打野
</span>
@@ -1251,7 +1264,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-1 "
>
group-1
</span>
@@ -1264,7 +1278,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2 "
>
group-2
</span>
@@ -1277,7 +1292,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-3 "
>
group-3
</span>
@@ -1290,7 +1306,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-4 "
>
group-4
</span>
@@ -1303,7 +1320,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-5 "
>
group-5
</span>
@@ -1316,7 +1334,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-6 "
>
group-6
</span>
@@ -1329,7 +1348,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-7 "
>
group-7
</span>
@@ -1342,7 +1362,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-8 "
>
group-8
</span>
@@ -1355,7 +1376,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-9 "
>
group-9
</span>
@@ -1368,7 +1390,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-10 "
>
group-10
</span>
@@ -1407,7 +1430,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2-option-1 "
>
group-2-option-1
</span>
@@ -1433,7 +1457,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2-option-2 "
>
group-2-option-2
</span>
@@ -1459,7 +1484,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2-option-3 "
>
group-2-option-3
</span>
@@ -1485,7 +1511,8 @@ exports[`Renderer:transfer chained mode with virtual 1`] = `
class="cxd-ChainedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="group-2-option-4 "
>
group-2-option-4
</span>
@@ -1776,7 +1803,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="法师"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师 "
>
法师
</span>
@@ -1816,7 +1844,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="诸葛亮"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="诸葛亮 "
>
诸葛亮
</span>
@@ -1861,7 +1890,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="战士"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="战士 "
>
战士
</span>
@@ -1901,7 +1931,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="曹操"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="曹操 "
>
曹操
</span>
@@ -1941,7 +1972,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="钟无艳"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="钟无艳 "
>
钟无艳
</span>
@@ -1986,7 +2018,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="打野"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="打野 "
>
打野
</span>
@@ -2026,7 +2059,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="李白"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="李白 "
>
李白
</span>
@@ -2066,7 +2100,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="韩信"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="韩信 "
>
韩信
</span>
@@ -2106,7 +2141,8 @@ exports[`Renderer:transfer follow left mode 1`] = `
title="云中君"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="云中君 "
>
云中君
</span>
@@ -2176,7 +2212,10 @@ exports[`Renderer:transfer follow left mode 1`] = `
class="cxd-Tree-itemText"
title="法师"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="法师"
+ >
法师
</span>
</span>
@@ -2212,7 +2251,10 @@ exports[`Renderer:transfer follow left mode 1`] = `
class="cxd-Tree-itemText"
title="诸葛亮"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="诸葛亮"
+ >
诸葛亮
</span>
</span>
@@ -2444,7 +2486,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="法师"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师 "
>
法师
</span>
@@ -2484,7 +2527,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="诸葛亮"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="诸葛亮 "
>
诸葛亮
</span>
@@ -2529,7 +2573,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="战士"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="战士 "
>
战士
</span>
@@ -2569,7 +2614,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="曹操"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="曹操 "
>
曹操
</span>
@@ -2609,7 +2655,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="钟无艳"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="钟无艳 "
>
钟无艳
</span>
@@ -2654,7 +2701,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="打野"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="打野 "
>
打野
</span>
@@ -2694,7 +2742,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="李白"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="李白 "
>
李白
</span>
@@ -2734,7 +2783,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="韩信"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="韩信 "
>
韩信
</span>
@@ -2774,7 +2824,8 @@ exports[`Renderer:transfer follow left mode 2`] = `
title="云中君"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="云中君 "
>
云中君
</span>
@@ -2865,7 +2916,10 @@ exports[`Renderer:transfer follow left mode 2`] = `
class="cxd-Tree-itemText"
title="战士"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="战士"
+ >
战士
</span>
</span>
@@ -2901,7 +2955,10 @@ exports[`Renderer:transfer follow left mode 2`] = `
class="cxd-Tree-itemText"
title="曹操"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="曹操"
+ >
曹操
</span>
</span>
@@ -3112,7 +3169,8 @@ exports[`Renderer:transfer group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-197 "
>
option-197
</span>
@@ -3146,7 +3204,8 @@ exports[`Renderer:transfer group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-198 "
>
option-198
</span>
@@ -3180,7 +3239,8 @@ exports[`Renderer:transfer group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-199 "
>
option-199
</span>
@@ -3214,7 +3274,8 @@ exports[`Renderer:transfer group mode with virtual 1`] = `
class="cxd-GroupedSelection-itemLabel"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="option-200 "
>
option-200
</span>
@@ -4943,7 +5004,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-1"
+ >
label-1
</span>
</label>
@@ -4963,7 +5027,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-3"
+ >
label-3
</span>
</label>
@@ -4983,7 +5050,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-5"
+ >
label-5
</span>
</label>
@@ -5003,7 +5073,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-7"
+ >
label-7
</span>
</label>
@@ -5023,7 +5096,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-9"
+ >
label-9
</span>
</label>
@@ -5043,7 +5119,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-11"
+ >
label-11
</span>
</label>
@@ -5063,7 +5142,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-13"
+ >
label-13
</span>
</label>
@@ -5083,7 +5165,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-15"
+ >
label-15
</span>
</label>
@@ -5103,7 +5188,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-17"
+ >
label-17
</span>
</label>
@@ -5123,7 +5211,10 @@ exports[`Renderer:transfer table mode with virtual: result not virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-19"
+ >
label-19
</span>
</label>
@@ -5575,7 +5666,10 @@ exports[`Renderer:transfer table mode with virtual: result virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-1"
+ >
label-1
</span>
</label>
@@ -5596,7 +5690,10 @@ exports[`Renderer:transfer table mode with virtual: result virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-3"
+ >
label-3
</span>
</label>
@@ -5617,7 +5714,10 @@ exports[`Renderer:transfer table mode with virtual: result virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-5"
+ >
label-5
</span>
</label>
@@ -5638,7 +5738,10 @@ exports[`Renderer:transfer table mode with virtual: result virtual 1`] = `
<label
class="cxd-Selections-label"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="label-7"
+ >
label-7
</span>
</label>
@@ -5898,7 +6001,8 @@ exports[`Renderer:transfer tree 1`] = `
title="法师"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="法师 "
>
法师
</span>
@@ -5938,7 +6042,8 @@ exports[`Renderer:transfer tree 1`] = `
title="诸葛亮"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="诸葛亮 "
>
诸葛亮
</span>
@@ -5983,7 +6088,8 @@ exports[`Renderer:transfer tree 1`] = `
title="战士"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="战士 "
>
战士
</span>
@@ -6023,7 +6129,8 @@ exports[`Renderer:transfer tree 1`] = `
title="曹操"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="曹操 "
>
曹操
</span>
@@ -6063,7 +6170,8 @@ exports[`Renderer:transfer tree 1`] = `
title="钟无艳"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="钟无艳 "
>
钟无艳
</span>
@@ -6108,7 +6216,8 @@ exports[`Renderer:transfer tree 1`] = `
title="打野"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="打野 "
>
打野
</span>
@@ -6148,7 +6257,8 @@ exports[`Renderer:transfer tree 1`] = `
title="李白"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="李白 "
>
李白
</span>
@@ -6188,7 +6298,8 @@ exports[`Renderer:transfer tree 1`] = `
title="韩信"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="韩信 "
>
韩信
</span>
@@ -6228,7 +6339,8 @@ exports[`Renderer:transfer tree 1`] = `
title="云中君"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="云中君 "
>
云中君
</span>
@@ -6432,7 +6544,8 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
title="诸葛亮"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="诸葛亮 "
>
诸葛亮
</span>
@@ -6472,7 +6585,8 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
title="曹操"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="曹操 "
>
曹操
</span>
@@ -6512,7 +6626,8 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
title="钟无艳"
>
<span
- class=""
+ class=" cxd-Selection-ellipsis-line"
+ title="钟无艳 "
>
钟无艳
</span>
@@ -6561,7 +6676,10 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
<label
class="cxd-Selections-label is-invalid"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="w"
+ >
w
</span>
</label>
@@ -6581,7 +6699,10 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
<label
class="cxd-Selections-label is-invalid"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="x"
+ >
x
</span>
</label>
@@ -6601,7 +6722,10 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
<label
class="cxd-Selections-label is-invalid"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="y"
+ >
y
</span>
</label>
@@ -6621,7 +6745,10 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = `
<label
class="cxd-Selections-label is-invalid"
>
- <span>
+ <span
+ class="cxd-Selection-ellipsis-line"
+ title="z"
+ >
z
</span>
</label>
diff --git a/packages/amis/__tests__/renderers/Form/transfer.test.tsx b/packages/amis/__tests__/renderers/Form/transfer.test.tsx
index b27b046ae..ad9b6abfa 100644
--- a/packages/amis/__tests__/renderers/Form/transfer.test.tsx
+++ b/packages/amis/__tests__/renderers/Form/transfer.test.tsx
@@ -1227,7 +1227,7 @@ test('Renderer:transfer with searchApi', async () => {
await wait(300);
- const caocao = container.querySelector('span[title=曹操]');
+ const caocao = container.querySelector('span[title=李白]');
expect(caocao).toBeNull();
});
| [
"evalute:Math"
] | [
"lexer:simple",
"lexer:filter",
"lexer:exception",
"parser:simple",
"parser:complex",
"parser:evalMode",
"parser:template",
"parser:string",
"parser:number",
"parser:single-string",
"parser:object-literall",
"parser:array-literall",
"parser:variable-geter",
"parser:variable-geter2",
"parser:multi-expression",
"parser:functionCall",
"parser:filter",
"parser:filter-escape",
"parser:conditional",
"parser:binary-expression",
"parser:group-expression",
"parser:unary-expression",
"parser:anonymous-function",
"formula:expression",
"formula:expression2",
"formula:expression3",
"formula:if",
"formula:and",
"formula:or",
"formula:xor",
"formula:ifs",
"formula:math",
"formula:text",
"formula:date",
"formula:last",
"formula:basename",
"formula:customFunction",
"evalute:simple",
"evalute:filter",
"evalute:filter2",
"evalute:filter3",
"evalute:filter4",
"evalute:keywords",
"evalute:oldVariable",
"evalute:ariable2",
"evalute:ariable3",
"evalute:object-variable",
"evalute:literal-variable",
"evalute:tempalte",
"evalute:literal",
"evalute:variableName",
"evalute:3-1",
"evalate:0.1+0.2",
"evalute:variable:com.xxx.xx",
"evalute:anonymous:function",
"evalute:anonymous:function2",
"evalute:array:func",
"evalute:ISTYPE"
] | No new interfaces are introduced. | custom-check-github | {
"base_image_name": "node_16",
"install": [
"npm install"
],
"log_parser": "parse_log_js_4",
"test_cmd": "cd packages/amis-formula && npx jest --verbose --no-color"
} | {
"num_modified_files": 34,
"num_modified_lines": 523,
"pr_author": "lurunze1226",
"pr_labels": [
"fix"
],
"llm_metadata": {
"code": "B5",
"code_quality": null,
"confidence": 0.9,
"detected_issues": {
"B1": false,
"B2": false,
"B3": false,
"B4": false,
"B5": true,
"B6": false
},
"detected_issues_explanation": null,
"detecte d_issues": null,
"difficulty": "medium",
"external_urls": [
"https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1157-R1158",
"https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1190",
"https://github.com/baidu/amis/pull/8354/files?diff=unified&w=0#diff-74ef3e735568303c05308159e59fd316cca5f1fba7b0b805b50c43be1ca55cf3R1251"
],
"intent_completeness": "partial",
"patch": null,
"pr_categories": [
"minor_bug"
],
"reason": null,
"reasoning": "The issue requests adding a `clearPersistDataAfterSubmit` prop to the Form renderer to clear persisted data on navigation. The test patch does modify Form.tsx to call `store.clearLocalPersistData()`, but it also contains a large number of unrelated changes (snapshot updates, UI class tweaks, addition of a new POW function in the formula evaluator, etc.) that are not part of the requested fix. These extraneous modifications cause the test suite to diverge from the original intent, indicating the patch is primarily a collection of unrelated artifacts rather than a focused solution.",
"suggested_fixes": null,
"test_alignment": null,
"test_alignment_issues": [
"Snapshot files for many Select/Transfer components are altered without relation to the Form persist‑data fix",
"New tests for a POW math function are added in the formula package",
"Numerous UI component files (selection, tree, transfer, etc.) receive style and class name changes",
"Various editor and core files are modified (e.g., drag‑and‑drop handling, store logic) that are unrelated to the Form issue"
],
"test_alignment_quick_tree": null,
"test_alignment_quick_tree_bootstrap": null,
"test_alignment_quick_tree_mocks": null,
"test_alignment_quick_tree_params": null,
"test_alignment_quick_tree_unrelated": null,
"test_alignment_quick_tree_use_hook": null,
"test_alignment_quick_tree_use_hook_unrelated": null,
"test_alignment_sample_without_replacement": null,
"test_alignment_test_alignment_sample_without_replacement": null,
"test_build_phylogeny": null,
"test_build_phylogeny_unrelated": null,
"test_build_phylogeny_use_hook": null,
"test_build_phylogeny_use_hook_unrelated": null,
"test_core_seq_test_sample_motif_length_1": null,
"test_core_seq_test_sample_motif_length_3": null,
"test_core_seq_test_sample_without_replacement": null,
"test_core_sequence": null,
"test_core_sequence_test_sample_motif_length_1": null,
"test_core_sequence_test_sample_motif_length_3": null,
"test_core_sequence_test_sample_without_replacement": null,
"test_sample_motif_length_1": null,
"test_sample_motif_length_3": null,
"test_sample_without_replacement": null
}
} | |
08412adcb500e92f7ebb55453cd26a028d0c1368 | 2023-10-12 01:53:11 | baidu__amis-8360 | diff --git a/examples/components/CRUD/List.jsx b/examples/components/CRUD/List.jsx
index 15d65c389..18aef7409 100644
--- a/examples/components/CRUD/List.jsx
+++ b/examples/components/CRUD/List.jsx
@@ -3,32 +3,18 @@ export default {
remark: 'bla bla bla',
body: {
type: 'crud',
- api: '/api/sample',
+ name: 'thelist',
+ api: {
+ method: 'get',
+ url: '/api/sample',
+ sendOn: '${mode}'
+ },
mode: 'list',
draggable: true,
saveOrderApi: {
url: '/api/sample/saveOrder'
},
orderField: 'weight',
- filter: {
- title: '条件搜索',
- submitText: '',
- body: [
- {
- type: 'input-text',
- name: 'keywords',
- placeholder: '通过关键字搜索',
- addOn: {
- label: '搜索',
- type: 'submit'
- }
- },
- {
- type: 'plain',
- text: '这只是个示例, 目前搜索对查询结果无效.'
- }
- ]
- },
affixHeader: true,
bulkActions: [
{
@@ -63,6 +49,44 @@ export default {
],
quickSaveApi: '/api/sample/bulkUpdate',
quickSaveItemApi: '/api/sample/$id',
+ headerToolbar: [
+ {
+ type: 'form',
+ mode: 'inline',
+ wrapWithPanel: false,
+ submitOnChange: true,
+ submitOnInit: true,
+ target: 'thelist',
+ body: [
+ {
+ type: 'select',
+ name: 'mode',
+ className: 'mb-0',
+ selectFirst: true,
+ options: [
+ {
+ label: '模式 1',
+ value: 'mode1'
+ },
+ {
+ label: '模式 2',
+ value: 'mode2'
+ }
+ ]
+ },
+ {
+ type: 'input-text',
+ name: 'keywords',
+ placeholder: '通过关键字搜索',
+ className: 'mb-0',
+ addOn: {
+ label: '搜索',
+ type: 'submit'
+ }
+ }
+ ]
+ }
+ ],
listItem: {
actions: [
{
diff --git a/packages/amis-core/src/WithStore.tsx b/packages/amis-core/src/WithStore.tsx
index 6e1c37aee..6c9a0d4b9 100644
--- a/packages/amis-core/src/WithStore.tsx
+++ b/packages/amis-core/src/WithStore.tsx
@@ -252,7 +252,7 @@ export function HocStoreFactory(renderer: {
props.store?.storeType === 'ComboStore'
? undefined
: syncDataFromSuper(
- store.data,
+ props.data,
(props.data as any).__super,
(prevProps.data as any).__super,
store,
diff --git a/packages/amis-core/src/store/crud.ts b/packages/amis-core/src/store/crud.ts
index dc2df1cc6..d254a63f5 100644
--- a/packages/amis-core/src/store/crud.ts
+++ b/packages/amis-core/src/store/crud.ts
@@ -61,12 +61,11 @@ export const CRUDStore = ServiceStore.named('CRUDStore')
// 因为会把数据呈现在地址栏上。
return createObject(
createObject(self.data, {
- ...self.query,
items: self.items.concat(),
selectedItems: self.selectedItems.concat(),
unSelectedItems: self.unSelectedItems.concat()
}),
- {}
+ {...self.query}
);
},
diff --git a/packages/amis-core/src/utils/helper.ts b/packages/amis-core/src/utils/helper.ts
index 3d4fa48b4..ebbdfc9e8 100644
--- a/packages/amis-core/src/utils/helper.ts
+++ b/packages/amis-core/src/utils/helper.ts
@@ -1587,7 +1587,7 @@ export function mapObject(
}
if (Array.isArray(value)) {
- return value.map(item => mapObject(item, fn));
+ return value.map(item => mapObject(item, fn, skipFn));
}
if (isObject(value)) {
@@ -1595,7 +1595,8 @@ export function mapObject(
Object.keys(tmpValue).forEach(key => {
(tmpValue as PlainObject)[key] = mapObject(
(tmpValue as PlainObject)[key],
- fn
+ fn,
+ skipFn
);
});
return tmpValue;
diff --git a/packages/amis-editor-core/src/util.ts b/packages/amis-editor-core/src/util.ts
index 65f87f69b..4529381b8 100644
--- a/packages/amis-editor-core/src/util.ts
+++ b/packages/amis-editor-core/src/util.ts
@@ -1063,14 +1063,12 @@ export function getI18nEnabled() {
}
/** schema 翻译方法 */
-export function translateSchema(schema: any, replaceData?: any) {
+export function translateSchema(schema: any, replaceData?: any, skipFn?: any) {
replaceData = replaceData || (window as any)?.editorStore?.appCorpusData;
if (!isPlainObject(replaceData)) {
return schema;
}
- return mapObject(schema, (item: any) => {
- return replaceData[item] || item;
- });
+ return mapObject(schema, (item: any) => replaceData[item] || item, skipFn);
}
/** 应用级别的翻译方法 */
diff --git a/packages/amis-editor/src/renderer/FormulaControl.tsx b/packages/amis-editor/src/renderer/FormulaControl.tsx
index f00316787..b6c03d110 100644
--- a/packages/amis-editor/src/renderer/FormulaControl.tsx
+++ b/packages/amis-editor/src/renderer/FormulaControl.tsx
@@ -515,16 +515,16 @@ export default class FormulaControl extends React.Component<
} else {
curRendererSchema.placeholder = '请输入静态值';
}
- // 设置popOverContainer
- curRendererSchema.popOverContainer = window.document.body;
}
+ JSONPipeOut(curRendererSchema);
+
// 对 schema 进行国际化翻译
if (this.appLocale && this.appCorpusData) {
return translateSchema(curRendererSchema, this.appCorpusData);
}
- return JSONPipeOut(curRendererSchema);
+ return curRendererSchema;
}
@autobind
diff --git a/packages/amis-formula/src/doc.md b/packages/amis-formula/src/doc.md
index f571ac097..37b95f335 100644
--- a/packages/amis-formula/src/doc.md
+++ b/packages/amis-formula/src/doc.md
@@ -268,6 +268,17 @@
取数据最后一个。
+### POW
+
+用法:`POW(base, exponent)`
+
+ * `base:number` 基数
+ * `exponent:number` 指数
+
+返回:`number` 基数的指数次幂
+
+返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。
+
## 文本函数
### LEFT
diff --git a/packages/amis-formula/src/doc.ts b/packages/amis-formula/src/doc.ts
index c3a72cf65..5291b3029 100644
--- a/packages/amis-formula/src/doc.ts
+++ b/packages/amis-formula/src/doc.ts
@@ -465,6 +465,29 @@ export const doc: {
},
namespace: '数学函数'
},
+ {
+ name: 'POW',
+ description:
+ '返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。',
+ example: 'POW(base, exponent)',
+ params: [
+ {
+ type: 'number',
+ name: 'base',
+ description: '基数'
+ },
+ {
+ type: 'number',
+ name: 'exponent',
+ description: '指数'
+ }
+ ],
+ returns: {
+ type: 'number',
+ description: '基数的指数次幂'
+ },
+ namespace: '数学函数'
+ },
{
name: 'LEFT',
description: '返回传入文本左侧的指定长度字符串。',
diff --git a/packages/amis-formula/src/evalutor.ts b/packages/amis-formula/src/evalutor.ts
index 7befa4b79..8e44dc051 100644
--- a/packages/amis-formula/src/evalutor.ts
+++ b/packages/amis-formula/src/evalutor.ts
@@ -13,6 +13,7 @@ import uniqBy from 'lodash/uniqBy';
import isEqual from 'lodash/isEqual';
import isPlainObject from 'lodash/isPlainObject';
import get from 'lodash/get';
+import isNumber from 'lodash/isNumber';
import {EvaluatorOptions, FilterContext, FilterMap, FunctionMap} from './types';
import {FormulaEvalError} from './error';
@@ -978,6 +979,24 @@ export class Evaluator {
return arr.length ? arr[arr.length - 1] : null;
}
+ /**
+ * 返回基数的指数次幂,参数base为基数,exponent为指数,如果参数值不合法则返回基数本身,计算结果不合法,则返回NaN。
+ *
+ * @example POW(base, exponent)
+ * @param {number} base 基数
+ * @param {number} exponent 指数
+ * @namespace 数学函数
+ *
+ * @returns {number} 基数的指数次幂
+ */
+ fnPOW(base: number, exponent: number) {
+ if (!isNumber(base) || !isNumber(exponent)) {
+ return base;
+ }
+
+ return Math.pow(base, exponent);
+ }
+
// 文本函数
normalizeText(raw: any) {
diff --git a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
index 8553ae3c3..258f07b2d 100644
--- a/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
+++ b/packages/amis/src/renderers/Table/HeadCellSearchDropdown.tsx
@@ -3,9 +3,7 @@ import {RendererProps} from 'amis-core';
import {ActionObject} from 'amis-core';
import {Icon} from 'amis-ui';
import {Overlay} from 'amis-core';
-import {findDOMNode} from 'react-dom';
import {PopOver} from 'amis-core';
-import {ITableStore} from 'amis-core';
import {setVariable, createObject} from 'amis-core';
export interface QuickSearchConfig {
@@ -23,35 +21,31 @@ export interface HeadCellSearchProps extends RendererProps {
onQuery: (values: object) => void;
}
-export class HeadCellSearchDropDown extends React.Component<
- HeadCellSearchProps,
- any
-> {
- state = {
- isOpened: false
- };
-
- formItems: Array<string> = [];
- constructor(props: HeadCellSearchProps) {
- super(props);
-
- this.open = this.open.bind(this);
- this.close = this.close.bind(this);
- this.handleSubmit = this.handleSubmit.bind(this);
- this.handleAction = this.handleAction.bind(this);
- }
-
- buildSchema() {
- const {searchable, sortable, name, label, translate: __} = this.props;
-
+export function HeadCellSearchDropDown({
+ searchable,
+ name,
+ label,
+ onQuery,
+ data,
+ dispatchEvent,
+ onAction,
+ classnames: cx,
+ translate: __,
+ classPrefix: ns,
+ popOverContainer,
+ render
+}: HeadCellSearchProps) {
+ const ref = React.createRef<HTMLElement>();
+ const [formSchema, formItems] = React.useMemo(() => {
let schema: any;
+ const formItems: Array<string> = [];
if (searchable === true) {
schema = {
title: '',
- controls: [
+ body: [
{
- type: 'text',
+ type: 'input-text',
name,
placeholder: label,
clearable: true
@@ -59,21 +53,22 @@ export class HeadCellSearchDropDown extends React.Component<
]
};
} else if (searchable) {
- if (searchable.controls || searchable.tabs || searchable.fieldSet) {
+ if (searchable.body || searchable.tabs || searchable.fieldSet) {
+ // todo 删除此处代码,这些都是不推荐的用法
schema = {
title: '',
...searchable,
- controls: Array.isArray(searchable.controls)
- ? searchable.controls.concat()
+ body: Array.isArray(searchable.body)
+ ? searchable.body.concat()
: undefined
};
} else {
schema = {
title: '',
className: searchable.formClassName,
- controls: [
+ body: [
{
- type: searchable.type || 'text',
+ type: searchable.type || 'input-text',
name: searchable.name || name,
placeholder: label,
...searchable
@@ -83,41 +78,11 @@ export class HeadCellSearchDropDown extends React.Component<
}
}
- if (schema && schema.controls && sortable) {
- schema.controls.unshift(
- {
- type: 'hidden',
- name: 'orderBy',
- value: name
- },
- {
- type: 'button-group',
- name: 'orderDir',
- label: __('sort'),
- options: [
- {
- label: __('asc'),
- value: 'asc'
- },
- {
- label: __('desc'),
- value: 'desc'
- }
- ]
- }
- );
- }
-
if (schema) {
- const formItems: Array<string> = [];
- schema.controls?.forEach(
- (item: any) =>
- item.name &&
- item.name !== 'orderBy' &&
- item.name !== 'orderDir' &&
- formItems.push(item.name)
- );
- this.formItems = formItems;
+ Array.isArray(schema.body) &&
+ schema.body.forEach(
+ (item: any) => item.name && formItems.push(item.name)
+ );
schema = {
...schema,
type: 'form',
@@ -144,64 +109,13 @@ export class HeadCellSearchDropDown extends React.Component<
};
}
- return schema || 'error';
- }
-
- handleClickOutside() {
- this.close();
- }
-
- open() {
- this.setState({
- isOpened: true
- });
- }
-
- close() {
- this.setState({
- isOpened: false
- });
- }
-
- handleAction(e: any, action: ActionObject, ctx: object) {
- const {onAction} = this.props;
-
- if (action.actionType === 'cancel' || action.actionType === 'close') {
- this.close();
- return;
- }
-
- if (action.actionType === 'reset') {
- this.close();
- this.handleReset();
- return;
- }
-
- onAction && onAction(e, action, ctx);
- }
-
- handleReset() {
- const {onQuery, data, name} = this.props;
- const values = {...data};
- this.formItems.forEach(key => setVariable(values, key, undefined));
-
- if (values.orderBy === name) {
- values.orderBy = '';
- values.orderDir = 'asc';
- }
- onQuery(values);
- }
-
- async handleSubmit(values: any) {
- const {onQuery, name, data, dispatchEvent} = this.props;
-
- if (values.orderDir) {
- values = {
- ...values,
- orderBy: name
- };
- }
+ return [schema || 'error', formItems];
+ }, [searchable, name, label]);
+ const [isOpened, setIsOpened] = React.useState(false);
+ const open = React.useCallback(() => setIsOpened(true), []);
+ const close = React.useCallback(() => setIsOpened(false), []);
+ const handleSubmit = React.useCallback(async (values: any) => {
const rendererEvent = await dispatchEvent(
'columnSearch',
createObject(data, {
@@ -214,78 +128,81 @@ export class HeadCellSearchDropDown extends React.Component<
return;
}
- this.close();
-
+ close();
onQuery(values);
- }
+ }, []);
- isActive() {
- const {data, name, orderBy} = this.props;
+ const handleAction = React.useCallback(
+ (e: any, action: ActionObject, ctx: object) => {
+ if (action.actionType === 'cancel' || action.actionType === 'close') {
+ close();
+ return;
+ }
- return orderBy === name || this.formItems.some(key => data?.[key]);
- }
+ if (action.actionType === 'reset') {
+ close();
+ handleReset();
+ return;
+ }
- render() {
- const {
- render,
- name,
- data,
- searchable,
- store,
- orderBy,
- popOverContainer,
- classPrefix: ns,
- classnames: cx
- } = this.props;
+ onAction && onAction(e, action, ctx);
+ },
+ []
+ );
- const formSchema = this.buildSchema();
- const isActive = this.isActive();
+ const handleReset = React.useCallback(() => {
+ const values = {...data};
+ // todo 这里不精准,如果表单项有容器嵌套,这里将不正确
+ formItems.forEach(key => setVariable(values, key, undefined));
- return (
- <span
- className={cx(
- `${ns}TableCell-searchBtn`,
- isActive ? 'is-active' : '',
- this.state.isOpened ? 'is-opened' : ''
- )}
- >
- <span onClick={this.open}>
- <Icon icon="search" className="icon" />
- </span>
- {this.state.isOpened ? (
- <Overlay
- container={popOverContainer || (() => findDOMNode(this))}
- placement="left-bottom-left-top right-bottom-right-top"
- target={
- popOverContainer ? () => findDOMNode(this)!.parentNode : null
- }
- show
- >
- <PopOver
- classPrefix={ns}
- onHide={this.close}
- className={cx(
- `${ns}TableCell-searchPopOver`,
- (searchable as any).className
- )}
- overlay
- >
- {
- render('quick-search-form', formSchema, {
- data: {
- ...data,
- orderBy: orderBy,
- orderDir:
- orderBy === name ? (store as ITableStore).orderDir : ''
- },
- onSubmit: this.handleSubmit,
- onAction: this.handleAction
- }) as JSX.Element
- }
- </PopOver>
- </Overlay>
- ) : null}
+ onQuery(values);
+ }, [data]);
+
+ const isActive = React.useMemo(() => {
+ // todo 这里不精准,如果表单项有容器嵌套,这里将不正确
+ return formItems.some(key => data?.[key]);
+ }, [data]);
+
+ return (
+ <span
+ ref={ref}
+ className={cx(
+ `${ns}TableCell-searchBtn`,
+ isActive ? 'is-active' : '',
+ isOpened ? 'is-opened' : ''
+ )}
+ >
+ <span onClick={open}>
+ <Icon icon="search" className="icon" />
</span>
- );
- }
+ {isOpened ? (
+ <Overlay
+ container={popOverContainer || (() => ref.current)}
+ placement="left-bottom-left-top right-bottom-right-top"
+ target={popOverContainer ? () => ref.current?.parentNode : null}
+ show
+ >
+ <PopOver
+ classPrefix={ns}
+ onHide={close}
+ className={cx(
+ `${ns}TableCell-searchPopOver`,
+ (searchable as any).className
+ )}
+ overlay
+ >
+ {
+ render('quick-search-form', formSchema, {
+ data: {
+ ...data
+ },
+ onSubmit: handleSubmit,
+ onAction: handleAction
+ }) as JSX.Element
+ }
+ </PopOver>
+ </Overlay>
+ ) : null}
+ </span>
+ );
}
diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx
index 62ddc298b..f07dcc238 100644
--- a/packages/amis/src/renderers/Table/index.tsx
+++ b/packages/amis/src/renderers/Table/index.tsx
@@ -1860,11 +1860,8 @@ export default class Table extends React.Component<TableProps, object> {
onQuery={onQuery}
name={column.name}
searchable={column.searchable}
- sortable={false}
type={column.type}
data={query}
- orderBy={store.orderBy}
- orderDir={store.orderDir}
popOverContainer={this.getPopOverContainer}
/>
);
| chore: 调整列的快速搜索逻辑干掉之前没清理干净的排序相关逻辑 Close: #8342
### What
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 1113e82</samp>
Refactored and simplified a table header component that supports searching and filtering. Used React hooks and removed unused code.
<!--
copilot:poem
-->
### <samp>🤖 Generated by Copilot at 1113e82</samp>
> _Sing, O Muse, of the skillful refactorer_
> _Who tamed the `HeadCellSearchDropDown` with hooks_
> _And cleansed the form schema and data of clutter_
> _And cast away the props and code of nooks_
### Why
Close: #8342
### How
<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 1113e82</samp>
* Refactor `HeadCellSearchDropDown` component from class to functional, using hooks and removing unused props and fields ([link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L6-R6), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L26-R48), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L62-R62), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L74-R71), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L86-R85), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L147-R118), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L217-R207))
* Replace `controls` with `body` in `searchable` prop and change default type to `input-text` ([link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L62-R62), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L74-R71))
* Remove `orderBy` and `orderDir` fields from form schema and data, as they are no longer needed ([link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L86-R85), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L147-R118), [link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L217-R207))
* Use `dispatchEvent` prop to trigger `columnSearch` event before submitting form values ([link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L147-R118))
* Use `ref` to attach span element as container and target for `Overlay` component ([link](https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L217-R207))
| **Title**
Remove residual sorting logic from column quick‑search and streamline related components
**Problem**
The quick‑search dropdown in table headers still injected hidden sorting fields (`orderBy`, `orderDir`) and relied on outdated class‑based implementation, causing confusing query parameters and unnecessary complexity. Similar leftover sorting handling existed in the CRUD store and example configuration.
**Root Cause**
Sorting‑related code was never fully removed after refactoring, and the component used an internal store copy instead of the incoming props for data synchronization.
**Fix / Expected Behavior**
- Eliminate hidden sorting fields from the quick‑search form schema and stop passing `orderBy`/`orderDir` to the dropdown.
- Rewrite the dropdown as a functional component using hooks, with proper opening/closing logic and overlay container handling.
- Ensure the dropdown only emits the `columnSearch` event with the actual search values.
- Update the CRUD example to use a header toolbar form for mode selection and keyword search, removing the old `filter` block.
- Adjust the store sync to use the component’s `data` prop, and simplify query handling in the CRUD store.
- Extend the generic `mapObject` helper to accept an optional skip function and propagate it through recursive calls.
- Update schema translation utilities to forward the new skip parameter.
- Add the `POW` mathematical function to the formula engine with documentation.
**Risk & Validation**
- Verify that table column search no longer includes sorting parameters and that the `columnSearch` event receives correct payloads.
- Test the CRUD list example to confirm mode‑based API calls and keyword search work as expected.
- Run the existing test suite, especially UI rendering and formula evaluation tests, to ensure no regressions from the functional component conversion.
- Manually check that translation and helper utilities still operate correctly with the added `skipFn` argument. | 8,360 | baidu/amis | diff --git a/packages/amis-formula/__tests__/evalute.test.ts b/packages/amis-formula/__tests__/evalute.test.ts
index 4670b3906..2fb97d99a 100644
--- a/packages/amis-formula/__tests__/evalute.test.ts
+++ b/packages/amis-formula/__tests__/evalute.test.ts
@@ -539,3 +539,26 @@ test('evalute:ISTYPE', () => {
expect(evaluate('${ISTYPE(f, "plain-object")}', data)).toBe(true);
expect(evaluate('${ISTYPE(g, "date")}', data)).toBe(true);
});
+
+test('evalute:Math', () => {
+ const data = {
+ float: 0.5,
+ integer1: 2,
+ integer2: 4,
+ negativeInteger: -2,
+ array: [1, 2 ,3],
+ infinity: Infinity
+ }
+
+ expect(evaluate('${POW(integer1, integer2)}', data)).toBe(16);
+ expect(evaluate('${POW(integer2, 0.5)}', data)).toBe(2);
+ expect(evaluate('${POW(integer1, -2)}', data)).toBe(0.25);
+ /** 计算结果不合法,则返回NaN */
+ expect(evaluate('${POW(negativeInteger, 0.5)}', data)).toBe(NaN);
+ /** 参数值不合法,则返回基数本身*/
+ expect(evaluate('${POW(array, 2)}', data)).toBe(data.array);
+ /** 测试Infinity */
+ expect(evaluate('${POW(infinity, 2)}', data)).toBe(data.infinity);
+ expect(evaluate('${POW(1, infinity)}', data)).toBe(NaN);
+ expect(evaluate('${POW(2, infinity)}', data)).toBe(data.infinity);
+})
| [
"evalute:Math"
] | [
"parser:simple",
"parser:complex",
"parser:evalMode",
"parser:template",
"parser:string",
"parser:number",
"parser:single-string",
"parser:object-literall",
"parser:array-literall",
"parser:variable-geter",
"parser:variable-geter2",
"parser:multi-expression",
"parser:functionCall",
"parser:filter",
"parser:filter-escape",
"parser:conditional",
"parser:binary-expression",
"parser:group-expression",
"parser:unary-expression",
"parser:anonymous-function",
"lexer:simple",
"lexer:filter",
"lexer:exception",
"evalute:simple",
"evalute:filter",
"evalute:filter2",
"evalute:filter3",
"evalute:filter4",
"evalute:keywords",
"evalute:oldVariable",
"evalute:ariable2",
"evalute:ariable3",
"evalute:object-variable",
"evalute:literal-variable",
"evalute:tempalte",
"evalute:literal",
"evalute:variableName",
"evalute:3-1",
"evalate:0.1+0.2",
"evalute:variable:com.xxx.xx",
"evalute:anonymous:function",
"evalute:anonymous:function2",
"evalute:array:func",
"evalute:ISTYPE",
"formula:expression",
"formula:expression2",
"formula:expression3",
"formula:if",
"formula:and",
"formula:or",
"formula:xor",
"formula:ifs",
"formula:math",
"formula:text",
"formula:date",
"formula:last",
"formula:basename",
"formula:customFunction"
] | Method: Evaluator.fnPOW(base: number, exponent: number)
Location: packages/amis-formula/src/evalutor.ts → class Evaluator
Inputs:
- **base**: `number` – the base value for exponentiation. If not a number, the function returns the original `base` unchanged.
- **exponent**: `number` – the exponent value. If not a number, the function returns the original `base` unchanged.
Outputs:
- Returns a `number` equal to `Math.pow(base, exponent)`. If the computation results in an invalid number (e.g., a negative base with a non‑integer exponent), the result is `NaN`. For non‑numeric arguments, the original `base` is returned unchanged.
Description:
Calculates the exponentiation of `base` raised to `exponent`. Used by the Formula evaluator when the `POW` function appears in an expression (e.g., `${POW(a, b)}`). Handles type validation and propagates `NaN` for mathematically invalid results. | custom-check-github | {
"base_image_name": "node_16",
"install": [
"npm install"
],
"log_parser": "parse_log_js_4",
"test_cmd": "cd packages/amis-formula && npx jest --verbose --no-color"
} | {
"num_modified_files": 11,
"num_modified_lines": 212,
"pr_author": "2betop",
"pr_labels": [
"chore"
],
"llm_metadata": {
"code": "B1",
"code_quality": null,
"confidence": 0.78,
"detected_issues": {
"B1": true,
"B2": false,
"B3": false,
"B4": false,
"B5": false,
"B6": false
},
"detected_issues_explanation": null,
"detecte d_issues": null,
"difficulty": "medium",
"external_urls": [
"https://github.com/baidu/amis/pull/8360/files?diff=unified&w=0#diff-f7780da9091a356f2349f5d0b7e7c95fbc83b5ea89ebed9e46482c91572183a5L6-R6"
],
"intent_completeness": "complete",
"patch": null,
"pr_categories": [
"core_feat"
],
"reason": null,
"reasoning": "The issue describes refactoring the table header quick‑search component and removing sorting logic, but the provided test patch adds tests for a new POW function in the formula evaluator, which is unrelated to the UI change. The tests do not verify the described behavior, indicating a coupling between the test suite and unrelated code. Therefore the primary problem is a test‑suite coupling issue (B1).",
"suggested_fixes": null,
"test_alignment": null,
"test_alignment_issues": [
"Tests target POW function in amis‑formula, while issue concerns HeadCellSearchDropDown UI refactor",
"No tests verify the removal of sorting fields or the new hook‑based component"
],
"test_alignment_quick_tree": null,
"test_alignment_quick_tree_bootstrap": null,
"test_alignment_quick_tree_mocks": null,
"test_alignment_quick_tree_params": null,
"test_alignment_quick_tree_unrelated": null,
"test_alignment_quick_tree_use_hook": null,
"test_alignment_quick_tree_use_hook_unrelated": null,
"test_alignment_sample_without_replacement": null,
"test_alignment_test_alignment_sample_without_replacement": null,
"test_build_phylogeny": null,
"test_build_phylogeny_unrelated": null,
"test_build_phylogeny_use_hook": null,
"test_build_phylogeny_use_hook_unrelated": null,
"test_core_seq_test_sample_motif_length_1": null,
"test_core_seq_test_sample_motif_length_3": null,
"test_core_seq_test_sample_without_replacement": null,
"test_core_sequence": null,
"test_core_sequence_test_sample_motif_length_1": null,
"test_core_sequence_test_sample_motif_length_3": null,
"test_core_sequence_test_sample_without_replacement": null,
"test_sample_motif_length_1": null,
"test_sample_motif_length_3": null,
"test_sample_without_replacement": null
}
} | |
79728ddad4ddfdad819d4ea6e152790ba2aa410e | 2023-10-12 06:11:20 | "github-actions[bot]: <!-- Labeler (https://github.com/jimschubert/labeler) -->\n👍 Thanks for thi(...TRUNCATED) | baidu__amis-8365 | "diff --git a/docs/zh-CN/components/table2.md b/docs/zh-CN/components/table2.md\nindex 3443a8ef2..a3(...TRUNCATED) | "fix: 修复 REPLACE 公式第二个参数是空字符串时导致的死循环问题 Close: #8200\n#(...TRUNCATED) | "**Title** \nFix REPLACE formula infinite loop, add POW function and stabilize table rendering \n\(...TRUNCATED) | 8,365 | baidu/amis | "diff --git a/packages/amis-formula/__tests__/evalute.test.ts b/packages/amis-formula/__tests__/eval(...TRUNCATED) | [
"evalute:Math"
] | ["lexer:simple","lexer:filter","lexer:exception","parser:simple","parser:complex","parser:evalMode",(...TRUNCATED) | "Method: Evaluator.fnPOW(self, base: number, exponent: number)\nLocation: packages/amis-formula/src/(...TRUNCATED) | custom-check-github | {"base_image_name":"node_16","install":["npm install"],"log_parser":"parse_log_js_4","test_cmd":"cd (...TRUNCATED) | {"num_modified_files":22,"num_modified_lines":609,"pr_author":"2betop","pr_labels":["fix"],"llm_meta(...TRUNCATED) |
79728ddad4ddfdad819d4ea6e152790ba2aa410e | 2023-10-12 08:54:51 | baidu__amis-8370 | "diff --git a/examples/components/CRUD/List.jsx b/examples/components/CRUD/List.jsx\nindex 15d65c389(...TRUNCATED) | "feat: 表达式新增幂函数(Math.pow)\n### What\r\n\r\n<!--\ncopilot:summary\n-->\n### <samp>(...TRUNCATED) | "**Title** \nAdd exponentiation support and correct CRUD/store handling \n\n**Problem** \n- Formu(...TRUNCATED) | 8,370 | baidu/amis | "diff --git a/packages/amis-formula/__tests__/evalute.test.ts b/packages/amis-formula/__tests__/eval(...TRUNCATED) | [
"evalute:Math"
] | ["evalute:simple","evalute:filter","evalute:filter2","evalute:filter3","evalute:filter4","evalute:ke(...TRUNCATED) | "Method: Evaluator.fnPOW(base: number, exponent: number)\nLocation: packages/amis-formula/src/evalut(...TRUNCATED) | custom-check-github | {"base_image_name":"node_16","install":["npm install"],"log_parser":"parse_log_js_4","test_cmd":"cd (...TRUNCATED) | {"num_modified_files":7,"num_modified_lines":100,"pr_author":"lurunze1226","pr_labels":["feat"],"llm(...TRUNCATED) | |
6f599d5d939201ad5b809001425b333b87c6ec12 | 2023-10-13 09:45:51 | "github-actions[bot]: <!-- Labeler (https://github.com/jimschubert/labeler) -->\n👍 Thanks for thi(...TRUNCATED) | baidu__amis-8385 | "diff --git a/docs/zh-CN/types/classname.md b/docs/zh-CN/types/classname.md\nindex fbfa53d12..049ac8(...TRUNCATED) | "feat: formula 取 cookie, localstorage, sessionstorage支持 &['xxx'] 来获取复杂变量名数(...TRUNCATED) | "**Title** \nEnable dynamic class name expressions and support special‑character keys in cookie/l(...TRUNCATED) | 8,385 | baidu/amis | "diff --git a/packages/amis-formula/__tests__/async-evalute.test.ts b/packages/amis-formula/__tests_(...TRUNCATED) | [
"evalute:namespace",
"async-evalute:namespace"
] | ["evalute:simple","evalute:filter","evalute:filter2","evalute:filter3","evalute:filter4","evalute:ke(...TRUNCATED) | No new interfaces are introduced. | custom-check-github | {"base_image_name":"node_16","install":["npm install"],"log_parser":"parse_log_js_4","test_cmd":"cd (...TRUNCATED) | {"num_modified_files":6,"num_modified_lines":95,"pr_author":"2betop","pr_labels":["feat"],"llm_metad(...TRUNCATED) |
983b98f9573e1bc58602bb78ea31d87d3ce829a0 | 2024-06-13 20:29:57 | "codecov[bot]: ## [Codecov](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull(...TRUNCATED) | materials-consortia__optimade-python-tools-2097 | "diff --git a/openapi/openapi.json b/openapi/openapi.json\nindex c5f1a39e..11eb639e 100644\n--- a/op(...TRUNCATED) | "Validate property names against identifier regular expression\nThis PR implements property name val(...TRUNCATED) | "**Title** \nEnforce OPTIMADE identifier rules for property and field names \n\n**Problem** \nCli(...TRUNCATED) | 2,097 | Materials-Consortia/optimade-python-tools | "diff --git a/tests/models/test_baseinfo.py b/tests/models/test_baseinfo.py\nindex 6d24a116..49d9bd5(...TRUNCATED) | [
"tests/models/test_baseinfo.py::test_bad_entry_info_custom_properties"
] | ["tests/models/test_baseinfo.py::test_available_api_versions","tests/models/test_baseinfo.py::test_g(...TRUNCATED) | "Method: EntryInfoResource.__init__(self, formats: list[str], description: str, output_fields_by_for(...TRUNCATED) | MIT | {"base_image_name":"python_base_310","install":["git submodule update --init --recursive","pip insta(...TRUNCATED) | {"num_modified_files":4,"num_modified_lines":15,"pr_author":"merkys","pr_labels":[],"llm_metadata":{(...TRUNCATED) |
ce04b39d8a6488b9220f0a8f23f55e09886205fa | 2024-10-30 11:20:48 | "codecov[bot]: ## [Codecov](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull(...TRUNCATED) | materials-consortia__optimade-python-tools-2175 | "diff --git a/optimade/server/config.py b/optimade/server/config.py\nindex 29ba11a1..7b56469c 100644(...TRUNCATED) | "Quality of life changes around JSONL & MongoDB\n- Better error handling and logging on JSONL insert(...TRUNCATED) | "**Title** \nAdd optional default index creation and improve robustness of JSONL data ingestion \n(...TRUNCATED) | 2,175 | Materials-Consortia/optimade-python-tools | "diff --git a/tests/server/entry_collections/test_indexes.py b/tests/server/entry_collections/test_i(...TRUNCATED) | [
"tests/server/entry_collections/test_indexes.py::test_indexes_are_created_where_appropriate"
] | [] | "Method: EntryCollection.insert(self, data: list[EntryResource | dict]) -> None\nLocation: optimade/(...TRUNCATED) | MIT | {"base_image_name":"python_base_310","install":["git submodule update --init --recursive","pip insta(...TRUNCATED) | {"num_modified_files":6,"num_modified_lines":116,"pr_author":"ml-evs","pr_labels":[],"llm_metadata":(...TRUNCATED) |
e171370b70f66dd849211689b5f4aad3a766d6fb | 2025-02-28 12:35:08 | "codecov[bot]: ## [Codecov](https://app.codecov.io/gh/Materials-Consortia/optimade-python-tools/pull(...TRUNCATED) | materials-consortia__optimade-python-tools-2236 | "diff --git a/openapi/openapi.json b/openapi/openapi.json\nindex e2c67e8e..94ef86e7 100644\n--- a/op(...TRUNCATED) | "Add support for `space_group_symmetry_operations_xyz`\nAs above. Adds the OPTIMADE 1.2 field `space(...TRUNCATED) | "**Title** \nAdd OPTIMADE 1.2 `space_group_symmetry_operations_xyz` support to the Structure mo(...TRUNCATED) | 2,236 | Materials-Consortia/optimade-python-tools | "diff --git a/tests/adapters/structures/test_structures.py b/tests/adapters/structures/test_structur(...TRUNCATED) | ["tests/models/test_structures.py::test_structure_fatal_deformities[deformity28]","tests/models/test(...TRUNCATED) | ["tests/adapters/structures/test_structures.py::test_instantiate","tests/adapters/structures/test_st(...TRUNCATED) | "Method: StructureResourceAttributes.check_symmetry_operations(self) \nLocation: optimade/models/str(...TRUNCATED) | MIT | {"base_image_name":"python_base_310","install":["git submodule update --init --recursive","pip insta(...TRUNCATED) | {"num_modified_files":4,"num_modified_lines":77,"pr_author":"ml-evs","pr_labels":["schema: Concerns (...TRUNCATED) |
d6ca66644751d6df2dd0ed3591e63402186cd710 | 2020-04-24 14:12:02 | "abdullahgarcia: Please, review accordingly\niYehuda: Hi @abdullahgarcia, thanks for your contributi(...TRUNCATED) | aquasecurity__kube-hunter-344 | "diff --git a/docs/_kb/KHV051.md b/docs/_kb/KHV051.md\nnew file mode 100644\nindex 0000000..b09de24\(...TRUNCATED) | "Two new kubelet active hunters.\n<!---\r\n Thank you for contributing to Aqua Security.\r\n P(...TRUNCATED) | "**Title** \nAdd active hunters for exposing and exploiting privileged containers via an insecure k(...TRUNCATED) | 344 | aquasecurity/kube-hunter | "diff --git a/tests/core/test_handler.py b/tests/core/test_handler.py\nindex 5c48975..5ccc71e 100644(...TRUNCATED) | ["tests/core/test_handler.py::test_passive_hunters_registered","tests/core/test_handler.py::test_act(...TRUNCATED) | [] | "Method: ProveAnonymousAuth.__init__(self, event)\nLocation: kube_hunter.modules.hunting.kubelet.Pro(...TRUNCATED) | custom-check-github | {"base_image_name":"python_base_310","install":["pip install -q -r requirements-dev.txt","pip instal(...TRUNCATED) | {"num_modified_files":3,"num_modified_lines":573,"pr_author":"abdullahgarcia","pr_labels":[],"llm_me(...TRUNCATED) |
ad4cfe1c11391f66b05df7e26f2059515f1f9988 | 2020-09-07 12:13:32 | "codecov[bot]: # [Codecov](https://codecov.io/gh/aquasecurity/kube-hunter/pull/372?src=pr&el=h1) Rep(...TRUNCATED) | aquasecurity__kube-hunter-372 | "diff --git a/kube_hunter/modules/hunting/aks.py b/kube_hunter/modules/hunting/aks.py\nindex a5877c3(...TRUNCATED) | fix azure spn hunter
Fixes https://github.com/aquasecurity/kube-hunter/issues/370
| "**Title** \nImprove Azure SPN hunter to detect azure.json mounted via hostPath volumes \n\n**Prob(...TRUNCATED) | 372 | aquasecurity/kube-hunter | "diff --git a/tests/hunting/test_aks.py b/tests/hunting/test_aks.py\nnew file mode 100644\nindex 000(...TRUNCATED) | [
"tests/hunting/test_aks.py::test_AzureSpnHunter"
] | [] | "Method: AzureSpnHunter.__init__(self, handler)\nLocation: kube_hunter/modules/hunting/aks.py\nInput(...TRUNCATED) | custom-check-github | {"base_image_name":"python_base_310","install":["pip install -q -r requirements-dev.txt","pip instal(...TRUNCATED) | {"num_modified_files":1,"num_modified_lines":8,"pr_author":"itaysk","pr_labels":[],"llm_metadata":{"(...TRUNCATED) |
SWE-rebench-V2-PRs
Dataset Summary
SWE-rebench-V2-PRs is a large-scale dataset of real-world GitHub pull requests collected across multiple programming languages, intended for training and evaluating code-generation and software-engineering agents. The dataset contains 126,300 samples covering Go, Python, JavaScript, TypeScript, Rust, Java, C, C++, Julia, Elixir, Kotlin, PHP, Scala, Clojure, Dart, OCaml, and other languages. For log parser functions, base Dockerfiles, and the prompts used, please see https://github.com/SWE-rebench/SWE-rebench-V2
Quick Start
from datasets import load_dataset
ds = load_dataset("nebius/SWE-rebench-V2-PRs", split="train")
print(len(ds)) # 126300
Dataset Structure
| Field | Type | Description |
|---|---|---|
instance_id |
string |
Unique identifier for the instance |
repo |
string |
GitHub repository in owner/repo format |
pull_number |
int64 |
Pull request number |
base_commit |
string |
Git commit SHA of the base before the PR |
patch |
string |
The gold patch introduced by the pull request |
test_patch |
string |
Diff adding or modifying tests that verify the patch |
problem_statement |
string |
Issue description the pull request addresses |
pr_description |
string |
Full pull request description |
hints_text |
string |
Additional hints extracted from the issue thread |
created_at |
int64 |
Unix timestamp (milliseconds) of PR creation |
FAIL_TO_PASS |
list[string] |
Test IDs that fail before the patch and pass after |
PASS_TO_PASS |
list[string] |
Test IDs that pass both before and after the patch |
interface |
string |
Description of the code interface changed by the PR |
license |
string |
SPDX license identifier of the repository |
install_config |
struct |
Configuration needed to reproduce the test environment |
meta |
struct |
Metadata and LLM-generated quality annotations |
License
The dataset is licensed under the Creative Commons Attribution 4.0 license. However, please respect the license of each specific repository on which a particular instance is based. To facilitate this, the license of each repository at the time of the commit is provided for every instance.
Citation
@misc{badertdinov2026swerebenchv2languageagnosticswe,
title={SWE-rebench V2: Language-Agnostic SWE Task Collection at Scale},
author={Ibragim Badertdinov and Maksim Nekrashevich and Anton Shevtsov and Alexander Golubev},
year={2026},
eprint={2602.23866},
archivePrefix={arXiv},
primaryClass={cs.SE},
url={https://arxiv.org/abs/2602.23866},
}
- Downloads last month
- 7