Merge branch 'master' into feat-context

This commit is contained in:
lvxiaojiao 2023-05-06 11:47:15 +08:00
commit 1a6842d9dc
161 changed files with 793 additions and 1732 deletions

View File

@ -44,4 +44,7 @@ jobs:
- name: test
run: |
npm test --workspaces
cd packages/ooxml-viewer
npm test
cd ../../
sh deploy-gh-pages.sh

View File

@ -675,12 +675,22 @@ Cards 模式支持 [Cards](./cards) 中的所有功能。
通过设置`"autoGenerateFilter": true`开启查询区域,会根据列元素的 `searchable` 属性值,自动生成查询条件表单,只有 `searchable` 属性值为合法的组件 Schema 时才会生成查询条件。注意这个属性和 `filter` 冲突,开启 `filter``autoGenerateFilter` 将会失效。
### autoGenerateFilter 属性表
| 属性名 | 类型 | 默认值 | 说明 |
| -------------- | --------- | ------ | -------------------- |
| columnsNum | `number` | `3` | 过滤条件单行列数 |
| showBtnToolbar | `boolean` | `true` | 是否显示设置查询字段 |
```schema: scope="body"
{
"type": "crud",
"api": "/api/mock2/sample",
"syncLocation": false,
"autoGenerateFilter": true,
"autoGenerateFilter": {
"columnsNum": 2,
"showBtnToolbar": false
},
"headerToolbar": [
{
"type": "columns-toggler",
@ -704,7 +714,7 @@ Cards 模式支持 [Cards](./cards) 中的所有功能。
},
{
"name": "engine",
"label": "Rendering engine"
"label": "Rendering engine",
},
{
"name": "browser",
@ -2886,7 +2896,7 @@ itemAction 里的 onClick 还能通过 `data` 参数拿到当前行的数据,
| footerToolbar | Array | `['statistics', 'pagination']` | 底部工具栏配置 |
| alwaysShowPagination | `boolean` | `false` | 是否总是显示分页 |
| affixHeader | `boolean` | `true` | 是否固定表头(table 下) |
| autoGenerateFilter | `boolean` | `false` | 是否开启查询区域,开启后会根据列元素的 `searchable` 属性值,自动生成查询条件表单 |
| autoGenerateFilter | `Object \| boolean` | | 是否开启查询区域,开启后会根据列元素的 `searchable` 属性值,自动生成查询条件表单 |
| resetPageAfterAjaxItemAction | `boolean` | `false` | 单条数据 ajax 操作后是否重置页码为第一页 |
| autoFillHeight | `boolean``{height: number}` | | 内容区域自适应高度 |

View File

@ -327,7 +327,7 @@ Dialog 弹框 主要由 [Action](./action) 触发,主要展示一个对话框
}
```
## 行为后关闭弹框
## 动作后关闭弹框
在弹框中配置行为按钮,可以在按钮上配置`"close": true`,在行为完成后,关闭当前弹框。
@ -357,9 +357,49 @@ Dialog 弹框 主要由 [Action](./action) 触发,主要展示一个对话框
}
```
以上例子是关闭当前弹窗,如果希望关闭上层弹窗,则需要给目标弹窗设置 `name` 属性,然后配置按钮 `close` 属性为目标 `name` 属性如:
```schema: scope="body"
{
"type": "button",
"label": "多级弹框",
"actionType": "dialog",
"dialog": {
"title": "提示",
"body": "这是个简单的弹框",
"name": "dialog_1",
"actions": [
{
"type": "button",
"actionType": "confirm",
"label": "确认",
"primary": true
},
{
"type": "button",
"actionType": "dialog",
"label": "再弹一个",
"dialog": {
"title": "弹框中的弹框",
"body": "关闭当前弹窗的时候把外层的弹窗一起关了",
"actions": [
{
"type": "button",
"label": "关闭所有",
"level": "info",
"close": "dialog_1"
}
]
}
}
]
}
}
```
## 配置弹窗的按钮
可以通过设置 `actions` 来控制弹窗中的按钮。
默认弹窗会自动生成两个按钮,一个取消,一个确认。如果通过 `actions` 来自定义配置,则以配置的为准
```schema: scope="body"
{

View File

@ -279,6 +279,164 @@ order: 43
}
```
## 多级弹框
```schema: scope="body"
{
"type": "button",
"label": "多级弹框",
"actionType": "drawer",
"drawer": {
"title": "提示",
"body": "这是个简单的弹框",
"actions": [
{
"type": "button",
"actionType": "confirm",
"label": "确认",
"primary": true
},
{
"type": "button",
"actionType": "drawer",
"label": "再弹一个",
"drawer": {
"title": "弹框中的弹框",
"body": "如果你想,可以无限弹下去",
"actions": [
{
"type": "button",
"actionType": "drawer",
"label": "来吧",
"level": "info",
"drawer": {
"title": "弹框中的弹框",
"body": "如果你想,可以无限弹下去",
"actions": [
{
"type": "button",
"actionType": "confirm",
"label": "不弹了",
"primary": true
}
]
}
}
]
}
}
]
}
}
```
## 动作后关闭弹框
在弹框中配置行为按钮,可以在按钮上配置`"close": true`,在行为完成后,关闭当前弹框。
```schema: scope="body"
{
"type": "button",
"label": "弹个框",
"actionType": "drawer",
"drawer": {
"title": "弹框",
"body": [
{
"type": "button",
"label": "默认的 ajax 请求",
"actionType": "ajax",
"api": "/api/mock2/form/saveForm?waitSeconds=1"
},
{
"type": "button",
"label": "ajax 请求成功后关闭弹框",
"actionType": "ajax",
"api": "/api/mock2/form/saveForm?waitSeconds=1",
"close": true
}
]
}
}
```
以上例子是关闭当前弹窗,如果希望关闭上层弹窗,则需要给目标弹窗设置 `name` 属性,然后配置按钮 `close` 属性为目标 `name` 属性如:
```schema: scope="body"
{
"type": "button",
"label": "多级弹框",
"actionType": "drawer",
"drawer": {
"title": "提示",
"body": "这是个简单的弹框",
"name": "drawer_1",
"actions": [
{
"type": "button",
"actionType": "confirm",
"label": "确认",
"primary": true
},
{
"type": "button",
"actionType": "drawer",
"label": "再弹一个",
"drawer": {
"title": "弹框中的弹框",
"body": "关闭当前弹窗的时候把外层的弹窗一起关了",
"actions": [
{
"type": "button",
"label": "关闭所有",
"level": "info",
"close": "drawer_1"
}
]
}
}
]
}
}
```
## 配置弹窗的按钮
默认弹窗会自动生成两个按钮,一个取消,一个确认。如果通过 `actions` 来自定义配置,则以配置的为准。
```schema: scope="body"
{
"type": "button-toolbar",
"buttons": [
{
"type": "button",
"label": "无按钮",
"actionType": "dialog",
"dialog": {
"title": "提示",
"actions": [],
"body": "无按钮的弹框"
}
},
{
"type": "button",
"label": "只有一个确认按钮",
"actionType": "dialog",
"dialog": {
"title": "提示",
"actions": [{
"type": "button",
"actionType": "confirm",
"label": "OK",
"primary": true
}],
"body": "只有一个 OK 的弹框"
}
}
]
}
```
## 属性表
| 属性名 | 类型 | 默认值 | 说明 |

View File

@ -270,13 +270,13 @@ export const defaultOptions: RenderOptions = {
},
isCancel() {
console.error(
'Please implement isCancel. see https://baidu.gitee.io/amis/docs/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
'Please implement isCancel. see https://aisuda.bce.baidu.com/amis/zh-CN/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
);
return false;
},
updateLocation() {
console.error(
'Please implement updateLocation. see https://baidu.gitee.io/amis/docs/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
'Please implement updateLocation. see https://aisuda.bce.baidu.com/amis/zh-CN/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
);
},

View File

@ -186,7 +186,7 @@ export interface FormSchemaBase {
/**
* Form api
*
* https://baidu.gitee.io/amis/docs/components/form/index#%E8%A1%A8%E5%8D%95%E6%8F%90%E4%BA%A4
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/index#%E8%A1%A8%E5%8D%95%E6%8F%90%E4%BA%A4
*/
api?: string | BaseApiObject;

View File

@ -431,13 +431,14 @@ type Category = 'api' | 'event';
* @param ext
*/
export function debug(cat: Category, msg: string, ext?: object) {
if (!isEnabled) {
return;
}
console.groupCollapsed('[amis debug]', msg);
console.debug(ext);
console.groupEnd();
if (!isEnabled) {
return;
}
const log = {
cat,
level: 'debug',

View File

@ -475,7 +475,7 @@ export default class Editor extends Component<EditorProps> {
preview() {
if (this.props.onPreview) {
this.props.onPreview(true);
this.props.onPreview(!this.props.preview);
}
}

View File

@ -53,9 +53,9 @@ const ShortcutKeyList = [
tooltip: '保存当前所有操作'
},
{
title: '预览',
title: '预览/编辑',
letters: ['⌘', 'p'],
tooltip: '开启预览模式'
tooltip: '开启/关闭预览模式'
},
{
title: '删除',

View File

@ -121,6 +121,7 @@ export function registerEditorPlugin(klass: PluginClass) {
isExitPlugin = builtInPlugins.find(item => item === klass);
}
if (!isExitPlugin) {
klass.id = klass.id || klass.name || guid();
builtInPlugins.push(klass);
} else {
console.warn(`注册插件异常,已存在同名插件:`, klass);

View File

@ -1,4 +1,4 @@
import {Button, resolveVariable} from 'amis';
import {Button} from 'amis';
import React from 'react';
import {registerEditorPlugin} from 'amis-editor-core';
import {
@ -16,6 +16,7 @@ import {
} from 'amis-editor-core';
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
import {diff, JSONPipeOut, repeatArray} from 'amis-editor-core';
import {resolveArrayDatasource} from '../util';
export class CardsPlugin extends BasePlugin {
static scene = ['layout'];
@ -252,11 +253,11 @@ export class CardsPlugin extends BasePlugin {
...props.defaultData,
...props.data
};
const arr = Array.isArray(props.value)
? props.value
: typeof props.source === 'string'
? resolveVariable(props.source, data)
: resolveVariable('items', data);
const arr = resolveArrayDatasource({
value: props.value,
data,
source: props.source
});
if (!Array.isArray(arr) || !arr.length) {
const mockedData: any = {

View File

@ -1,5 +1,5 @@
import React from 'react';
import {resolveVariable, Button} from 'amis';
import {Button} from 'amis';
import {
registerEditorPlugin,
BaseEventContext,
@ -25,6 +25,7 @@ import {
getArgsWrapper
} from '../../renderer/event-control/helper';
import cloneDeep from 'lodash/cloneDeep';
import {resolveArrayDatasource} from '../../util';
export class TableControlPlugin extends BasePlugin {
// 关联渲染器名字
@ -791,11 +792,7 @@ export class TableControlPlugin extends BasePlugin {
};
filterProps(props: any) {
const arr = Array.isArray(props.value)
? props.value
: typeof props.source === 'string'
? resolveVariable(props.source, props.data)
: resolveVariable('items', props.data);
const arr = resolveArrayDatasource(props);
if (!Array.isArray(arr) || !arr.length) {
const mockedData: any = {};

View File

@ -118,11 +118,7 @@ export class ListControlPlugin extends BasePlugin {
]
},
option: {
body: [
getSchemaTpl('optionControlV2', {
description: '设置选项后,输入时会下拉这些选项供用户参考。'
})
]
body: [getSchemaTpl('optionControlV2')]
},
status: {}
},

View File

@ -85,14 +85,13 @@ export class ImagesPlugin extends BasePlugin {
}
}
},
{
name: 'source',
type: 'input-text',
label: '关联数据',
description:
'比如:\\${listVar},用来关联作用域中的已有数据。',
getSchemaTpl('sourceBindControl', {
label: tipedLabel(
'关联数据',
'比如:\\${listVar},用来关联作用域中的已有数据'
),
visibleOn: 'this.__mode == 1'
},
}),
{
type: 'combo',
name: 'options',

View File

@ -1,4 +1,4 @@
import {Button, resolveVariable} from 'amis';
import {Button} from 'amis';
import React from 'react';
import {getI18nEnabled, registerEditorPlugin} from 'amis-editor-core';
import {
@ -13,7 +13,11 @@ import {
} from 'amis-editor-core';
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
import {diff, JSONPipeOut, repeatArray} from 'amis-editor-core';
import {schemaArrayFormat, schemaToArray} from '../util';
import {
schemaArrayFormat,
resolveArrayDatasource,
schemaToArray
} from '../util';
export class ListPlugin extends BasePlugin {
// 关联渲染器名字
@ -90,13 +94,9 @@ export class ListPlugin extends BasePlugin {
},
isCRUDBody
? null
: {
name: 'source',
type: 'input-text',
label: '数据源',
pipeIn: defaultValue('${items}'),
description: '绑定当前环境变量'
},
: getSchemaTpl('sourceBindControl', {
label: '数据源'
}),
{
name: 'placeholder',
pipeIn: defaultValue('没有数据'),
@ -192,11 +192,11 @@ export class ListPlugin extends BasePlugin {
...props.defaultData,
...props.data
};
let arr = Array.isArray(props.value)
? props.value
: typeof props.source === 'string'
? resolveVariable(props.source, data)
: resolveVariable('items', data);
const arr = resolveArrayDatasource({
value: props.value,
data,
source: props.source
});
if (!Array.isArray(arr) || !arr.length) {
const mockedData: any = this.buildMockData();

View File

@ -27,7 +27,7 @@ import {
getEventControlConfig,
getArgsWrapper
} from '../renderer/event-control/helper';
import {schemaArrayFormat, schemaToArray} from '../util';
import {schemaArrayFormat, schemaToArray, resolveArrayDatasource} from '../util';
export class TablePlugin extends BasePlugin {
// 关联渲染器名字
@ -596,11 +596,7 @@ export class TablePlugin extends BasePlugin {
};
filterProps(props: any) {
const arr = Array.isArray(props.value)
? props.value
: typeof props.source === 'string'
? resolveVariable(props.source, props.data)
: resolveVariable('items', props.data);
const arr = resolveArrayDatasource(props);
if (!Array.isArray(arr) || !arr.length) {
const mockedData: any = {};

View File

@ -1,5 +1,3 @@
import {resolveVariable} from 'amis';
import {setVariable, someTree} from 'amis-core';
import {
BasePlugin,
@ -26,6 +24,7 @@ import {
getArgsWrapper
} from '../renderer/event-control/helper';
import type {SchemaObject} from 'amis';
import {resolveArrayDatasource} from '../util';
export class Table2Plugin extends BasePlugin {
// 关联渲染器名字
@ -838,11 +837,7 @@ export class Table2Plugin extends BasePlugin {
};
filterProps(props: any) {
const arr = Array.isArray(props.value)
? props.value
: typeof props.source === 'string'
? resolveVariable(props.source, props.data)
: resolveVariable('items', props.data);
const arr = resolveArrayDatasource(props);
if (!Array.isArray(arr) || !arr.length) {
const mockedData: any = {};

View File

@ -189,13 +189,11 @@ export class TabsPlugin extends BasePlugin {
{
title: '高级',
body: [
getSchemaTpl('expressionFormulaControl', {
evalMode: true,
getSchemaTpl('sourceBindControl', {
label: tipedLabel(
'关联数据',
'根据该数据来动态重复渲染所配置的选项卡'
),
name: 'source'
)
}),
getSchemaTpl('switch', {
name: 'mountOnEnter',

View File

@ -12,7 +12,8 @@ import debounce from 'lodash/debounce';
enum MapType {
CUSTOM = 'custom',
API = 'api'
API = 'api',
VARIABLE = 'variable'
}
export interface MapSourceControlProps extends FormControlProps {
@ -38,7 +39,9 @@ export default class MapSourceControl extends React.Component<
let mapType: MapType = MapType.CUSTOM;
if (props.data.hasOwnProperty('source') && props.data.source) {
mapType = MapType.API;
mapType = /\$\{(.*?)\}/g.test(props.data.source)
? MapType.VARIABLE
: MapType.API;
}
this.state = {
@ -86,7 +89,7 @@ export default class MapSourceControl extends React.Component<
return;
}
if (mapType === MapType.API) {
if ([MapType.API, MapType.VARIABLE].includes(mapType)) {
onBulkChange &&
onBulkChange({
source,
@ -127,6 +130,10 @@ export default class MapSourceControl extends React.Component<
{
label: '外部接口',
value: MapType.API
},
{
label: '上下文变量',
value: MapType.VARIABLE
}
] as Array<{
label: string;
@ -387,12 +394,25 @@ export default class MapSourceControl extends React.Component<
render() {
const {mapType} = this.state;
const {className} = this.props;
const {className, render} = this.props;
return (
<div className={cx('ae-OptionControl', className)}>
{this.renderHeader()}
{mapType === MapType.CUSTOM ? this.renderMap() : this.renderApiPanel()}
{mapType === MapType.CUSTOM ? this.renderMap() : null}
{mapType === MapType.API ? this.renderApiPanel() : null}
{mapType === MapType.VARIABLE
? render(
'variable',
getSchemaTpl('sourceBindControl', {
label: false,
className: 'ae-ExtendMore'
}),
{
onChange: this.handleAPIChange
}
)
: null}
</div>
);
}

View File

@ -42,12 +42,14 @@ export interface OptionControlProps extends FormControlProps {
className?: string;
}
export type SourceType = 'custom' | 'api' | 'apicenter' | 'variable';
export interface OptionControlState {
options: Array<OptionControlItem>;
api: SchemaApi;
labelField: string;
valueField: string;
source: 'custom' | 'api' | 'apicenter';
source: SourceType;
}
export default class OptionControl extends React.Component<
@ -64,7 +66,7 @@ export default class OptionControl extends React.Component<
constructor(props: OptionControlProps) {
super(props);
let source: 'custom' | 'api' | 'apicenter' = 'custom';
let source: SourceType = 'custom';
if (props.data.hasOwnProperty('source') && props.data.source) {
const api = props.data.source;
@ -75,7 +77,11 @@ export default class OptionControl extends React.Component<
? api.url || ''
: '';
source = !url.indexOf('api://') ? 'apicenter' : 'api';
source = /\$\{(.*?)\}/g.test(props.data.source)
? 'variable'
: !url.indexOf('api://')
? 'apicenter'
: 'api';
}
this.state = {
@ -250,7 +256,7 @@ export default class OptionControl extends React.Component<
data.value = defaultValue;
}
if (source === 'api' || source === 'apicenter') {
if (source === 'api' || source === 'apicenter' || source === 'variable') {
const {api, labelField, valueField} = this.state;
data.source = api;
data.labelField = labelField || undefined;
@ -337,8 +343,8 @@ export default class OptionControl extends React.Component<
*
*/
@autobind
handleSourceChange(source: 'custom' | 'api' | 'apicenter') {
this.setState({source: source}, this.onChange);
handleSourceChange(source: SourceType) {
this.setState({api: '', source: source}, this.onChange);
}
/**
@ -478,14 +484,18 @@ export default class OptionControl extends React.Component<
label: '外部接口',
value: 'api'
},
...(hasApiCenter ? [{label: 'API中心', value: 'apicenter'}] : [])
...(hasApiCenter ? [{label: 'API中心', value: 'apicenter'}] : []),
{
label: '上下文变量',
value: 'variable'
}
// {
// label: '表单实体',
// value: 'form'
// }
] as Array<{
label: string;
value: 'custom' | 'api' | 'apicenter';
value: SourceType;
}>
).map(item => ({
...item,
@ -813,9 +823,6 @@ export default class OptionControl extends React.Component<
renderApiPanel() {
const {render} = this.props;
const {source, api, labelField, valueField} = this.state;
if (source === 'custom') {
return null;
}
return render(
'api',
@ -888,7 +895,22 @@ export default class OptionControl extends React.Component<
</div>
) : null}
{this.renderApiPanel()}
{source === 'api' || source === 'apicenter'
? this.renderApiPanel()
: null}
{source === 'variable'
? render(
'variable',
getSchemaTpl('sourceBindControl', {
label: false,
className: 'ae-ExtendMore'
}),
{
onChange: this.handleAPIChange
}
)
: null}
</div>
);
}

View File

@ -16,11 +16,13 @@ interface OptionControlProps extends FormControlProps {
className?: string;
}
type SourceType = 'custom' | 'api' | 'form' | 'variable';
interface OptionControlState {
api: SchemaApi;
labelField: string;
valueField: string;
source: 'custom' | 'api' | 'form';
source: SourceType;
}
function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
@ -36,7 +38,11 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
api: props.data.source,
labelField: props.data.labelField,
valueField: props.data.valueField,
source: props.data.source ? 'api' : 'custom'
source: props.data.source
? /\$\{(.*?)\}/g.test(props.data.source)
? 'variable'
: 'api'
: 'custom'
};
this.handleSourceChange = this.handleSourceChange.bind(this);
@ -60,7 +66,7 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
valueField: undefined
};
if (source === 'api') {
if (['api', 'variable'].includes(source)) {
const {api, labelField, valueField} = this.state;
data.source = api;
data.labelField = labelField || undefined;
@ -74,8 +80,8 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
/**
*
*/
handleSourceChange(source: 'custom' | 'api' | 'form') {
this.setState({source: source}, this.onChange);
handleSourceChange(source: SourceType) {
this.setState({api: '', source: source}, this.onChange);
}
handleAPIChange(source: SchemaApi) {
@ -158,10 +164,14 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
{
label: '接口获取',
value: 'api'
},
{
label: '上下文变量',
value: 'variable'
}
] as Array<{
label: string;
value: 'custom' | 'api' | 'form';
value: SourceType;
}>
).map(item => ({
...item,
@ -257,7 +267,7 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
render() {
const {source, api, labelField, valueField} = this.state;
const {className} = this.props;
const {className, render} = this.props;
const cmptProps = {
...this.props,
data: {
@ -274,7 +284,20 @@ function BaseOptionControl(Cmpt: React.JSXElementConstructor<any>) {
{source === 'custom' ? <Cmpt {...cmptProps} /> : null}
{this.renderApiPanel()}
{source === 'api' ? this.renderApiPanel() : null}
{source === 'variable'
? render(
'variable',
getSchemaTpl('sourceBindControl', {
label: false,
className: 'ae-ExtendMore'
}),
{
onChange: this.handleAPIChange
}
)
: null}
</div>
);
}

View File

@ -32,13 +32,15 @@ export interface OptionControlProps extends FormControlProps {
showIconField?: boolean; // 是否有图标字段
}
export type SourceType = 'custom' | 'api' | 'apicenter' | 'variable';
export interface OptionControlState {
options: Array<OptionControlItem>;
api: SchemaApi;
labelField: string;
valueField: string;
iconField: string;
source: 'custom' | 'api' | 'apicenter';
source: SourceType;
modalVisible: boolean;
}
@ -66,9 +68,14 @@ export default class TreeOptionControl extends React.Component<
labelField: labelField,
valueField: valueField,
iconField: showIconField ? iconField : undefined,
source: source ? 'api' : 'custom',
source: source
? /\$\{(.*?)\}/g.test(source)
? 'variable'
: 'api'
: 'custom',
modalVisible: false
};
this.sortables = [];
}
@ -105,7 +112,7 @@ export default class TreeOptionControl extends React.Component<
* options字段的统一出口
*/
onChange() {
const {source} = this.state;
const {source, api, labelField, valueField, iconField} = this.state;
const {onBulkChange} = this.props;
const data: Partial<OptionControlProps> = {
source: undefined,
@ -119,13 +126,13 @@ export default class TreeOptionControl extends React.Component<
data.options = this.pretreatOptions(options);
}
if (source === 'api' || source === 'apicenter') {
const {api, labelField, valueField, iconField} = this.state;
if (source === 'api' || source === 'apicenter' || source === 'variable') {
data.source = api;
data.labelField = labelField || undefined;
data.valueField = valueField || undefined;
data.iconField = iconField;
}
onBulkChange && onBulkChange(data);
return;
}
@ -134,8 +141,8 @@ export default class TreeOptionControl extends React.Component<
*
*/
@autobind
handleSourceChange(source: 'custom' | 'api' | 'apicenter') {
this.setState({source: source}, this.onChange);
handleSourceChange(source: SourceType) {
this.setState({api: '', source: source}, this.onChange);
}
renderHeader() {
@ -160,10 +167,14 @@ export default class TreeOptionControl extends React.Component<
label: '外部接口',
value: 'api'
},
...(hasApiCenter ? [{label: 'API中心', value: 'apicenter'}] : [])
...(hasApiCenter ? [{label: 'API中心', value: 'apicenter'}] : []),
{
label: '上下文变量',
value: 'variable'
}
] as Array<{
label: string;
value: 'custom' | 'api' | 'apicenter';
value: SourceType;
}>
).map(item => ({
...item,
@ -574,9 +585,6 @@ export default class TreeOptionControl extends React.Component<
renderApiPanel() {
const {render, showIconField = false} = this.props;
const {source, api, labelField, valueField, iconField} = this.state;
if (source === 'custom') {
return null;
}
return render(
'api',
@ -624,7 +632,7 @@ export default class TreeOptionControl extends React.Component<
render() {
const {source} = this.state;
const {className} = this.props;
const {className, render} = this.props;
return (
<div className={cx('ae-TreeOptionControl', className)}>
@ -648,7 +656,22 @@ export default class TreeOptionControl extends React.Component<
</div>
) : null}
{this.renderApiPanel()}
{source === 'api' || source === 'apicenter'
? this.renderApiPanel()
: null}
{source === 'variable'
? render(
'variable',
getSchemaTpl('sourceBindControl', {
label: false,
className: 'ae-ExtendMore'
}),
{
onChange: this.handleAPIChange
}
)
: null}
</div>
);
}

View File

@ -624,6 +624,20 @@ setSchemaTpl(
}
);
/**
*
*/
setSchemaTpl('sourceBindControl', (schema: object = {}) => ({
type: 'ae-formulaControl',
name: 'source',
label: '数据',
variableMode: 'tabs',
inputMode: 'input-group',
placeholder: '请输入表达式',
requiredDataPropsVariables: true,
...schema
}));
setSchemaTpl('menuTpl', () => {
return getSchemaTpl('textareaFormulaControl', {
mode: 'normal',

View File

@ -3,7 +3,7 @@ import {
EditorManager,
RendererPluginAction
} from 'amis-editor-core';
import {filterTree, mapTree} from 'amis';
import {filterTree, mapTree, resolveVariableAndFilter} from 'amis';
import {ACTION_TYPE_TREE} from './renderer/event-control/helper';
import {ActionConfig, ComponentInfo} from './renderer/event-control/types';
import {
@ -280,10 +280,34 @@ export const isAuto = (value: any) => {
return false;
};
/**
* filterProps value
*/
export const resolveArrayDatasource = (
{
data,
value,
source
}: {
value?: any;
data: any;
source: string;
},
defaultSource: string = '$items'
) =>
Array.isArray(value)
? value
: // resolveVariable 不支持 ${items} 格式,导致预览态无数据
resolveVariableAndFilter(
typeof source === 'string' ? source : defaultSource,
data,
'| raw'
);
export const schemaToArray = (value: any) => {
return value && Array.isArray(value)? value : [value];
};
export const schemaArrayFormat = (value: any) => {
return value && Array.isArray(value) && value.length === 1 ? value[0] : value;
};
};

View File

@ -11,7 +11,7 @@ import {ClassNamesFn} from 'amis-core';
/**
* Badge
* https://baidu.gitee.io/amis/docs/components/badge
* https://aisuda.bce.baidu.com/amis/zh-CN/components/badge
*/
export interface BadgeObject {
className?: string;

View File

@ -6,8 +6,6 @@
import React from 'react';
import moment from 'moment';
import 'moment/locale/zh-cn';
import 'moment/locale/de';
import {Icon} from './icons';
import {PopOver} from 'amis-core';
import PopUp from './PopUp';

View File

@ -1239,13 +1239,15 @@ export class DateRangePicker extends React.Component<
}
renderMonth(props: any, month: number, year: number, date: any) {
const m = moment();
const currentDate = m.year(year).month(month);
const currentDate = props.viewDate.year(year).month(month);
const {startDate, endDate} = this.state;
var localMoment = m.localeData().monthsShort(m.month(month));
var strLength = 3;
var monthStrFixedLength = localMoment.substring(0, strLength);
const {translate: __} = this.props;
const monthStr = currentDate.format(__('MMM'));
const strLength = 3;
// Because some months are up to 5 characters long, we want to
// use a fixed string length for consistency
const monthStrFixedLength = monthStr.substring(0, strLength);
if (
startDate &&
@ -1262,7 +1264,7 @@ export class DateRangePicker extends React.Component<
props.className += className;
return (
<td {...props} {...others}>
<td {...omit(props, 'viewDate')} {...others}>
<span>{monthStrFixedLength}</span>
</td>
);

View File

@ -162,6 +162,8 @@ export class Tag extends React.Component<TagProps> {
})}
style={tagStyle}
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
>
<span className={cx('Tag-text')}>
{prevIcon}

View File

@ -12,6 +12,8 @@ import {
utils
} from 'amis-core';
import {PickerOption} from '../PickerColumn';
import 'moment/locale/zh-cn';
import 'moment/locale/de';
export type DateType =
| 'year'

View File

@ -121,7 +121,8 @@ export class CustomMonthsView extends React.Component<CustomMonthsViewProps> {
props = {
'key': i,
'data-value': i,
'className': classes
'className': classes,
'viewDate': this.props.viewDate
};
if (!isDisabled)
@ -153,16 +154,16 @@ export class CustomMonthsView extends React.Component<CustomMonthsViewProps> {
year: number,
date: moment.Moment
) => {
var localMoment = this.props.viewDate;
var monthStr = localMoment
.localeData()
.monthsShort(localMoment.month(month));
var strLength = 3;
const {translate: __} = this.props;
const {viewDate: localMoment, ...rest} = props;
const monthStr = localMoment.month(month).format(__('MMM'));
const strLength = 3;
// Because some months are up to 5 characters long, we want to
// use a fixed string length for consistency
var monthStrFixedLength = monthStr.substring(0, strLength);
const monthStrFixedLength = monthStr.substring(0, strLength);
return (
<td {...props}>
<td {...rest}>
<span>{monthStrFixedLength}</span>
</td>
);

View File

@ -154,9 +154,12 @@ test('Renderer:crud loadDataOnce', async () => {
body: {
type: 'crud',
syncLocation: false,
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/sample',
api: 'https://aisuda.bce.baidu.com/amis/api/mock2/sample',
loadDataOnce: true,
autoGenerateFilter: true,
autoGenerateFilter: {
columnsNum: 4,
showBtnToolbar: false
},
filterSettingSource: ['version'],
columns: [
{
@ -240,8 +243,9 @@ test('Renderer:crud loadDataOnce', async () => {
container.querySelectorAll('.cxd-Table-tr--1th .cxd-PlainField')[4]
?.innerHTML
).toEqual('4');
expect(container.querySelector('.cxd-Crud-pager')).not.toBeInTheDocument();
expect(container).toMatchSnapshot();
// 啥意思?为何不能有分页?
// expect(container.querySelector('.cxd-Crud-pager')).not.toBeInTheDocument();
// expect(container).toMatchSnapshot();
});
test('Renderer:crud list', async () => {
@ -751,7 +755,10 @@ test('Renderer: crud autoGenerateFilter', async () => {
type: 'crud',
api: '/api/mock2/sample',
syncLocation: false,
autoGenerateFilter: true,
autoGenerateFilter: {
columnsNum: 4,
showBtnToolbar: false
},
bulkActions: [
{
label: '批量删除',

View File

@ -478,7 +478,7 @@ test('Renderer:condition-builder with custom field', async () => {
fireEvent.click(await findByText('请选择操作'));
fireEvent.click(await findByText('等于(自定义)'));
await wait(200);
await wait(400);
const colorInputs = container.querySelectorAll(
'.cxd-CBValue .cxd-ColorPicker-input'
)!;

View File

@ -304,7 +304,7 @@ test('Renderer:input-table verifty', async () => {
data: {
table: [{}]
},
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm',
api: 'https://aisuda.bce.baidu.com/amis/api/mock2/form/saveForm',
body: [
{
type: 'input-table',
@ -381,7 +381,7 @@ test('Renderer:input-table cell selects delete', async () => {
}
]
},
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm',
api: 'https://aisuda.bce.baidu.com/amis/api/mock2/form/saveForm',
body: [
{
type: 'input-table',

View File

@ -14,7 +14,7 @@ test('Renderer:portlet', () => {
label: '固定操作',
type: 'button',
actionType: 'ajax',
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm'
api: 'https://aisuda.bce.baidu.com/amis/api/mock2/form/saveForm'
}
],
tabs: [
@ -26,7 +26,7 @@ test('Renderer:portlet', () => {
label: 'ajax请求',
type: 'button',
actionType: 'ajax',
api: 'https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm'
api: 'https://aisuda.bce.baidu.com/amis/api/mock2/form/saveForm'
},
{
type: 'dropdown-button',

View File

@ -640,7 +640,7 @@ export type SchemaRedirect = string;
* 2. `<%= data.xxx %>`
*
*
* https://baidu.gitee.io/amis/docs/concepts/template
* https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/template
*/
export type SchemaTpl = string;
@ -851,7 +851,7 @@ export interface ToastSchemaBase extends BaseSchema {
/**
* Form
*
* https://baidu.gitee.io/amis/docs/components/form/index
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/index
*/
export interface FormSchema extends FormSchemaBase, BaseSchema {
/**

View File

@ -232,7 +232,7 @@ export interface DialogActionSchema extends ButtonSchema {
/**
*
* https://baidu.gitee.io/amis/docs/components/dialog
* https://aisuda.bce.baidu.com/amis/zh-CN/components/dialog
*/
dialog: DialogSchemaBase;
@ -252,7 +252,7 @@ export interface DrawerActionSchema extends ButtonSchema {
/**
*
* https://baidu.gitee.io/amis/docs/components/drawer
* https://aisuda.bce.baidu.com/amis/zh-CN/components/drawer
*/
drawer: DrawerSchemaBase;
@ -272,7 +272,7 @@ export interface ToastActionSchema extends ButtonSchema {
/**
*
* https://baidu.gitee.io/amis/docs/components/toast
* https://aisuda.bce.baidu.com/amis/zh-CN/components/toast
*/
toast: ToastSchemaBase;
}
@ -365,7 +365,7 @@ export interface VanillaAction extends ButtonSchema {
/**
*
* https://baidu.gitee.io/amis/docs/components/action
* https://aisuda.bce.baidu.com/amis/zh-CN/components/action
*/
export type ActionSchema =
| AjaxActionSchema

View File

@ -12,7 +12,7 @@ import type {AlertProps} from 'amis-ui/lib/components/Alert2';
/**
* Alert
* https://baidu.gitee.io/amis/docs/components/alert
* https://aisuda.bce.baidu.com/amis/zh-CN/components/alert
*/
export interface AlertSchema extends BaseSchema {
/**

View File

@ -8,7 +8,7 @@ import {BaseSchema, SchemaClassName, SchemaCollection} from '../Schema';
/**
* AnchorNavSection
* https://baidu.gitee.io/amis/docs/components/anchor-nav
* https://aisuda.bce.baidu.com/amis/zh-CN/components/anchor-nav
*/
export type AnchorNavSectionSchema = {
@ -30,7 +30,7 @@ export type AnchorNavSectionSchema = {
/**
* AnchorNav
* https://baidu.gitee.io/amis/docs/components/anchor-nav
* https://aisuda.bce.baidu.com/amis/zh-CN/components/anchor-nav
*/
export interface AnchorNavSchema extends BaseSchema {
/**
@ -162,22 +162,24 @@ export default class AnchorNav extends React.Component<
links = Array.isArray(links) ? links : [links];
let children: Array<JSX.Element | null> = [];
children = links.map((section, index) =>
isVisible(section, data) ? (
<AnchorNavSection
{...(section as any)}
title={filter(section.title, data)}
key={index}
name={section.href || index}
>
{this.renderSection
? this.renderSection(section, this.props, index)
: sectionRender
? sectionRender(section, this.props, index)
: render(`section/${index}`, section.body || '')}
</AnchorNavSection>
) : null
).filter(item => !!item);
children = links
.map((section, index) =>
isVisible(section, data) ? (
<AnchorNavSection
{...(section as any)}
title={filter(section.title, data)}
key={index}
name={section.href || index}
>
{this.renderSection
? this.renderSection(section, this.props, index)
: sectionRender
? sectionRender(section, this.props, index)
: render(`section/${index}`, section.body || '')}
</AnchorNavSection>
) : null
)
.filter(item => !!item);
return (
<CAnchorNav

View File

@ -81,7 +81,7 @@ export interface AppPage extends SpinnerExtraProps {
/**
* App JSSDK
* https://baidu.gitee.io/amis/docs/components/app
* https://aisuda.bce.baidu.com/amis/zh-CN/components/app
*/
export interface AppSchema extends BaseSchema, SpinnerExtraProps {
/**

View File

@ -9,7 +9,7 @@ import {BaseSchema, SchemaUrlPath} from '../Schema';
/**
* Audio
* https://baidu.gitee.io/amis/docs/components/audio
* https://aisuda.bce.baidu.com/amis/zh-CN/components/audio
*/
export interface AudioSchema extends BaseSchema {
/**
@ -300,7 +300,9 @@ export class Audio extends React.Component<AudioProps, AudioState> {
const date = new Date(seconds * 1000);
const hh = date.getUTCHours();
const mm = isNaN(date.getUTCMinutes()) ? 0 : date.getUTCMinutes();
const ss = isNaN(date.getUTCSeconds()) ? '00': this.pad(date.getUTCSeconds());
const ss = isNaN(date.getUTCSeconds())
? '00'
: this.pad(date.getUTCSeconds());
if (hh) {
return `${hh}:${this.pad(mm)}:${ss}`;
}
@ -460,7 +462,10 @@ export class Audio extends React.Component<AudioProps, AudioState> {
const {muted, src} = this.state;
return (
<div className={cx('Audio', className, inline ? 'Audio--inline' : '')} style={style}>
<div
className={cx('Audio', className, inline ? 'Audio--inline' : '')}
style={style}
>
<audio
className={cx('Audio-original')}
ref={this.audioRef}

View File

@ -9,7 +9,7 @@ const BarCode = React.lazy(() => import('amis-ui/lib/components/BarCode'));
/**
* BarCode
* https://baidu.gitee.io/amis/docs/components/barcode
* https://aisuda.bce.baidu.com/amis/zh-CN/components/barcode
*/
export interface BarCodeSchema extends BaseSchema {
/**
@ -39,12 +39,23 @@ export interface BarCodeProps
export class BarCodeField extends React.Component<BarCodeProps, object> {
render() {
const {className, style, width, height, classnames: cx, options} = this.props;
const {
className,
style,
width,
height,
classnames: cx,
options
} = this.props;
const value = getPropValue(this.props);
return (
<Suspense fallback={<div>...</div>}>
<div data-testid="barcode" className={cx('BarCode', className)} style={style}>
<div
data-testid="barcode"
className={cx('BarCode', className)}
style={style}
>
<BarCode value={value} options={options}></BarCode>
</div>
</Suspense>

View File

@ -53,7 +53,7 @@ export type ItemPlace = 'start' | 'middle' | 'end';
/**
* Breadcrumb
* https://baidu.gitee.io/amis/docs/components/breadcrumb
* https://aisuda.bce.baidu.com/amis/zh-CN/components/breadcrumb
*/
export interface BreadcrumbSchema extends BaseSchema {

View File

@ -6,7 +6,7 @@ import {ActionSchema} from './Action';
/**
* Button Group
* https://baidu.gitee.io/amis/docs/components/button-group
* https://aisuda.bce.baidu.com/amis/zh-CN/components/button-group
*/
export interface ButtonGroupSchema extends BaseSchema {
/**

View File

@ -77,6 +77,21 @@ export type CRUDToolbarObject = {
align?: 'left' | 'right';
};
export type AutoGenerateFilterObject = {
/**
*
*/
columnsNum?: number;
/**
*
*/
showBtnToolbar?: boolean;
/**
* /
*/
// showExpand?: boolean;
};
export type CRUDRendererEvent = TableRendererEvent | CardsRendererEvent;
export interface CRUDCommonSchema extends BaseSchema, SpinnerExtraProps {
@ -303,7 +318,7 @@ export interface CRUDCommonSchema extends BaseSchema, SpinnerExtraProps {
/**
* searchable属性值
*/
autoGenerateFilter?: boolean;
autoGenerateFilter?: AutoGenerateFilterObject | boolean;
/**
*
@ -325,7 +340,7 @@ export type CRUDTableSchema = CRUDCommonSchema & {
/**
* CRUD
* https://baidu.gitee.io/amis/docs/components/crud
* https://aisuda.bce.baidu.com/amis/zh-CN/components/crud
*/
export type CRUDSchema = CRUDCardsSchema | CRUDListSchema | CRUDTableSchema;

View File

@ -59,7 +59,7 @@ export type CardBodyField = SchemaObject & {
/**
* Card
* https://baidu.gitee.io/amis/docs/components/card
* https://aisuda.bce.baidu.com/amis/zh-CN/components/card
*/
export interface CardSchema extends BaseSchema {
/**

View File

@ -7,7 +7,7 @@ import {buildStyle} from 'amis-core';
/**
* Card2
* https://baidu.gitee.io/amis/docs/components/card2
* https://aisuda.bce.baidu.com/amis/zh-CN/components/card2
*/
export interface Card2Schema extends BaseSchema {
/**

View File

@ -31,7 +31,7 @@ import type {IItem} from 'amis-core';
/**
* Cards
* https://baidu.gitee.io/amis/docs/components/card
* https://aisuda.bce.baidu.com/amis/zh-CN/components/card
*/
export interface CardsSchema extends BaseSchema, SpinnerExtraProps {
/**

View File

@ -23,7 +23,7 @@ import {ScopedContext, IScopedContext} from 'amis-core';
/**
* Carousel
* https://baidu.gitee.io/amis/docs/components/carousel
* https://aisuda.bce.baidu.com/amis/zh-CN/components/carousel
*/
export interface CarouselSchema extends BaseSchema {
/**

View File

@ -51,7 +51,7 @@ const DEFAULT_EVENT_PARAMS = [
/**
* Chart
* https://baidu.gitee.io/amis/docs/components/carousel
* https://aisuda.bce.baidu.com/amis/zh-CN/components/carousel
*/
export interface ChartSchema extends BaseSchema {
/**

View File

@ -71,7 +71,7 @@ export interface CustomLang {
/**
*
* https://baidu.gitee.io/amis/docs/components/code
* https://aisuda.bce.baidu.com/amis/zh-CN/components/code
*/
export interface CodeSchema extends BaseSchema {
type: 'code';

View File

@ -10,7 +10,7 @@ import {BaseSchema, SchemaCollection, SchemaTpl, SchemaObject} from '../Schema';
/**
* Collapse
* https://baidu.gitee.io/amis/docs/components/collapse
* https://aisuda.bce.baidu.com/amis/zh-CN/components/collapse
*/
export interface CollapseSchema extends BaseSchema {
/**

View File

@ -5,7 +5,7 @@ import {CollapseGroup} from 'amis-ui';
/**
* CollapseGroup
* https://baidu.gitee.io/amis/docs/components/collapse
* https://aisuda.bce.baidu.com/amis/zh-CN/components/collapse
*/
export interface CollapseGroupSchema extends BaseSchema {
/**

View File

@ -8,7 +8,7 @@ import {getPropValue} from 'amis-core';
/**
* Color
* https://baidu.gitee.io/amis/docs/components/color
* https://aisuda.bce.baidu.com/amis/zh-CN/components/color
*/
export interface ColorSchema extends BaseSchema {
/**
@ -39,7 +39,13 @@ export class ColorField extends React.Component<ColorProps, object> {
};
render() {
const {className, style, classnames: cx, defaultColor, showValue} = this.props;
const {
className,
style,
classnames: cx,
defaultColor,
showValue
} = this.props;
const color = getPropValue(this.props);
return (
@ -49,7 +55,9 @@ export class ColorField extends React.Component<ColorProps, object> {
style={{backgroundColor: color || defaultColor}}
/>
{showValue ? (
<span className={cx('ColorField-value')}>{color || defaultColor}</span>
<span className={cx('ColorField-value')}>
{color || defaultColor}
</span>
) : null}
</div>
);

View File

@ -62,7 +62,7 @@ export interface ContainerDraggableConfig {
/**
* Container
* https://baidu.gitee.io/amis/docs/components/container
* https://aisuda.bce.baidu.com/amis/zh-CN/components/container
*/
export interface ContainerSchema extends BaseSchema {
/**

View File

@ -6,7 +6,7 @@ import {getPropValue} from 'amis-core';
/**
* Date
* https://baidu.gitee.io/amis/docs/components/date
* https://aisuda.bce.baidu.com/amis/zh-CN/components/date
*/
export interface DateSchema extends BaseSchema {
/**

View File

@ -29,7 +29,7 @@ import {isAlive} from 'mobx-state-tree';
/**
* Dialog
* https://baidu.gitee.io/amis/docs/components/dialog
* https://aisuda.bce.baidu.com/amis/zh-CN/components/dialog
*/
export interface DialogSchema extends BaseSchema {
type: 'dialog';
@ -829,7 +829,11 @@ export class DialogRenderer extends Dialog {
// clear error
store.updateMessage();
onClose();
action.close && this.closeTarget(action.close);
if (action.close) {
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
} else if (action.actionType === 'confirm') {
const rendererEvent = await dispatchEvent(
'confirm',
@ -880,7 +884,9 @@ export class DialogRenderer extends Dialog {
action.target && scoped.reload(action.target, data);
if (action.close || action.type === 'submit') {
this.handleSelfClose(undefined, action.type === 'submit');
this.closeTarget(action.close);
action.close &&
typeof action.close === 'string' &&
this.closeTarget(action.close);
}
} else if (this.tryChildrenToHandle(action, data)) {
// do nothing
@ -902,8 +908,9 @@ export class DialogRenderer extends Dialog {
action.reload &&
this.reloadTarget(filter(action.reload, store.data), store.data);
if (action.close) {
this.handleSelfClose();
this.closeTarget(action.close);
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
})
.catch(e => {
@ -912,7 +919,7 @@ export class DialogRenderer extends Dialog {
}
});
} else if (onAction) {
let ret = onAction(
await onAction(
e,
{
...action,
@ -922,10 +929,12 @@ export class DialogRenderer extends Dialog {
throwErrors,
delegate || this.context
);
action.close &&
(ret && ret.then
? ret.then(this.handleSelfClose)
: setTimeout(this.handleSelfClose, 200));
if (action.close) {
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
}
}

View File

@ -4,7 +4,7 @@ import {BaseSchema} from '../Schema';
/**
* Divider 线
* https://baidu.gitee.io/amis/docs/components/divider
* https://aisuda.bce.baidu.com/amis/zh-CN/components/divider
*/
export interface DividerSchema extends BaseSchema {
type: 'divider';

View File

@ -27,7 +27,7 @@ import {isAlive} from 'mobx-state-tree';
/**
* Drawer
* https://baidu.gitee.io/amis/docs/components/drawer
* https://aisuda.bce.baidu.com/amis/zh-CN/components/drawer
*/
export interface DrawerSchema extends BaseSchema {
type: 'drawer';
@ -811,7 +811,11 @@ export class DrawerRenderer extends Drawer {
}
store.setCurrentAction(action);
onClose();
action.close && this.closeTarget(action.close);
if (action.close) {
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
} else if (action.actionType === 'confirm') {
const rendererEvent = await dispatchEvent(
'confirm',
@ -831,9 +835,11 @@ export class DrawerRenderer extends Drawer {
} else if (action.actionType === 'reload') {
store.setCurrentAction(action);
action.target && scoped.reload(action.target, data);
if (action.close) {
this.handleSelfClose();
this.closeTarget(action.close);
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
} else if (this.tryChildrenToHandle(action, data)) {
// do nothing
@ -854,9 +860,11 @@ export class DrawerRenderer extends Drawer {
redirect && env.jumpTo(redirect, action);
action.reload &&
this.reloadTarget(filter(action.reload, store.data), store.data);
if (action.close) {
this.handleSelfClose();
this.closeTarget(action.close);
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
})
.catch(e => {
@ -865,17 +873,13 @@ export class DrawerRenderer extends Drawer {
}
});
} else if (onAction) {
let ret = onAction(
e,
action,
data,
throwErrors,
delegate || this.context
);
action.close &&
(ret && ret.then
? ret.then(this.handleSelfClose)
: setTimeout(this.handleSelfClose, 200));
await onAction(e, action, data, throwErrors, delegate || this.context);
if (action.close) {
action.close === true
? this.handleSelfClose()
: this.closeTarget(action.close);
}
}
}

View File

@ -23,7 +23,7 @@ export type DropdownButton =
/**
*
* https://baidu.gitee.io/amis/docs/components/dropdown-button
* https://aisuda.bce.baidu.com/amis/zh-CN/components/dropdown-button
*/
export interface DropdownButtonSchema extends BaseSchema {
/**

View File

@ -7,7 +7,7 @@ import {BaseSchema, SchemaCollection} from '../Schema';
/**
* Each
* https://baidu.gitee.io/amis/docs/components/each
* https://aisuda.bce.baidu.com/amis/zh-CN/components/each
*/
export interface EachSchema extends BaseSchema {
/**

View File

@ -9,7 +9,7 @@ import {BaseSchema, SchemaCollection, SchemaObject} from '../Schema';
/**
* Flex
* https://baidu.gitee.io/amis/docs/components/flex
* https://aisuda.bce.baidu.com/amis/zh-CN/components/flex
*/
export interface FlexSchema extends BaseSchema {
/**

View File

@ -13,7 +13,7 @@ import {supportStatic} from './StaticHoc';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/button-group
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/button-group
*/
export interface ButtonGroupControlSchema
extends Omit<ButtonGroupSchema, 'type'>,

View File

@ -5,7 +5,7 @@ import {FormControlProps, FormItem} from 'amis-core';
/**
* Button Toolar
* https://baidu.gitee.io/amis/docs/components/button-toolbar
* https://aisuda.bce.baidu.com/amis/zh-CN/components/button-toolbar
*/
export interface ButtonToolbarSchema extends BaseSchema {
/**

View File

@ -19,7 +19,7 @@ import {isEmpty} from 'lodash';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/chained-select
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/chained-select
*/
export interface ChainedSelectControlSchema extends FormOptionsSchema {
type: 'chained-select';

View File

@ -10,7 +10,7 @@ import {supportStatic} from './StaticHoc';
/**
* Radio
* https://baidu.gitee.io/amis/docs/components/form/chart-radios
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/chart-radios
*/
export interface ChartRadiosControlSchema extends FormOptionsSchema {
type: 'chart-radios';
@ -111,10 +111,13 @@ export default class ChartRadiosControl extends React.Component<
} = this.props;
if (options.length && selectedOptions.length) {
const count = options.reduce((all, cur) => {
return all + cur[chartValueField || valueField]
return all + cur[chartValueField || valueField];
}, 0);
if (count > 0) {
const percent = (+selectedOptions[0][chartValueField || valueField] / count * 100).toFixed(2);
const percent = (
(+selectedOptions[0][chartValueField || valueField] / count) *
100
).toFixed(2);
displayValue = `${selectedOptions[0][labelField]}${percent}%`;
}
}

View File

@ -19,7 +19,7 @@ export interface SchemaMap {
/**
* Checkbox
* https://baidu.gitee.io/amis/docs/components/form/checkbox
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/checkbox
*/
export interface CheckboxControlSchema extends FormBaseControlSchema {
/**

View File

@ -15,7 +15,7 @@ import {supportStatic} from './StaticHoc';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/checkboxes
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/checkboxes
*/
export interface CheckboxesControlSchema extends FormOptionsSchema {
type: 'checkboxes';

View File

@ -69,7 +69,7 @@ export type ComboSubControl = SchemaObject & {
/**
* Combo
* https://baidu.gitee.io/amis/docs/components/form/combo
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/combo
*/
export interface ComboControlSchema extends FormBaseControlSchema {
/**

View File

@ -27,7 +27,7 @@ import {IconSchema} from '../Icon';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/condition-builder
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/condition-builder
*/
export interface ConditionBuilderControlSchema extends FormBaseControlSchema {
/**

View File

@ -7,7 +7,7 @@ import {FormBaseControl, FormItemWrap} from 'amis-core';
/**
* Group
* https://baidu.gitee.io/amis/docs/components/form/group
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/group
*/
export interface FormControlSchema extends FormBaseControlSchema {
type: 'control';

View File

@ -15,7 +15,7 @@ import type {ListenerAction} from 'amis-core';
/**
* Diff
* https://baidu.gitee.io/amis/docs/components/form/diff
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/diff
*/
export interface DiffControlSchema extends FormBaseControlSchema {
/**

View File

@ -15,7 +15,7 @@ import type {ListenerAction} from 'amis-core';
/**
* Editor
* https://baidu.gitee.io/amis/docs/components/form/editor
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/editor
*/
export interface EditorControlSchema extends Omit<FormBaseControl, 'size'> {
type:
@ -247,7 +247,7 @@ export default class EditorControl extends React.Component<EditorProps, any> {
if (this.props.editorDidMount) {
let editorDidMount = this.props.editorDidMount;
if (typeof editorDidMount === 'string') {
editorDidMount = new Function('editor', 'monaco');
editorDidMount = new Function('editor', 'monaco', editorDidMount);
}
const dispose = editorDidMount(editor, monaco);
if (typeof dispose === 'function') {

View File

@ -7,7 +7,7 @@ import type {FormHorizontal} from 'amis-core';
/**
* FieldSet
* https://baidu.gitee.io/amis/docs/components/form/fieldset
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/fieldset
*/
export interface FieldSetControlSchema
extends Omit<FormBaseControl, 'size'>,

View File

@ -6,7 +6,7 @@ import {FormBaseControlSchema} from '../../Schema';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/formula
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formula
*/
export interface FormulaControlSchema extends FormBaseControlSchema {
/**

View File

@ -29,7 +29,7 @@ export type GroupSubControl = SchemaObject & {
/**
* Group
* https://baidu.gitee.io/amis/docs/components/form/group
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/group
*/
export interface GroupControlSchema extends FormBaseControlSchema {
type: 'group';

View File

@ -4,7 +4,7 @@ import {FormBaseControlSchema} from '../../Schema';
/**
* Hidden
* https://baidu.gitee.io/amis/docs/components/form/hidden
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/hidden
*/
export interface HiddenControlSchema extends FormBaseControlSchema {
type: 'hidden';

View File

@ -12,7 +12,7 @@ import {FormBaseControlSchema} from '../../Schema';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/icon-picker
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/icon-picker
*/
export interface IconPickerControlSchema extends FormBaseControlSchema {
type: 'icon-picker';
@ -281,9 +281,7 @@ export default class IconPickerControl extends React.PureComponent<
{!value || (inputValue && isOpen) ? null : (
<div className={cx('IconPickerControl-value')}>
<i className={cx(value)} />
{
typeof value === 'string' ? value : ''
}
{typeof value === 'string' ? value : ''}
</div>
)}

View File

@ -6,7 +6,7 @@ import {SchemaCollection} from '../../Schema';
/**
* InputArray combo
* https://baidu.gitee.io/amis/docs/components/form/array
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/array
*/
export interface ArrayControlSchema
extends Omit<

View File

@ -18,7 +18,7 @@ import {supportStatic} from './StaticHoc';
/**
* City
* https://baidu.gitee.io/amis/docs/components/form/city
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/city
*/
export interface InputCityControlSchema
extends FormBaseControlSchema,

View File

@ -14,7 +14,7 @@ export const ColorPicker = React.lazy(
/**
* Color
* https://baidu.gitee.io/amis/docs/components/form/color
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/color
*/
export interface InputColorControlSchema extends FormBaseControlSchema {
/**

View File

@ -8,8 +8,6 @@ import {
import cx from 'classnames';
import {filterDate, isPureVariable, resolveVariableAndFilter} from 'amis-core';
import moment from 'moment';
import 'moment/locale/zh-cn';
import 'moment/locale/de';
import {DatePicker} from 'amis-ui';
import {FormBaseControlSchema, SchemaObject} from '../../Schema';
import {createObject, anyChanged, isMobile, autobind} from 'amis-core';
@ -61,7 +59,7 @@ export interface InputDateBaseControlSchema extends FormBaseControlSchema {
/**
* Date日期选择控件
* https://baidu.gitee.io/amis/docs/components/form/date
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/date
*/
export interface DateControlSchema extends InputDateBaseControlSchema {
/**
@ -99,7 +97,7 @@ export interface DateControlSchema extends InputDateBaseControlSchema {
/**
* Datetime日期时间选择控件
* https://baidu.gitee.io/amis/docs/components/form/datetime
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/datetime
*/
export interface DateTimeControlSchema extends InputDateBaseControlSchema {
/**
@ -144,7 +142,7 @@ export interface DateTimeControlSchema extends InputDateBaseControlSchema {
/**
* Time
* https://baidu.gitee.io/amis/docs/components/form/time
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/time
*/
export interface TimeControlSchema extends InputDateBaseControlSchema {
/**
@ -179,7 +177,7 @@ export interface TimeControlSchema extends InputDateBaseControlSchema {
/**
* Month
* https://baidu.gitee.io/amis/docs/components/form/Month
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/Month
*/
export interface MonthControlSchema extends InputDateBaseControlSchema {
/**

View File

@ -7,8 +7,6 @@ import {
} from 'amis-core';
import cx from 'classnames';
import {filterDate, parseDuration} from 'amis-core';
import 'moment/locale/zh-cn';
import 'moment/locale/de';
import {DateRangePicker} from 'amis-ui';
import {isMobile, createObject, autobind} from 'amis-core';
import {ActionObject} from 'amis-core';
@ -18,7 +16,7 @@ import {supportStatic} from './StaticHoc';
/**
* DateRange
* https://baidu.gitee.io/amis/docs/components/form/date-range
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/date-range
*/
export interface DateRangeControlSchema extends FormBaseControlSchema {
/**

View File

@ -7,7 +7,7 @@ import type {CellValue, CellRichTextValue} from 'exceljs';
/**
* Excel
* https://baidu.gitee.io/amis/docs/components/form/input-excel
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-excel
*/
export interface InputExcelControlSchema extends FormBaseControlSchema {
/**

View File

@ -32,7 +32,7 @@ import omit from 'lodash/omit';
/**
* File
* https://baidu.gitee.io/amis/docs/components/form/file
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/file
*/
export interface FileControlSchema extends FormBaseControlSchema {
/**

View File

@ -12,7 +12,7 @@ import {FormBaseControlSchema, SchemaCollection} from '../../Schema';
/**
* InputGroup
* https://baidu.gitee.io/amis/docs/components/form/input-group
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-group
*/
export interface InputGroupControlSchema extends FormBaseControlSchema {
type: 'input-group';

View File

@ -37,7 +37,7 @@ import {TplSchema} from '../Tpl';
/**
* Image
* https://baidu.gitee.io/amis/docs/components/form/image
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/image
*/
export interface ImageControlSchema extends FormBaseControlSchema {
/**

View File

@ -8,7 +8,7 @@ import {supportStatic} from './StaticHoc';
/**
* MonthRange
* https://baidu.gitee.io/amis/docs/components/form/month-range
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/month-range
*/
export interface MonthRangeControlSchema

View File

@ -23,7 +23,7 @@ import {supportStatic} from './StaticHoc';
/**
*
* https://baidu.gitee.io/amis/docs/components/form/number
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/number
*/
export interface NumberControlSchema extends FormBaseControlSchema {
type: 'input-number';

View File

@ -7,7 +7,7 @@ import {DateRangePicker} from 'amis-ui';
import {supportStatic} from './StaticHoc';
/**
* QuarterRange
* https://baidu.gitee.io/amis/docs/components/form/input-quarter-range
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-quarter-range
*/
export interface QuarterRangeControlSchema
extends Omit<DateRangeControlSchema, 'type'> {

View File

@ -19,7 +19,7 @@ import {supportStatic} from './StaticHoc';
/**
* Range
* https://baidu.gitee.io/amis/docs/components/form/range
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/range
*/
export type Value = string | MultipleValue | number | [number, number];

View File

@ -14,7 +14,7 @@ import {supportStatic} from './StaticHoc';
/**
* Rating
* https://baidu.gitee.io/amis/docs/components/form/rating
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/rating
*/
export interface RatingControlSchema extends FormBaseControlSchema {
type: 'input-rating';

View File

@ -11,7 +11,7 @@ import {FormItem, FormControlProps, FormBaseControl} from 'amis-core';
/**
* Repeat
* https://baidu.gitee.io/amis/docs/components/form/repeat
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/repeat
*/
export interface RepeatControlSchema extends FormBaseControlSchema {
type: 'input-repeat';

View File

@ -15,7 +15,7 @@ import type {FormBaseControlSchema, SchemaApi} from '../../Schema';
/**
* RichText
* https://baidu.gitee.io/amis/docs/components/form/input-rich-text
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-rich-text
*/
export interface RichTextControlSchema extends FormBaseControlSchema {
type: 'input-rich-text';

View File

@ -11,7 +11,7 @@ import {findDOMNode} from 'react-dom';
/**
* SubForm
* https://baidu.gitee.io/amis/docs/components/form/subform
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/subform
*/
export interface SubFormControlSchema extends FormBaseControlSchema {
/**

View File

@ -23,7 +23,7 @@ import {TooltipWrapperSchema} from '../TooltipWrapper';
/**
* Tag
* https://baidu.gitee.io/amis/docs/components/form/tag
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/tag
*/
export interface TagControlSchema extends FormOptionsSchema {
type: 'input-tag';

View File

@ -31,7 +31,7 @@ import type {ListenerAction} from 'amis-core';
/**
* Text
* https://baidu.gitee.io/amis/docs/components/form/text
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/text
*/
export interface TextControlSchema extends FormOptionsSchema {
type:

View File

@ -23,7 +23,7 @@ import type {ItemRenderStates} from 'amis-ui/lib/components/Selection';
/**
* Tree
* https://baidu.gitee.io/amis/docs/components/form/tree
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/tree
*/
export interface TreeControlSchema extends FormOptionsSchema {
type: 'input-tree';

View File

@ -8,7 +8,7 @@ import {supportStatic} from './StaticHoc';
/**
* YearRange
* https://baidu.gitee.io/amis/docs/components/form/input-year-range
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/input-year-range
*/
export interface YearRangeControlSchema
extends Omit<DateRangeControlSchema, 'type'> {

View File

@ -6,7 +6,7 @@ import {FormBaseControlSchema} from '../../Schema';
/**
* JSON Schema
* https://baidu.gitee.io/amis/docs/components/form/json-schema
* https://aisuda.bce.baidu.com/amis/zh-CN/components/form/json-schema
*/
export interface JSONSchemaControlSchema extends FormBaseControlSchema {
/**

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