amis 1.5.4 → 1.5.6-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Root.js +1 -1
- package/lib/Root.js.map +2 -2
- package/lib/RootRenderer.d.ts +1 -1
- package/lib/RootRenderer.js +4 -3
- package/lib/RootRenderer.js.map +2 -2
- package/lib/Schema.d.ts +1 -1
- package/lib/Schema.js.map +1 -1
- package/lib/SchemaRenderer.js +4 -4
- package/lib/SchemaRenderer.js.map +2 -2
- package/lib/components/AsideNav.d.ts +1 -1
- package/lib/components/AsideNav.js.map +1 -1
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/CodeMirror.d.ts +26 -0
- package/lib/components/CodeMirror.js +104 -0
- package/lib/components/CodeMirror.js.map +13 -0
- package/lib/components/Collapse.d.ts +22 -21
- package/lib/components/Collapse.js +4 -6
- package/lib/components/Collapse.js.map +2 -2
- package/lib/components/CollapseGroup.d.ts +20 -20
- package/lib/components/CollapseGroup.js +5 -3
- package/lib/components/CollapseGroup.js.map +2 -2
- package/lib/components/ColorPicker.d.ts +85 -84
- package/lib/components/ColorPicker.js +15 -3
- package/lib/components/ColorPicker.js.map +2 -2
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DatePicker.js +7 -3
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/DateRangePicker.d.ts +85 -84
- package/lib/components/DateRangePicker.js +5 -3
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/LocationPicker.d.ts +84 -84
- package/lib/components/MonthRangePicker.d.ts +85 -84
- package/lib/components/MonthRangePicker.js +5 -3
- package/lib/components/MonthRangePicker.js.map +2 -2
- package/lib/components/PickerContainer.d.ts +2 -1
- package/lib/components/PickerContainer.js +3 -3
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/PopUp.d.ts +93 -0
- package/lib/components/PopUp.js +58 -0
- package/lib/components/PopUp.js.map +13 -0
- package/lib/components/Progress.js +1 -1
- package/lib/components/Progress.js.map +2 -2
- package/lib/components/Select.d.ts +237 -237
- package/lib/components/Steps.d.ts +1 -0
- package/lib/components/Steps.js +5 -3
- package/lib/components/Steps.js.map +2 -2
- package/lib/components/Tabs.d.ts +20 -20
- package/lib/components/TabsTransferPicker.js +1 -1
- package/lib/components/TabsTransferPicker.js.map +2 -2
- package/lib/components/TransferPicker.d.ts +0 -1
- package/lib/components/TransferPicker.js +2 -15
- package/lib/components/TransferPicker.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +560 -0
- package/lib/components/formula/Editor.js +186 -0
- package/lib/components/formula/Editor.js.map +13 -0
- package/lib/components/formula/FuncList.d.ts +67 -0
- package/lib/components/formula/FuncList.js +35 -0
- package/lib/components/formula/FuncList.js.map +13 -0
- package/lib/components/formula/Picker.d.ts +493 -0
- package/lib/components/formula/Picker.js +48 -0
- package/lib/components/formula/Picker.js.map +13 -0
- package/lib/components/formula/VariableList.d.ts +9 -0
- package/lib/components/formula/VariableList.js +15 -0
- package/lib/components/formula/VariableList.js.map +13 -0
- package/lib/components/formula/plugin.d.ts +18 -0
- package/lib/components/formula/plugin.js +136 -0
- package/lib/components/formula/plugin.js.map +13 -0
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +4 -2
- package/lib/components/index.js.map +2 -2
- package/lib/helper.css +57 -57
- package/lib/helper.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/renderers/CRUD.d.ts +1 -1
- package/lib/renderers/CRUD.js +4 -3
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Collapse.js +8 -2
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/CollapseGroup.js.map +2 -2
- package/lib/renderers/Dialog.d.ts +2 -2
- package/lib/renderers/Dialog.js +7 -7
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Drawer.js +2 -2
- package/lib/renderers/Drawer.js.map +2 -2
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputColor.d.ts +84 -84
- package/lib/renderers/Form/InputColor.js +2 -2
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputDate.js +2 -2
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +2 -2
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +1 -1
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputFormula.d.ts +35 -0
- package/lib/renderers/Form/InputFormula.js +25 -0
- package/lib/renderers/Form/InputFormula.js.map +13 -0
- package/lib/renderers/Form/InputImage.js +1 -1
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +2 -2
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputQuarterRange.js +2 -2
- package/lib/renderers/Form/InputQuarterRange.js.map +2 -2
- package/lib/renderers/Form/InputYearRange.js +2 -2
- package/lib/renderers/Form/InputYearRange.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +1 -1
- package/lib/renderers/Form/Item.js +4 -3
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +1 -0
- package/lib/renderers/Form/TreeSelect.js +11 -8
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +1 -1
- package/lib/renderers/Form/index.js +3 -2
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Page.d.ts +3 -3
- package/lib/renderers/Page.js +4 -3
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Steps.js +2 -2
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Wizard.d.ts +1 -1
- package/lib/renderers/Wizard.js +93 -36
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/formItem.js +11 -1
- package/lib/store/formItem.js.map +2 -2
- package/lib/themes/ang-ie11.css +261 -0
- package/lib/themes/ang.css +261 -0
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +261 -0
- package/lib/themes/antd.css +261 -0
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +261 -0
- package/lib/themes/cxd.css +261 -0
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +261 -0
- package/lib/themes/dark.css +261 -0
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +261 -0
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +2 -2
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/helper.js +2 -7
- package/lib/utils/helper.js.map +2 -2
- package/package.json +5 -3
- package/scss/_variables.scss +1 -1
- package/scss/components/_formula.scss +122 -0
- package/scss/components/_popup.scss +123 -0
- package/scss/components/_steps.scss +60 -0
- package/scss/components/form/_color.scss +4 -0
- package/scss/components/form/_date-range.scss +4 -0
- package/scss/components/form/_date.scss +3 -0
- package/scss/components/form/_tree-select.scss +4 -0
- package/scss/helper/background/_background-color.scss +1 -1
- package/scss/helper/border/_border-color.scss +1 -1
- package/scss/helper/typography/_text-color.scss +1 -1
- package/scss/themes/_common.scss +2 -0
- package/sdk/ang-ie11.css +875 -0
- package/sdk/ang.css +875 -0
- package/sdk/antd-ie11.css +875 -0
- package/sdk/antd.css +875 -0
- package/sdk/charts.js +18 -18
- package/sdk/codemirror.js +14 -0
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +3 -3
- package/sdk/cxd-ie11.css +875 -0
- package/sdk/cxd.css +875 -0
- package/sdk/dark-ie11.css +875 -0
- package/sdk/dark.css +875 -0
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css +57 -57
- package/sdk/helper.css.map +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +18 -18
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +875 -0
- package/sdk/sdk.css +875 -0
- package/sdk/sdk.js +1315 -1207
- package/sdk/thirds/hls.js/hls.js +18 -18
- package/sdk/thirds/mpegts.js/mpegts.js +2 -2
- package/sdk/tinymce.js +57 -57
- package/src/Root.tsx +1 -0
- package/src/RootRenderer.tsx +3 -3
- package/src/Schema.ts +1 -0
- package/src/SchemaRenderer.tsx +4 -0
- package/src/components/AsideNav.tsx +1 -1
- package/src/components/CodeMirror.tsx +99 -0
- package/src/components/Collapse.tsx +21 -13
- package/src/components/CollapseGroup.tsx +9 -11
- package/src/components/ColorPicker.tsx +45 -3
- package/src/components/DatePicker.tsx +33 -3
- package/src/components/DateRangePicker.tsx +17 -3
- package/src/components/MonthRangePicker.tsx +18 -4
- package/src/components/PickerContainer.tsx +10 -6
- package/src/components/PopUp.tsx +133 -0
- package/src/components/Progress.tsx +1 -1
- package/src/components/Steps.tsx +8 -3
- package/src/components/TabsTransferPicker.tsx +1 -1
- package/src/components/TransferPicker.tsx +1 -11
- package/src/components/formula/Editor.tsx +261 -0
- package/src/components/formula/FuncList.tsx +82 -0
- package/src/components/formula/Picker.tsx +86 -0
- package/src/components/formula/VariableList.tsx +49 -0
- package/src/components/formula/plugin.ts +177 -0
- package/src/components/index.tsx +2 -0
- package/src/index.tsx +1 -0
- package/src/renderers/CRUD.tsx +3 -3
- package/src/renderers/Collapse.tsx +27 -27
- package/src/renderers/CollapseGroup.tsx +13 -12
- package/src/renderers/Dialog.tsx +8 -8
- package/src/renderers/Drawer.tsx +2 -2
- package/src/renderers/Form/InputColor.tsx +2 -3
- package/src/renderers/Form/InputDate.tsx +2 -0
- package/src/renderers/Form/InputDateRange.tsx +2 -0
- package/src/renderers/Form/InputFile.tsx +1 -1
- package/src/renderers/Form/InputFormula.tsx +75 -0
- package/src/renderers/Form/InputImage.tsx +1 -1
- package/src/renderers/Form/InputMonthRange.tsx +2 -0
- package/src/renderers/Form/InputQuarterRange.tsx +2 -0
- package/src/renderers/Form/InputYearRange.tsx +2 -0
- package/src/renderers/Form/Item.tsx +2 -2
- package/src/renderers/Form/TreeSelect.tsx +82 -63
- package/src/renderers/Form/index.tsx +2 -2
- package/src/renderers/Page.tsx +11 -10
- package/src/renderers/Steps.tsx +4 -2
- package/src/renderers/Wizard.tsx +52 -12
- package/src/store/formItem.ts +15 -0
- package/src/utils/api.ts +5 -2
- package/src/utils/helper.ts +5 -14
@@ -0,0 +1,177 @@
|
|
1
|
+
/**
|
2
|
+
* @file 扩展 codemirror
|
3
|
+
*/
|
4
|
+
|
5
|
+
import type CodeMirror from 'codemirror';
|
6
|
+
import {eachTree} from '../../utils/helper';
|
7
|
+
import type {FormulaEditorProps, VariableItem} from './Editor';
|
8
|
+
|
9
|
+
export function editorFactory(
|
10
|
+
dom: HTMLElement,
|
11
|
+
cm: typeof CodeMirror,
|
12
|
+
props: any
|
13
|
+
) {
|
14
|
+
registerLaunguageMode(cm);
|
15
|
+
|
16
|
+
console.log('here', props.evalMode);
|
17
|
+
|
18
|
+
return cm(dom, {
|
19
|
+
value: props.value || '',
|
20
|
+
autofocus: true,
|
21
|
+
mode: props.evalMode ? 'text/formula' : 'text/formula-template'
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
export class FormulaPlugin {
|
26
|
+
constructor(
|
27
|
+
readonly editor: CodeMirror.Editor,
|
28
|
+
readonly cm: typeof CodeMirror,
|
29
|
+
readonly getProps: () => FormulaEditorProps
|
30
|
+
) {
|
31
|
+
// editor.on('change', this.autoMarkText);
|
32
|
+
this.autoMarkText();
|
33
|
+
}
|
34
|
+
|
35
|
+
autoMarkText() {
|
36
|
+
const {functions, variables, value} = this.getProps();
|
37
|
+
if (value) {
|
38
|
+
// todo functions 也需要自动替换
|
39
|
+
this.autoMark(variables);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
insertContent(value: any, type: 'variable' | 'func') {
|
44
|
+
const from = this.editor.getCursor();
|
45
|
+
if (type === 'variable') {
|
46
|
+
this.editor.replaceSelection(value.key);
|
47
|
+
var to = this.editor.getCursor();
|
48
|
+
|
49
|
+
this.markText(from, to, value.name, 'cm-field');
|
50
|
+
} else if (type === 'func') {
|
51
|
+
// todo 支持 snippet,目前是不支持的
|
52
|
+
|
53
|
+
this.editor.replaceSelection(`${value}()`);
|
54
|
+
var to = this.editor.getCursor();
|
55
|
+
this.markText(
|
56
|
+
from,
|
57
|
+
{
|
58
|
+
line: to.line,
|
59
|
+
ch: to.ch - 2
|
60
|
+
},
|
61
|
+
value,
|
62
|
+
'cm-func'
|
63
|
+
);
|
64
|
+
|
65
|
+
this.editor.setCursor({
|
66
|
+
line: to.line,
|
67
|
+
ch: to.ch - 1
|
68
|
+
});
|
69
|
+
} else if (typeof value === 'string') {
|
70
|
+
this.editor.replaceSelection(value);
|
71
|
+
}
|
72
|
+
|
73
|
+
this.editor.focus();
|
74
|
+
}
|
75
|
+
|
76
|
+
markText(
|
77
|
+
from: CodeMirror.Position,
|
78
|
+
to: CodeMirror.Position,
|
79
|
+
label: string,
|
80
|
+
className = 'cm-func'
|
81
|
+
) {
|
82
|
+
const text = document.createElement('span');
|
83
|
+
text.className = className;
|
84
|
+
text.innerText = label;
|
85
|
+
this.editor.markText(from, to, {
|
86
|
+
atomic: true,
|
87
|
+
replacedWith: text
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
autoMark(variables: Array<VariableItem>) {
|
92
|
+
if (!Array.isArray(variables) || !variables.length) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
const varMap: {
|
97
|
+
[propname: string]: string;
|
98
|
+
} = {};
|
99
|
+
|
100
|
+
eachTree(
|
101
|
+
variables,
|
102
|
+
item => item.value && (varMap[item.value] = item.label)
|
103
|
+
);
|
104
|
+
const vars = Object.keys(varMap).sort((a, b) => b.length - a.length);
|
105
|
+
|
106
|
+
const editor = this.editor;
|
107
|
+
const lines = editor.lineCount();
|
108
|
+
for (let line = 0; line < lines; line++) {
|
109
|
+
const content = editor.getLine(line);
|
110
|
+
|
111
|
+
// 标记方法调用
|
112
|
+
content.replace(/([A-Z]+)\s*\(/g, (_, func, pos) => {
|
113
|
+
this.markText(
|
114
|
+
{
|
115
|
+
line: line,
|
116
|
+
ch: pos
|
117
|
+
},
|
118
|
+
{
|
119
|
+
line: line,
|
120
|
+
ch: pos + func.length
|
121
|
+
},
|
122
|
+
func,
|
123
|
+
'cm-func'
|
124
|
+
);
|
125
|
+
return _;
|
126
|
+
});
|
127
|
+
|
128
|
+
// 标记变量
|
129
|
+
vars.forEach(v => {
|
130
|
+
let from = 0;
|
131
|
+
let idx = -1;
|
132
|
+
while (~(idx = content.indexOf(v, from))) {
|
133
|
+
this.markText(
|
134
|
+
{
|
135
|
+
line: line,
|
136
|
+
ch: idx
|
137
|
+
},
|
138
|
+
{
|
139
|
+
line: line,
|
140
|
+
ch: idx + v.length
|
141
|
+
},
|
142
|
+
varMap[v],
|
143
|
+
'cm-field'
|
144
|
+
);
|
145
|
+
from = idx + v.length;
|
146
|
+
}
|
147
|
+
});
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
dispose() {}
|
152
|
+
|
153
|
+
validate() {}
|
154
|
+
}
|
155
|
+
|
156
|
+
let modeRegisted = false;
|
157
|
+
function registerLaunguageMode(cm: typeof CodeMirror) {
|
158
|
+
if (modeRegisted) {
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
modeRegisted = true;
|
162
|
+
|
163
|
+
// 对应 evalMode
|
164
|
+
cm.defineMode('formula', (config: any, parserConfig: any) => {
|
165
|
+
var formula = cm.getMode(config, 'javascript');
|
166
|
+
if (!parserConfig || !parserConfig.base) return formula;
|
167
|
+
|
168
|
+
return cm.multiplexingMode(cm.getMode(config, parserConfig.base), {
|
169
|
+
open: '${',
|
170
|
+
close: '}',
|
171
|
+
mode: formula
|
172
|
+
});
|
173
|
+
});
|
174
|
+
|
175
|
+
cm.defineMIME('text/formula', {name: 'formula'});
|
176
|
+
cm.defineMIME('text/formula-template', {name: 'formula', base: 'htmlmixed'});
|
177
|
+
}
|
package/src/components/index.tsx
CHANGED
@@ -12,6 +12,7 @@ import Button from './Button';
|
|
12
12
|
import Checkbox from './Checkbox';
|
13
13
|
import Checkboxes from './Selection';
|
14
14
|
import Collapse from './Collapse';
|
15
|
+
import CollapseGroup from './CollapseGroup';
|
15
16
|
import DatePicker from './DatePicker';
|
16
17
|
import DateRangePicker from './DateRangePicker';
|
17
18
|
import Drawer from './Drawer';
|
@@ -69,6 +70,7 @@ export {
|
|
69
70
|
Checkbox,
|
70
71
|
Checkboxes,
|
71
72
|
Collapse,
|
73
|
+
CollapseGroup,
|
72
74
|
DatePicker,
|
73
75
|
DateRangePicker,
|
74
76
|
Drawer,
|
package/src/index.tsx
CHANGED
@@ -89,6 +89,7 @@ import './renderers/Form/Select';
|
|
89
89
|
import './renderers/Form/Static';
|
90
90
|
import './renderers/Form/InputDate';
|
91
91
|
import './renderers/Form/InputDateRange';
|
92
|
+
import './renderers/Form/InputFormula';
|
92
93
|
import './renderers/Form/InputRepeat';
|
93
94
|
import './renderers/Form/InputTree';
|
94
95
|
import './renderers/Form/TreeSelect';
|
package/src/renderers/CRUD.tsx
CHANGED
@@ -885,7 +885,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
885
885
|
env
|
886
886
|
} = this.props;
|
887
887
|
|
888
|
-
store.closeDialog();
|
888
|
+
store.closeDialog(true);
|
889
889
|
const dialogAction = store.action as Action;
|
890
890
|
|
891
891
|
if (stopAutoRefreshWhenModalIsOpen && interval) {
|
@@ -968,10 +968,10 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
968
968
|
redirect && env.jumpTo(redirect, dialogAction);
|
969
969
|
}
|
970
970
|
|
971
|
-
handleDialogClose() {
|
971
|
+
handleDialogClose(confirmed = false) {
|
972
972
|
const {store, stopAutoRefreshWhenModalIsOpen, silentPolling, interval} =
|
973
973
|
this.props;
|
974
|
-
store.closeDialog();
|
974
|
+
store.closeDialog(confirmed);
|
975
975
|
|
976
976
|
if (stopAutoRefreshWhenModalIsOpen && interval) {
|
977
977
|
this.timer = setTimeout(
|
@@ -1,12 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {Renderer, RendererProps} from '../factory';
|
3
3
|
import {Collapse as BasicCollapse} from '../components/Collapse';
|
4
|
-
import {
|
5
|
-
BaseSchema,
|
6
|
-
SchemaCollection,
|
7
|
-
SchemaTpl,
|
8
|
-
SchemaObject
|
9
|
-
} from '../Schema';
|
4
|
+
import {BaseSchema, SchemaCollection, SchemaTpl, SchemaObject} from '../Schema';
|
10
5
|
|
11
6
|
/**
|
12
7
|
* Collapse 折叠渲染器,格式说明。
|
@@ -63,9 +58,9 @@ export interface CollapseSchema extends BaseSchema {
|
|
63
58
|
*/
|
64
59
|
showArrow?: boolean;
|
65
60
|
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
/**
|
62
|
+
* 自定义切换图标
|
63
|
+
*/
|
69
64
|
expandIcon?: SchemaObject;
|
70
65
|
|
71
66
|
/**
|
@@ -104,14 +99,9 @@ export interface CollapseProps
|
|
104
99
|
children?: JSX.Element | ((props?: any) => JSX.Element);
|
105
100
|
}
|
106
101
|
|
107
|
-
export default class Collapse extends React.Component<
|
108
|
-
CollapseProps,
|
109
|
-
{}
|
110
|
-
> {
|
111
|
-
|
102
|
+
export default class Collapse extends React.Component<CollapseProps, {}> {
|
112
103
|
render() {
|
113
104
|
const {
|
114
|
-
key,
|
115
105
|
id,
|
116
106
|
classPrefix: ns,
|
117
107
|
classnames: cx,
|
@@ -144,7 +134,6 @@ export default class Collapse extends React.Component<
|
|
144
134
|
|
145
135
|
return (
|
146
136
|
<BasicCollapse
|
147
|
-
key={key}
|
148
137
|
id={id}
|
149
138
|
classnames={cx}
|
150
139
|
classPrefix={ns}
|
@@ -162,19 +151,30 @@ export default class Collapse extends React.Component<
|
|
162
151
|
showArrow={showArrow}
|
163
152
|
disabled={disabled}
|
164
153
|
propsUpdate={propsUpdate}
|
165
|
-
expandIcon={
|
166
|
-
|
154
|
+
expandIcon={
|
155
|
+
expandIcon
|
156
|
+
? render('arrow-icon', expandIcon || '', {
|
157
|
+
className: cx('Collapse-icon-tranform')
|
158
|
+
})
|
159
|
+
: null
|
160
|
+
}
|
161
|
+
collapseHeader={
|
162
|
+
collapseTitle || collapseHeader
|
163
|
+
? render('heading', collapseTitle || collapseHeader)
|
164
|
+
: null
|
165
|
+
}
|
167
166
|
header={render('heading', title || header || '')}
|
168
|
-
body={
|
169
|
-
|
170
|
-
? children
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
167
|
+
body={
|
168
|
+
children
|
169
|
+
? typeof children === 'function'
|
170
|
+
? children(this.props)
|
171
|
+
: children
|
172
|
+
: body
|
173
|
+
? render('body', body)
|
174
|
+
: null
|
175
|
+
}
|
175
176
|
onCollapse={onCollapse}
|
176
|
-
>
|
177
|
-
</BasicCollapse>
|
177
|
+
></BasicCollapse>
|
178
178
|
);
|
179
179
|
}
|
180
180
|
}
|
@@ -41,11 +41,13 @@ export interface CollapseGroupSchema extends BaseSchema {
|
|
41
41
|
export interface CollapseGroupProps
|
42
42
|
extends RendererProps,
|
43
43
|
Omit<CollapseGroupSchema, 'type' | 'className'> {
|
44
|
-
|
45
44
|
children?: JSX.Element | ((props?: any) => JSX.Element);
|
46
45
|
}
|
47
46
|
|
48
|
-
export class CollapseGroupRender extends React.Component<
|
47
|
+
export class CollapseGroupRender extends React.Component<
|
48
|
+
CollapseGroupProps,
|
49
|
+
{}
|
50
|
+
> {
|
49
51
|
constructor(props: CollapseGroupProps) {
|
50
52
|
super(props);
|
51
53
|
}
|
@@ -61,19 +63,18 @@ export class CollapseGroupRender extends React.Component<CollapseGroupProps, {}>
|
|
61
63
|
} = this.props;
|
62
64
|
return (
|
63
65
|
<CollapseGroup
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
)
|
66
|
+
defaultActiveKey={defaultActiveKey}
|
67
|
+
accordion={accordion}
|
68
|
+
expandIcon={expandIcon}
|
69
|
+
expandIconPosition={expandIconPosition}
|
70
|
+
className={className}
|
71
|
+
>
|
72
|
+
{render('body', body || '')}
|
73
|
+
</CollapseGroup>
|
74
|
+
);
|
73
75
|
}
|
74
76
|
}
|
75
77
|
|
76
|
-
|
77
78
|
@Renderer({
|
78
79
|
type: 'collapse-group'
|
79
80
|
})
|
package/src/renderers/Dialog.tsx
CHANGED
@@ -97,7 +97,7 @@ export type DialogSchemaBase = Omit<DialogSchema, 'type'>;
|
|
97
97
|
export interface DialogProps
|
98
98
|
extends RendererProps,
|
99
99
|
Omit<DialogSchema, 'className'> {
|
100
|
-
onClose: () => void;
|
100
|
+
onClose: (confirmed?: boolean) => void;
|
101
101
|
onConfirm: (
|
102
102
|
values: Array<object>,
|
103
103
|
action: Action,
|
@@ -214,12 +214,12 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
214
214
|
return ret;
|
215
215
|
}
|
216
216
|
|
217
|
-
handleSelfClose() {
|
217
|
+
handleSelfClose(e?: any, confirmed?: boolean) {
|
218
218
|
const {onClose, store} = this.props;
|
219
219
|
|
220
220
|
// clear error
|
221
221
|
store.updateMessage();
|
222
|
-
onClose();
|
222
|
+
onClose(confirmed);
|
223
223
|
}
|
224
224
|
|
225
225
|
handleAction(e: React.UIEvent<any>, action: Action, data: object) {
|
@@ -251,7 +251,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
251
251
|
return;
|
252
252
|
}
|
253
253
|
|
254
|
-
store.closeDialog();
|
254
|
+
store.closeDialog(true);
|
255
255
|
}
|
256
256
|
|
257
257
|
handleDialogClose(...args: Array<any>) {
|
@@ -264,7 +264,7 @@ export default class Dialog extends React.Component<DialogProps> {
|
|
264
264
|
return;
|
265
265
|
}
|
266
266
|
|
267
|
-
store.closeDialog();
|
267
|
+
store.closeDialog(args[1]);
|
268
268
|
}
|
269
269
|
|
270
270
|
handleDrawerConfirm(values: object[], action: Action, ...args: Array<any>) {
|
@@ -743,7 +743,7 @@ export class DialogRenderer extends Dialog {
|
|
743
743
|
},
|
744
744
|
data,
|
745
745
|
action
|
746
|
-
) || this.handleSelfClose();
|
746
|
+
) || this.handleSelfClose(undefined, true);
|
747
747
|
} else if (action.actionType === 'next' || action.actionType === 'prev') {
|
748
748
|
store.setCurrentAction(action);
|
749
749
|
if (action.type === 'submit') {
|
@@ -755,7 +755,7 @@ export class DialogRenderer extends Dialog {
|
|
755
755
|
},
|
756
756
|
data,
|
757
757
|
action
|
758
|
-
) || this.handleSelfClose();
|
758
|
+
) || this.handleSelfClose(undefined, true);
|
759
759
|
} else {
|
760
760
|
onConfirm([data], action, data, []);
|
761
761
|
}
|
@@ -769,7 +769,7 @@ export class DialogRenderer extends Dialog {
|
|
769
769
|
store.setCurrentAction(action);
|
770
770
|
action.target && scoped.reload(action.target, data);
|
771
771
|
if (action.close || action.type === 'submit') {
|
772
|
-
this.handleSelfClose();
|
772
|
+
this.handleSelfClose(undefined, action.type === 'submit');
|
773
773
|
this.closeTarget(action.close);
|
774
774
|
}
|
775
775
|
} else if (this.tryChildrenToHandle(action, data)) {
|
package/src/renderers/Drawer.tsx
CHANGED
@@ -304,7 +304,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|
304
304
|
return;
|
305
305
|
}
|
306
306
|
|
307
|
-
store.closeDialog();
|
307
|
+
store.closeDialog(true);
|
308
308
|
}
|
309
309
|
|
310
310
|
handleDialogClose(...args: Array<any>) {
|
@@ -317,7 +317,7 @@ export default class Drawer extends React.Component<DrawerProps> {
|
|
317
317
|
return;
|
318
318
|
}
|
319
319
|
|
320
|
-
store.closeDialog();
|
320
|
+
store.closeDialog(args[1]);
|
321
321
|
}
|
322
322
|
|
323
323
|
handleChildFinished(value: any, action: Action) {
|
@@ -68,12 +68,11 @@ export default class ColorControl extends React.PureComponent<
|
|
68
68
|
};
|
69
69
|
|
70
70
|
render() {
|
71
|
-
const {className, classPrefix: ns, value, ...rest} = this.props;
|
72
|
-
|
71
|
+
const {className, classPrefix: ns, value, env, ...rest} = this.props;
|
73
72
|
return (
|
74
73
|
<div className={cx(`${ns}ColorControl`, className)}>
|
75
74
|
<Suspense fallback={<div>...</div>}>
|
76
|
-
<ColorPicker classPrefix={ns} {...rest} value={value || ''} />
|
75
|
+
<ColorPicker classPrefix={ns} {...rest} value={value || ''} useMobileUI={env.useMobileUI}/>
|
77
76
|
</Suspense>
|
78
77
|
</div>
|
79
78
|
);
|
@@ -424,6 +424,7 @@ export default class DateControl extends React.PureComponent<
|
|
424
424
|
format,
|
425
425
|
timeFormat,
|
426
426
|
valueFormat,
|
427
|
+
env,
|
427
428
|
largeMode,
|
428
429
|
render,
|
429
430
|
...rest
|
@@ -441,6 +442,7 @@ export default class DateControl extends React.PureComponent<
|
|
441
442
|
format={valueFormat || format}
|
442
443
|
{...this.state}
|
443
444
|
classnames={cx}
|
445
|
+
useMobileUI={env.useMobileUI}
|
444
446
|
schedules={this.state.schedules}
|
445
447
|
largeMode={largeMode}
|
446
448
|
onScheduleClick={this.onScheduleClick.bind(this)}
|
@@ -172,6 +172,7 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|
172
172
|
maxDuration,
|
173
173
|
data,
|
174
174
|
format,
|
175
|
+
env,
|
175
176
|
...rest
|
176
177
|
} = this.props;
|
177
178
|
|
@@ -186,6 +187,7 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|
186
187
|
maxDate={maxDate ? filterDate(maxDate, data, format) : undefined}
|
187
188
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
188
189
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
190
|
+
useMobileUI={env.useMobileUI}
|
189
191
|
/>
|
190
192
|
</div>
|
191
193
|
);
|
@@ -790,7 +790,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
790
790
|
onProgress
|
791
791
|
)
|
792
792
|
.then(ret => {
|
793
|
-
if (ret.status || !ret.data) {
|
793
|
+
if ((ret.status && (ret as any).status !== '0') || !ret.data) {
|
794
794
|
throw new Error(ret.msg || __('File.errorRetry'));
|
795
795
|
}
|
796
796
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import FormItem, {FormBaseControl, FormControlProps} from './Item';
|
3
|
+
import FormulaPicker from '../../components/formula/Picker';
|
4
|
+
import type {FuncGroup, VariableItem} from '../../components/formula/Editor';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* InputFormula 公式编辑器
|
8
|
+
* 文档:https://baidu.gitee.io/amis/docs/components/form/input-formula
|
9
|
+
*/
|
10
|
+
export interface InputFormulaControlSchema extends FormBaseControl {
|
11
|
+
type: 'input-formula';
|
12
|
+
|
13
|
+
/**
|
14
|
+
* evalMode 即直接就是表达式,否则
|
15
|
+
* 需要 ${这里面才是表达式}
|
16
|
+
* 默认为 true
|
17
|
+
*/
|
18
|
+
evalMode?: boolean;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* 用于提示的变量集合,默认为空
|
22
|
+
*/
|
23
|
+
variables: Array<VariableItem>;
|
24
|
+
|
25
|
+
variableMode?: 'tabs' | 'tree';
|
26
|
+
|
27
|
+
/**
|
28
|
+
* 函数集合,默认不需要传,即 amis-formula 里面那个函数
|
29
|
+
* 如果有扩充,则需要传。
|
30
|
+
*/
|
31
|
+
functions: Array<FuncGroup>;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* 顶部标题,默认为表达式
|
35
|
+
*/
|
36
|
+
header: string;
|
37
|
+
}
|
38
|
+
|
39
|
+
export interface InputFormulaProps
|
40
|
+
extends FormControlProps,
|
41
|
+
Omit<
|
42
|
+
InputFormulaControlSchema,
|
43
|
+
'options' | 'inputClassName' | 'className' | 'descriptionClassName'
|
44
|
+
> {}
|
45
|
+
|
46
|
+
@FormItem({
|
47
|
+
type: 'input-formula'
|
48
|
+
})
|
49
|
+
export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
|
50
|
+
render() {
|
51
|
+
const {
|
52
|
+
selectedOptions,
|
53
|
+
disabled,
|
54
|
+
onChange,
|
55
|
+
evalMode,
|
56
|
+
variables,
|
57
|
+
variableMode,
|
58
|
+
functions,
|
59
|
+
header
|
60
|
+
} = this.props;
|
61
|
+
|
62
|
+
return (
|
63
|
+
<FormulaPicker
|
64
|
+
value={selectedOptions}
|
65
|
+
disabled={disabled}
|
66
|
+
onChange={onChange}
|
67
|
+
evalMode={evalMode}
|
68
|
+
variables={variables}
|
69
|
+
variableMode={variableMode}
|
70
|
+
functions={functions}
|
71
|
+
header={header}
|
72
|
+
/>
|
73
|
+
);
|
74
|
+
}
|
75
|
+
}
|
@@ -1035,7 +1035,7 @@ export default class ImageControl extends React.Component<
|
|
1035
1035
|
const __ = this.props.translate;
|
1036
1036
|
this._send(file, this.props.receiver as string, {}, onProgress)
|
1037
1037
|
.then((ret: Payload) => {
|
1038
|
-
if (ret.status) {
|
1038
|
+
if (ret.status && (ret as any).status !== '0') {
|
1039
1039
|
throw new Error(ret.msg || __('File.errorRetry'));
|
1040
1040
|
}
|
1041
1041
|
|
@@ -170,6 +170,7 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
|
170
170
|
maxDuration,
|
171
171
|
data,
|
172
172
|
format,
|
173
|
+
env,
|
173
174
|
...rest
|
174
175
|
} = this.props;
|
175
176
|
|
@@ -184,6 +185,7 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
|
184
185
|
maxDate={maxDate ? filterDate(maxDate, data, format) : undefined}
|
185
186
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
186
187
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
188
|
+
useMobileUI={env.useMobileUI}
|
187
189
|
/>
|
188
190
|
</div>
|
189
191
|
);
|
@@ -26,6 +26,7 @@ export default class QuarterRangeControl extends InputDateRange {
|
|
26
26
|
maxDuration,
|
27
27
|
data,
|
28
28
|
format,
|
29
|
+
env,
|
29
30
|
...rest
|
30
31
|
} = this.props;
|
31
32
|
|
@@ -44,6 +45,7 @@ export default class QuarterRangeControl extends InputDateRange {
|
|
44
45
|
maxDate={maxDate ? filterDate(maxDate, data, format) : undefined}
|
45
46
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
46
47
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
48
|
+
useMobileUI={env.useMobileUI}
|
47
49
|
/>
|
48
50
|
</div>
|
49
51
|
);
|
@@ -26,6 +26,7 @@ export default class YearRangeControl extends InputDateRange {
|
|
26
26
|
maxDuration,
|
27
27
|
data,
|
28
28
|
format,
|
29
|
+
env,
|
29
30
|
...rest
|
30
31
|
} = this.props;
|
31
32
|
|
@@ -44,6 +45,7 @@ export default class YearRangeControl extends InputDateRange {
|
|
44
45
|
maxDate={maxDate ? filterDate(maxDate, data, format) : undefined}
|
45
46
|
minDuration={minDuration ? parseDuration(minDuration) : undefined}
|
46
47
|
maxDuration={maxDuration ? parseDuration(maxDuration) : undefined}
|
48
|
+
useMobileUI={env.useMobileUI}
|
47
49
|
/>
|
48
50
|
</div>
|
49
51
|
);
|
@@ -436,12 +436,12 @@ export class FormItemWrap extends React.Component<FormItemProps> {
|
|
436
436
|
}
|
437
437
|
|
438
438
|
@autobind
|
439
|
-
handleDialogClose() {
|
439
|
+
handleDialogClose(confirmed = false) {
|
440
440
|
const {formItem: model} = this.props;
|
441
441
|
if (!model) {
|
442
442
|
return;
|
443
443
|
}
|
444
|
-
model.closeDialog();
|
444
|
+
model.closeDialog(confirmed);
|
445
445
|
}
|
446
446
|
|
447
447
|
renderControl(): JSX.Element | null {
|