amis 1.8.0-beta.5 → 1.8.0-beta.9
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/Schema.d.ts +9 -2
- package/lib/Schema.js.map +1 -1
- package/lib/actions/PageAction.d.ts +32 -0
- package/lib/actions/PageAction.js +72 -0
- package/lib/actions/PageAction.js.map +13 -0
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/index.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +84 -84
- package/lib/components/Cascader.d.ts +2 -0
- package/lib/components/Cascader.js +28 -12
- package/lib/components/Cascader.js.map +2 -2
- package/lib/components/Checkbox.js +2 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DatePicker.js +5 -5
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/Overlay.d.ts +1 -0
- package/lib/components/Overlay.js +4 -3
- package/lib/components/Overlay.js.map +2 -2
- package/lib/components/PullRefresh.d.ts +86 -0
- package/lib/components/PullRefresh.js +135 -0
- package/lib/components/PullRefresh.js.map +13 -0
- package/lib/components/Spinner.d.ts +200 -107
- package/lib/components/Spinner.js +30 -26
- package/lib/components/Spinner.js.map +2 -2
- package/lib/components/Tooltip.d.ts +4 -0
- package/lib/components/Tooltip.js +6 -4
- package/lib/components/Tooltip.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +60 -4
- package/lib/components/TooltipWrapper.js +27 -8
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +87 -85
- package/lib/components/Tree.js +13 -5
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/TimeView.d.ts +1 -0
- package/lib/components/calendar/TimeView.js +7 -0
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/condition-builder/Expression.d.ts +1 -0
- package/lib/components/condition-builder/Expression.js +4 -4
- package/lib/components/condition-builder/Expression.js.map +2 -2
- package/lib/components/condition-builder/Field.d.ts +1 -0
- package/lib/components/condition-builder/Field.js +3 -2
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Group.d.ts +1 -0
- package/lib/components/condition-builder/Group.js +2 -2
- package/lib/components/condition-builder/Group.js.map +2 -2
- package/lib/components/condition-builder/GroupOrItem.d.ts +1 -0
- package/lib/components/condition-builder/GroupOrItem.js +2 -2
- package/lib/components/condition-builder/GroupOrItem.js.map +2 -2
- package/lib/components/condition-builder/InputSwitch.d.ts +2 -1
- package/lib/components/condition-builder/InputSwitch.js +2 -2
- package/lib/components/condition-builder/InputSwitch.js.map +2 -2
- package/lib/components/condition-builder/Item.d.ts +1 -0
- package/lib/components/condition-builder/Item.js +9 -8
- package/lib/components/condition-builder/Item.js.map +2 -2
- package/lib/components/condition-builder/Value.d.ts +1 -0
- package/lib/components/condition-builder/Value.js +5 -5
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/index.d.ts +1 -0
- package/lib/components/condition-builder/index.js +2 -2
- package/lib/components/condition-builder/index.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +87 -85
- package/lib/components/formula/Editor.js +10 -6
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.js +3 -1
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +5 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +5 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +5 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/CRUD.js +1 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +2 -1
- package/lib/renderers/Form/Combo.js +51 -14
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -0
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputDate.js +10 -3
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +12 -3
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +13 -5
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +12 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +5 -1
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputText.js +8 -4
- package/lib/renderers/Form/InputText.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +5 -0
- package/lib/renderers/Form/InputTree.js +51 -2
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +68 -70
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +4 -0
- package/lib/renderers/Form/NestedSelect.js +14 -5
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +61 -27
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.js +4 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +11 -2
- package/lib/renderers/Form/TreeSelect.js +56 -10
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.d.ts +82 -67
- package/lib/renderers/Nav.js +47 -11
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.d.ts +20 -0
- package/lib/renderers/Page.js +51 -14
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +2 -0
- package/lib/renderers/Service.js +52 -20
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Spinner.d.ts +58 -2
- package/lib/renderers/Spinner.js +8 -1
- package/lib/renderers/Spinner.js.map +2 -2
- package/lib/renderers/Table/ColumnToggler.d.ts +4 -0
- package/lib/renderers/Table/ColumnToggler.js +11 -6
- package/lib/renderers/Table/ColumnToggler.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +27 -1
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +19 -11
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +31 -6
- package/lib/renderers/TooltipWrapper.js +18 -8
- package/lib/renderers/TooltipWrapper.js.map +2 -2
- package/lib/renderers/Wizard.js +23 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/crud.js +23 -13
- package/lib/store/crud.js.map +2 -2
- package/lib/themes/ang-ie11.css +313 -100
- package/lib/themes/ang.css +322 -103
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +429 -216
- package/lib/themes/antd.css +323 -104
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +424 -211
- package/lib/themes/cxd.css +324 -105
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +313 -100
- package/lib/themes/dark.css +322 -103
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +424 -211
- package/lib/themes/default.css +324 -105
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/ColorScale.d.ts +19 -0
- package/lib/utils/ColorScale.js +104 -0
- package/lib/utils/ColorScale.js.map +13 -0
- package/lib/utils/api.js +20 -4
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/dom.d.ts +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/dom.js.map +2 -2
- package/package.json +3 -2
- package/schema.json +29645 -29137
- package/scss/_properties.scss +33 -15
- package/scss/components/_column-toggler.scss +21 -11
- package/scss/components/_formula.scss +1 -1
- package/scss/components/_nav.scss +51 -6
- package/scss/components/_pull-refresh.scss +25 -0
- package/scss/components/_spinner.scss +134 -56
- package/scss/components/_tooltip.scss +4 -9
- package/scss/components/form/_checks.scss +1 -0
- package/scss/components/form/_combo.scss +13 -1
- package/scss/components/form/_date-range.scss +11 -2
- package/scss/components/form/_date.scss +11 -0
- package/scss/components/form/_file.scss +4 -0
- package/scss/components/form/_form.scss +15 -8
- package/scss/components/form/_transfer.scss +3 -2
- package/scss/themes/_antd-variables.scss +1 -1
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +2 -2
- package/sdk/ang-ie11.css +286 -80
- package/sdk/ang.css +294 -82
- package/sdk/antd-ie11.css +402 -196
- package/sdk/antd.css +295 -83
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +397 -191
- package/sdk/cxd.css +296 -84
- package/sdk/dark-ie11.css +286 -80
- package/sdk/dark.css +294 -82
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +5 -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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +397 -191
- package/sdk/sdk.css +296 -84
- package/sdk/sdk.js +1300 -1260
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/Schema.ts +10 -0
- package/src/actions/PageAction.ts +62 -0
- package/src/actions/index.ts +1 -0
- package/src/components/Cascader.tsx +37 -11
- package/src/components/Checkbox.tsx +1 -1
- package/src/components/DatePicker.tsx +7 -5
- package/src/components/Drawer.tsx +1 -0
- package/src/components/Modal.tsx +1 -0
- package/src/components/Overlay.tsx +6 -3
- package/src/components/PullRefresh.tsx +197 -0
- package/src/components/Spinner.tsx +77 -42
- package/src/components/Tooltip.tsx +12 -3
- package/src/components/TooltipWrapper.tsx +120 -33
- package/src/components/Tree.tsx +19 -5
- package/src/components/calendar/TimeView.tsx +12 -0
- package/src/components/condition-builder/Expression.tsx +6 -1
- package/src/components/condition-builder/Field.tsx +5 -1
- package/src/components/condition-builder/Group.tsx +4 -1
- package/src/components/condition-builder/GroupOrItem.tsx +4 -1
- package/src/components/condition-builder/InputSwitch.tsx +4 -1
- package/src/components/condition-builder/Item.tsx +28 -4
- package/src/components/condition-builder/Value.tsx +7 -1
- package/src/components/condition-builder/index.tsx +4 -2
- package/src/components/formula/Editor.tsx +20 -15
- package/src/components/formula/Picker.tsx +9 -5
- package/src/locale/de-DE.ts +5 -1
- package/src/locale/en-US.ts +5 -1
- package/src/locale/zh-CN.ts +5 -1
- package/src/renderers/CRUD.tsx +1 -1
- package/src/renderers/Form/Combo.tsx +102 -46
- package/src/renderers/Form/InputDate.tsx +18 -4
- package/src/renderers/Form/InputDateRange.tsx +19 -2
- package/src/renderers/Form/InputFile.tsx +16 -4
- package/src/renderers/Form/InputImage.tsx +15 -3
- package/src/renderers/Form/InputMonthRange.tsx +7 -1
- package/src/renderers/Form/InputText.tsx +14 -2
- package/src/renderers/Form/InputTree.tsx +40 -2
- package/src/renderers/Form/Item.tsx +6 -0
- package/src/renderers/Form/NestedSelect.tsx +23 -4
- package/src/renderers/Form/Options.tsx +26 -7
- package/src/renderers/Form/Select.tsx +5 -3
- package/src/renderers/Form/TreeSelect.tsx +47 -9
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Nav.tsx +230 -32
- package/src/renderers/Page.tsx +89 -33
- package/src/renderers/Service.tsx +62 -27
- package/src/renderers/Spinner.tsx +85 -3
- package/src/renderers/Table/ColumnToggler.tsx +36 -11
- package/src/renderers/Table/TableCell.tsx +39 -1
- package/src/renderers/Table/index.tsx +34 -21
- package/src/renderers/TooltipWrapper.tsx +64 -28
- package/src/renderers/Wizard.tsx +36 -25
- package/src/store/crud.ts +10 -0
- package/src/types.ts +4 -0
- package/src/utils/ColorScale.ts +138 -0
- package/src/utils/api.ts +26 -4
- package/src/utils/dom.tsx +7 -6
@@ -13,7 +13,6 @@ import {
|
|
13
13
|
mapTree,
|
14
14
|
guid
|
15
15
|
} from '../../utils/helper';
|
16
|
-
import {findDOMNode} from 'react-dom';
|
17
16
|
import animtion from '../../utils/Animation';
|
18
17
|
import {FormulaPickerProps} from '../formula/Picker';
|
19
18
|
|
@@ -31,6 +30,7 @@ export interface ConditionBuilderProps extends ThemeProps, LocaleProps {
|
|
31
30
|
searchable?: boolean;
|
32
31
|
fieldClassName?: string;
|
33
32
|
formula?: FormulaPickerProps;
|
33
|
+
popOverContainer?: any;
|
34
34
|
}
|
35
35
|
|
36
36
|
export class QueryBuilder extends React.Component<ConditionBuilderProps> {
|
@@ -210,7 +210,8 @@ export class QueryBuilder extends React.Component<ConditionBuilderProps> {
|
|
210
210
|
disabled,
|
211
211
|
searchable,
|
212
212
|
builderMode,
|
213
|
-
formula
|
213
|
+
formula,
|
214
|
+
popOverContainer
|
214
215
|
} = this.props;
|
215
216
|
|
216
217
|
const normalizedValue = Array.isArray(value?.children)
|
@@ -247,6 +248,7 @@ export class QueryBuilder extends React.Component<ConditionBuilderProps> {
|
|
247
248
|
disabled={disabled}
|
248
249
|
searchable={searchable}
|
249
250
|
formula={formula}
|
251
|
+
popOverContainer={popOverContainer}
|
250
252
|
/>
|
251
253
|
);
|
252
254
|
}
|
@@ -29,7 +29,9 @@ export interface FuncGroup {
|
|
29
29
|
}
|
30
30
|
|
31
31
|
export interface FuncItem {
|
32
|
-
name: string;
|
32
|
+
name: string; // 函数名
|
33
|
+
example?: string; // 示例
|
34
|
+
description?: string; // 描述
|
33
35
|
[propName: string]: any;
|
34
36
|
}
|
35
37
|
|
@@ -119,11 +121,7 @@ export class FormulaEditor extends React.Component<
|
|
119
121
|
return funcs;
|
120
122
|
}
|
121
123
|
|
122
|
-
static defaultProps: Pick<
|
123
|
-
FormulaEditorProps,
|
124
|
-
'functions' | 'variables' | 'evalMode'
|
125
|
-
> = {
|
126
|
-
functions: FormulaEditor.buildDefaultFunctions(doc),
|
124
|
+
static defaultProps: Pick<FormulaEditorProps, 'variables' | 'evalMode'> = {
|
127
125
|
variables: [],
|
128
126
|
evalMode: true
|
129
127
|
};
|
@@ -145,11 +143,15 @@ export class FormulaEditor extends React.Component<
|
|
145
143
|
variables,
|
146
144
|
item => item.value && (varMap[item.value] = item.label)
|
147
145
|
);
|
148
|
-
const vars = Object.keys(varMap)
|
149
|
-
|
146
|
+
const vars = Object.keys(varMap)
|
147
|
+
.filter(item => item)
|
148
|
+
.sort((a, b) => b.length - a.length);
|
149
|
+
|
150
|
+
const content = value || '';
|
151
|
+
let html = '';
|
150
152
|
|
151
153
|
// 标记方法调用
|
152
|
-
|
154
|
+
html = content.replace(/([A-Z]+)\s*\(/g, (_, func, pos) => {
|
153
155
|
return _?.replace(func, `<span class="c-func">${func}</span>`);
|
154
156
|
});
|
155
157
|
|
@@ -157,15 +159,12 @@ export class FormulaEditor extends React.Component<
|
|
157
159
|
let from = 0;
|
158
160
|
let idx = -1;
|
159
161
|
while (~(idx = content.indexOf(v, from))) {
|
160
|
-
|
161
|
-
v,
|
162
|
-
`<span class="c-field">${varMap[v]}</span>`
|
163
|
-
);
|
162
|
+
html = content.replace(v, `<span class="c-field">${varMap[v]}</span>`);
|
164
163
|
from = idx + v.length;
|
165
164
|
}
|
166
165
|
});
|
167
166
|
|
168
|
-
return {html
|
167
|
+
return {html};
|
169
168
|
}
|
170
169
|
|
171
170
|
componentWillUnmount() {
|
@@ -254,6 +253,12 @@ export class FormulaEditor extends React.Component<
|
|
254
253
|
classPrefix
|
255
254
|
} = this.props;
|
256
255
|
const {focused} = this.state;
|
256
|
+
const customFunctions = Array.isArray(functions) ? functions : [];
|
257
|
+
const functionList = [
|
258
|
+
...FormulaEditor.buildDefaultFunctions(doc),
|
259
|
+
...customFunctions
|
260
|
+
];
|
261
|
+
|
257
262
|
return (
|
258
263
|
<div
|
259
264
|
className={cx(`FormulaEditor`, {
|
@@ -299,7 +304,7 @@ export class FormulaEditor extends React.Component<
|
|
299
304
|
<FuncList
|
300
305
|
className={functionClassName}
|
301
306
|
title={__('FormulaEditor.function')}
|
302
|
-
data={
|
307
|
+
data={functionList}
|
303
308
|
onSelect={this.handleFunctionSelect}
|
304
309
|
/>
|
305
310
|
</section>
|
@@ -210,11 +210,15 @@ export class FormulaPicker extends React.Component<FormulaPickerProps> {
|
|
210
210
|
allowInput={allowInput}
|
211
211
|
clearable={clearable}
|
212
212
|
value={value}
|
213
|
-
result={
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
213
|
+
result={
|
214
|
+
allowInput
|
215
|
+
? void 0
|
216
|
+
: FormulaEditor.highlightValue(
|
217
|
+
value,
|
218
|
+
variables,
|
219
|
+
functions
|
220
|
+
)
|
221
|
+
}
|
218
222
|
itemRender={this.renderFormulaValue}
|
219
223
|
onResultChange={noop}
|
220
224
|
onChange={this.handleConfirm}
|
package/src/locale/de-DE.ts
CHANGED
@@ -289,5 +289,9 @@ register('de-DE', {
|
|
289
289
|
'FormulaEditor.btnLabel': 'Formel Bearbeiten',
|
290
290
|
'FormulaEditor.title': 'Formel Editor',
|
291
291
|
'FormulaEditor.variable': 'Variable',
|
292
|
-
'FormulaEditor.function': 'Funktion'
|
292
|
+
'FormulaEditor.function': 'Funktion',
|
293
|
+
'pullRefresh.pullingText': 'Zum Aktualisieren nach unten ziehen...',
|
294
|
+
'pullRefresh.loosingText': 'Zum Aktualisieren freigeben...',
|
295
|
+
'pullRefresh.loadingText': 'Laden...',
|
296
|
+
'pullRefresh.successText': 'Laden erfolgreich'
|
293
297
|
});
|
package/src/locale/en-US.ts
CHANGED
@@ -291,5 +291,9 @@ register('en-US', {
|
|
291
291
|
'FormulaEditor.btnLabel': 'Formula Edit',
|
292
292
|
'FormulaEditor.title': 'Formula Editor',
|
293
293
|
'FormulaEditor.variable': 'Variable',
|
294
|
-
'FormulaEditor.function': 'Function'
|
294
|
+
'FormulaEditor.function': 'Function',
|
295
|
+
'pullRefresh.pullingText': 'Pull down to refresh...',
|
296
|
+
'pullRefresh.loosingText': 'Release to refresh...',
|
297
|
+
'pullRefresh.loadingText': 'Loading...',
|
298
|
+
'pullRefresh.successText': 'Loading success'
|
295
299
|
});
|
package/src/locale/zh-CN.ts
CHANGED
@@ -298,5 +298,9 @@ register('zh-CN', {
|
|
298
298
|
'FormulaEditor.btnLabel': '公式编辑',
|
299
299
|
'FormulaEditor.title': '公式编辑器',
|
300
300
|
'FormulaEditor.variable': '变量',
|
301
|
-
'FormulaEditor.function': '函数'
|
301
|
+
'FormulaEditor.function': '函数',
|
302
|
+
'pullRefresh.pullingText': '下拉即可刷新...',
|
303
|
+
'pullRefresh.loosingText': '释放即可刷新...',
|
304
|
+
'pullRefresh.loadingText': '加载中...',
|
305
|
+
'pullRefresh.successText': '加载成功'
|
302
306
|
});
|
package/src/renderers/CRUD.tsx
CHANGED
@@ -1610,7 +1610,7 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
1610
1610
|
`bulk-action/${index}`,
|
1611
1611
|
{
|
1612
1612
|
...omit(btn, ['visibleOn', 'hiddenOn', 'disabledOn']),
|
1613
|
-
type: 'button',
|
1613
|
+
type: btn.type || 'button',
|
1614
1614
|
ignoreConfirm: true
|
1615
1615
|
},
|
1616
1616
|
{
|
@@ -1,13 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {findDOMNode} from 'react-dom';
|
3
3
|
import cloneDeep from 'lodash/cloneDeep';
|
4
|
-
import {
|
5
|
-
|
6
|
-
FormControlProps,
|
7
|
-
FormBaseControl,
|
8
|
-
FormControlSchemaAlias
|
9
|
-
} from './Item';
|
10
|
-
import {Schema, Action, Api} from '../../types';
|
4
|
+
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
5
|
+
import {Action, Api} from '../../types';
|
11
6
|
import {ComboStore, IComboStore} from '../../store/combo';
|
12
7
|
import {default as CTabs, Tab} from '../../components/Tabs';
|
13
8
|
import Button from '../../components/Button';
|
@@ -26,7 +21,7 @@ import {evalExpression, filter} from '../../utils/tpl';
|
|
26
21
|
import find from 'lodash/find';
|
27
22
|
import Select from '../../components/Select';
|
28
23
|
import {dataMapping, resolveVariable} from '../../utils/tpl-builtin';
|
29
|
-
import {isEffectiveApi} from '../../utils/api';
|
24
|
+
import {isEffectiveApi, str2AsyncFunction} from '../../utils/api';
|
30
25
|
import {Alert2} from '../../components';
|
31
26
|
import memoize from 'lodash/memoize';
|
32
27
|
import {Icon} from '../../components/icons';
|
@@ -34,8 +29,6 @@ import {isAlive} from 'mobx-state-tree';
|
|
34
29
|
import {
|
35
30
|
SchemaApi,
|
36
31
|
SchemaClassName,
|
37
|
-
SchemaCollection,
|
38
|
-
SchemaIcon,
|
39
32
|
SchemaObject,
|
40
33
|
SchemaTpl
|
41
34
|
} from '../../Schema';
|
@@ -369,7 +362,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
369
362
|
this.handleFormInit = this.handleFormInit.bind(this);
|
370
363
|
this.handleAction = this.handleAction.bind(this);
|
371
364
|
this.addItem = this.addItem.bind(this);
|
372
|
-
this.
|
365
|
+
this.deleteItem = this.deleteItem.bind(this);
|
373
366
|
this.dragTipRef = this.dragTipRef.bind(this);
|
374
367
|
this.flush = this.flush.bind(this);
|
375
368
|
this.handleComboTypeChange = this.handleComboTypeChange.bind(this);
|
@@ -525,7 +518,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
525
518
|
this.props.onChange(value, submitOnChange, true);
|
526
519
|
}
|
527
520
|
|
528
|
-
async
|
521
|
+
async deleteItem(key: number) {
|
529
522
|
const {
|
530
523
|
flat,
|
531
524
|
joinValues,
|
@@ -699,7 +692,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
699
692
|
const {onAction} = this.props;
|
700
693
|
|
701
694
|
if (action.actionType === 'delete') {
|
702
|
-
action.index !== void 0 && this.
|
695
|
+
action.index !== void 0 && this.deleteItem(action.index);
|
703
696
|
return;
|
704
697
|
}
|
705
698
|
|
@@ -1054,8 +1047,8 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1054
1047
|
) {
|
1055
1048
|
toolbar = (
|
1056
1049
|
<div
|
1057
|
-
onClick={this.
|
1058
|
-
key="
|
1050
|
+
onClick={this.deleteItem.bind(this, index)}
|
1051
|
+
key="delete"
|
1059
1052
|
className={cx(
|
1060
1053
|
`Combo-tab-delBtn ${!store.removable ? 'is-disabled' : ''}`
|
1061
1054
|
)}
|
@@ -1161,6 +1154,99 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1161
1154
|
);
|
1162
1155
|
}
|
1163
1156
|
|
1157
|
+
renderDelBtn(value: any, index: number) {
|
1158
|
+
const {
|
1159
|
+
classPrefix: ns,
|
1160
|
+
classnames: cx,
|
1161
|
+
render,
|
1162
|
+
store,
|
1163
|
+
deleteIcon,
|
1164
|
+
translate: __,
|
1165
|
+
itemRemovableOn,
|
1166
|
+
disabled,
|
1167
|
+
removable,
|
1168
|
+
deleteBtn
|
1169
|
+
} = this.props;
|
1170
|
+
|
1171
|
+
const finnalRemovable =
|
1172
|
+
store.removable !== false && // minLength ?
|
1173
|
+
!disabled && // 控件自身是否禁用
|
1174
|
+
removable !== false; // 是否可以删除
|
1175
|
+
|
1176
|
+
if (
|
1177
|
+
!(
|
1178
|
+
finnalRemovable && // 表达式判断单条是否可删除
|
1179
|
+
(!itemRemovableOn || evalExpression(itemRemovableOn, value) !== false)
|
1180
|
+
)
|
1181
|
+
) {
|
1182
|
+
// 不符合删除条件,则不渲染删除按钮
|
1183
|
+
return null;
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
// deleteBtn是对象,则根据自定义配置渲染按钮
|
1187
|
+
if (isObject(deleteBtn)) {
|
1188
|
+
return render('delete-btn', {
|
1189
|
+
...deleteBtn,
|
1190
|
+
type: 'button',
|
1191
|
+
className: cx(
|
1192
|
+
'Combo-delController',
|
1193
|
+
deleteBtn ? deleteBtn.classname : ''
|
1194
|
+
),
|
1195
|
+
onClick: (e: any) => {
|
1196
|
+
if (!deleteBtn.onClick) {
|
1197
|
+
this.deleteItem(index);
|
1198
|
+
return;
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
let originClickHandler = deleteBtn.onClick;
|
1202
|
+
if (typeof originClickHandler === 'string') {
|
1203
|
+
originClickHandler = str2AsyncFunction(
|
1204
|
+
deleteBtn.onClick,
|
1205
|
+
'e',
|
1206
|
+
'index',
|
1207
|
+
'props'
|
1208
|
+
);
|
1209
|
+
}
|
1210
|
+
const result = originClickHandler(e, index, this.props);
|
1211
|
+
if (result && result.then) {
|
1212
|
+
result.then(() => {
|
1213
|
+
this.deleteItem(index);
|
1214
|
+
});
|
1215
|
+
} else {
|
1216
|
+
this.deleteItem(index);
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
});
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
// deleteBtn是string,则渲染按钮文本
|
1223
|
+
if (typeof deleteBtn === 'string') {
|
1224
|
+
return render('delete-btn', {
|
1225
|
+
type: 'button',
|
1226
|
+
className: cx('Combo-delController'),
|
1227
|
+
label: deleteBtn,
|
1228
|
+
onClick: this.deleteItem.bind(this, index)
|
1229
|
+
});
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
// 如果上述按钮不满足,则渲染默认按钮
|
1233
|
+
return (
|
1234
|
+
<a
|
1235
|
+
onClick={this.deleteItem.bind(this, index)}
|
1236
|
+
key="delete"
|
1237
|
+
className={cx(`Combo-delBtn ${!store.removable ? 'is-disabled' : ''}`)}
|
1238
|
+
data-tooltip={__('delete')}
|
1239
|
+
data-position="bottom"
|
1240
|
+
>
|
1241
|
+
{deleteIcon ? (
|
1242
|
+
<i className={deleteIcon} />
|
1243
|
+
) : (
|
1244
|
+
<Icon icon="status-close" className="icon" />
|
1245
|
+
)}
|
1246
|
+
</a>
|
1247
|
+
);
|
1248
|
+
}
|
1249
|
+
|
1164
1250
|
renderMultipe() {
|
1165
1251
|
if (this.props.tabsMode) {
|
1166
1252
|
return this.renderTabsMode();
|
@@ -1183,12 +1269,10 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1183
1269
|
addable,
|
1184
1270
|
removable,
|
1185
1271
|
typeSwitchable,
|
1186
|
-
itemRemovableOn,
|
1187
1272
|
delimiter,
|
1188
1273
|
canAccessSuperData,
|
1189
1274
|
addIcon,
|
1190
1275
|
dragIcon,
|
1191
|
-
deleteIcon,
|
1192
1276
|
noBorder,
|
1193
1277
|
conditions,
|
1194
1278
|
lazyLoad,
|
@@ -1206,11 +1290,6 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1206
1290
|
value = value.split(delimiter || ',');
|
1207
1291
|
}
|
1208
1292
|
|
1209
|
-
const finnalRemovable =
|
1210
|
-
store.removable !== false && // minLength ?
|
1211
|
-
!disabled && // 控件自身是否禁用
|
1212
|
-
removable !== false; // 是否可以删除
|
1213
|
-
|
1214
1293
|
return (
|
1215
1294
|
<div
|
1216
1295
|
className={cx(
|
@@ -1226,30 +1305,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1226
1305
|
<div className={cx(`Combo-items`, itemsWrapperClassName)}>
|
1227
1306
|
{Array.isArray(value) && value.length ? (
|
1228
1307
|
value.map((value, index, thelist) => {
|
1229
|
-
let delBtn: any =
|
1230
|
-
|
1231
|
-
if (
|
1232
|
-
finnalRemovable && // 表达式判断单条是否可删除
|
1233
|
-
(!itemRemovableOn ||
|
1234
|
-
evalExpression(itemRemovableOn, value) !== false)
|
1235
|
-
) {
|
1236
|
-
delBtn = (
|
1237
|
-
<Button
|
1238
|
-
key="remove"
|
1239
|
-
className={cx('Combo-delBtn')}
|
1240
|
-
disabled={!store.removable}
|
1241
|
-
tooltip={__('delete')}
|
1242
|
-
tooltipPlacement="bottom"
|
1243
|
-
onClick={this.removeItem.bind(this, index)}
|
1244
|
-
>
|
1245
|
-
{deleteIcon ? (
|
1246
|
-
<i className={deleteIcon} />
|
1247
|
-
) : (
|
1248
|
-
<Icon icon="status-close" className="icon" />
|
1249
|
-
)}
|
1250
|
-
</Button>
|
1251
|
-
);
|
1252
|
-
}
|
1308
|
+
let delBtn: any = this.renderDelBtn(value, index);
|
1253
1309
|
|
1254
1310
|
const data = this.formatValue(value, index);
|
1255
1311
|
let condition: ComboCondition | null = null;
|
@@ -423,8 +423,14 @@ export default class DateControl extends React.PureComponent<
|
|
423
423
|
// 动作
|
424
424
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
425
425
|
const {resetValue, onChange} = this.props;
|
426
|
+
|
426
427
|
if (action.actionType === 'clear') {
|
427
|
-
onChange(
|
428
|
+
onChange('');
|
429
|
+
return;
|
430
|
+
}
|
431
|
+
|
432
|
+
if (action.actionType === 'reset' && resetValue) {
|
433
|
+
onChange(resetValue);
|
428
434
|
}
|
429
435
|
}
|
430
436
|
|
@@ -457,15 +463,23 @@ export default class DateControl extends React.PureComponent<
|
|
457
463
|
useMobileUI,
|
458
464
|
...rest
|
459
465
|
} = this.props;
|
466
|
+
const mobileUI = useMobileUI && isMobile();
|
460
467
|
|
461
468
|
if (type === 'time' && timeFormat) {
|
462
469
|
format = timeFormat;
|
463
470
|
}
|
464
471
|
|
465
|
-
const mobileUI = useMobileUI && isMobile();
|
466
|
-
|
467
472
|
return (
|
468
|
-
<div
|
473
|
+
<div
|
474
|
+
className={cx(
|
475
|
+
`DateControl`,
|
476
|
+
{
|
477
|
+
'is-date': /date$/.test(type),
|
478
|
+
'is-datetime': /datetime$/.test(type)
|
479
|
+
},
|
480
|
+
className
|
481
|
+
)}
|
482
|
+
>
|
469
483
|
<DatePicker
|
470
484
|
{...rest}
|
471
485
|
useMobileUI={useMobileUI}
|
@@ -180,8 +180,14 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|
180
180
|
// 动作
|
181
181
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
182
182
|
const {resetValue, onChange} = this.props;
|
183
|
+
|
183
184
|
if (action.actionType === 'clear') {
|
184
|
-
onChange(
|
185
|
+
onChange('');
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
|
189
|
+
if (action.actionType === 'reset' && resetValue) {
|
190
|
+
onChange(resetValue);
|
185
191
|
}
|
186
192
|
}
|
187
193
|
|
@@ -213,8 +219,19 @@ export default class DateRangeControl extends React.Component<DateRangeProps> {
|
|
213
219
|
...rest
|
214
220
|
} = this.props;
|
215
221
|
const mobileUI = useMobileUI && isMobile();
|
222
|
+
const comptType = this.props?.type;
|
223
|
+
|
216
224
|
return (
|
217
|
-
<div
|
225
|
+
<div
|
226
|
+
className={cx(
|
227
|
+
`${ns}DateRangeControl`,
|
228
|
+
{
|
229
|
+
'is-date': /date-/.test(comptType),
|
230
|
+
'is-datetime': /datetime-/.test(comptType)
|
231
|
+
},
|
232
|
+
className
|
233
|
+
)}
|
234
|
+
>
|
218
235
|
<DateRangePicker
|
219
236
|
{...rest}
|
220
237
|
useMobileUI={useMobileUI}
|
@@ -818,7 +818,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
818
818
|
let value =
|
819
819
|
(ret.data as any).value || (ret.data as any).url || ret.data;
|
820
820
|
|
821
|
-
const dispatcher = await this.dispatchEvent('success',
|
821
|
+
const dispatcher = await this.dispatchEvent('success', {
|
822
|
+
...file,
|
823
|
+
value,
|
824
|
+
state: 'uploaded'
|
825
|
+
});
|
822
826
|
if (dispatcher?.prevented) {
|
823
827
|
return;
|
824
828
|
}
|
@@ -1220,11 +1224,19 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1220
1224
|
|
1221
1225
|
async dispatchEvent(e: string, data?: Record<string, any>) {
|
1222
1226
|
const {dispatchEvent} = this.props;
|
1223
|
-
|
1227
|
+
const getEventData = (item: Record<string, any>) => ({
|
1228
|
+
name: item.path || item.name,
|
1229
|
+
value: item.value,
|
1230
|
+
state: item.state,
|
1231
|
+
error: item.error
|
1232
|
+
});
|
1233
|
+
const value = data
|
1234
|
+
? getEventData(data)
|
1235
|
+
: this.state.files.map(item => getEventData(item));
|
1224
1236
|
return dispatchEvent(
|
1225
1237
|
e,
|
1226
1238
|
createObject(this.props.data, {
|
1227
|
-
file:
|
1239
|
+
file: value
|
1228
1240
|
})
|
1229
1241
|
);
|
1230
1242
|
}
|
@@ -1316,7 +1328,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1316
1328
|
>
|
1317
1329
|
<input disabled={disabled} {...getInputProps()} />
|
1318
1330
|
|
1319
|
-
{drag ? (
|
1331
|
+
{drag || isDragActive ? (
|
1320
1332
|
<div
|
1321
1333
|
className={cx('FileControl-acceptTip')}
|
1322
1334
|
onClick={this.handleSelect}
|
@@ -1081,7 +1081,11 @@ export default class ImageControl extends React.Component<
|
|
1081
1081
|
};
|
1082
1082
|
obj.value = obj.value || obj.url;
|
1083
1083
|
|
1084
|
-
const dispatcher = await this.dispatchEvent('success',
|
1084
|
+
const dispatcher = await this.dispatchEvent('success', {
|
1085
|
+
...file,
|
1086
|
+
value: obj.value,
|
1087
|
+
state: 'uploaded'
|
1088
|
+
});
|
1085
1089
|
if (dispatcher?.prevented) {
|
1086
1090
|
return;
|
1087
1091
|
}
|
@@ -1252,8 +1256,16 @@ export default class ImageControl extends React.Component<
|
|
1252
1256
|
|
1253
1257
|
async dispatchEvent(e: string, data?: Record<string, any>) {
|
1254
1258
|
const {dispatchEvent} = this.props;
|
1255
|
-
|
1256
|
-
|
1259
|
+
const getEventData = (item: Record<string, any>) => ({
|
1260
|
+
name: item.path || item.name,
|
1261
|
+
value: item.value,
|
1262
|
+
state: item.state,
|
1263
|
+
error: item.error
|
1264
|
+
});
|
1265
|
+
const value = data
|
1266
|
+
? getEventData(data)
|
1267
|
+
: this.files.map(item => getEventData(item));
|
1268
|
+
return dispatchEvent(e, createObject(this.props.data, {file: value}));
|
1257
1269
|
}
|
1258
1270
|
|
1259
1271
|
// 动作
|
@@ -170,8 +170,14 @@ export default class MonthRangeControl extends React.Component<MonthRangeProps>
|
|
170
170
|
// 动作
|
171
171
|
doAction(action: Action, data: object, throwErrors: boolean) {
|
172
172
|
const {resetValue, onChange} = this.props;
|
173
|
+
|
173
174
|
if (action.actionType === 'clear') {
|
174
|
-
onChange(
|
175
|
+
onChange('');
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
if (action.actionType === 'reset' && resetValue) {
|
180
|
+
onChange(resetValue);
|
175
181
|
}
|
176
182
|
}
|
177
183
|
|
@@ -179,7 +179,7 @@ export default class TextControl extends React.PureComponent<
|
|
179
179
|
term: ''
|
180
180
|
})
|
181
181
|
);
|
182
|
-
} else {
|
182
|
+
} else if (addHook) {
|
183
183
|
this.unHook = addHook(async (data: any) => {
|
184
184
|
await formItem.loadOptions(
|
185
185
|
autoComplete,
|
@@ -546,6 +546,8 @@ export default class TextControl extends React.PureComponent<
|
|
546
546
|
multiple,
|
547
547
|
creatable,
|
548
548
|
borderMode,
|
549
|
+
showCounter,
|
550
|
+
maxLength,
|
549
551
|
translate: __
|
550
552
|
} = this.props;
|
551
553
|
let type = this.props.type?.replace(/^(?:native|input)\-/, '');
|
@@ -664,6 +666,16 @@ export default class TextControl extends React.PureComponent<
|
|
664
666
|
</a>
|
665
667
|
) : null}
|
666
668
|
|
669
|
+
{showCounter ? (
|
670
|
+
<span className={cx('TextControl-counter')}>
|
671
|
+
{`${this.valueToString(value)?.length}${
|
672
|
+
typeof maxLength === 'number' && maxLength
|
673
|
+
? `/${maxLength}`
|
674
|
+
: ''
|
675
|
+
}`}
|
676
|
+
</span>
|
677
|
+
) : null}
|
678
|
+
|
667
679
|
{loading ? (
|
668
680
|
<Spinner
|
669
681
|
show
|
@@ -832,8 +844,8 @@ export default class TextControl extends React.PureComponent<
|
|
832
844
|
</div>
|
833
845
|
) : (
|
834
846
|
<div className={cx(`${ns}TextControl-addOn`, addOn.className)}>
|
835
|
-
{addOn.label ? filter(addOn.label, data) : null}
|
836
847
|
{iconElement}
|
848
|
+
{addOn.label ? filter(addOn.label, data) : null}
|
837
849
|
</div>
|
838
850
|
)
|
839
851
|
) : null;
|