amis 1.9.1-beta.13 → 1.9.1-beta.19
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/components/Select.js +2 -2
- package/lib/components/Select.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +44 -40
- package/lib/components/formula/Editor.js +16 -5
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.d.ts +88 -41
- package/lib/components/formula/Picker.js +49 -22
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.js +2 -1
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.js +3 -0
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/InputFormula.d.ts +6 -2
- package/lib/renderers/Form/InputFormula.js +4 -3
- package/lib/renderers/Form/InputFormula.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +4 -0
- package/lib/renderers/Form/InputTree.js +2 -2
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Table/index.js +2 -1
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +6 -2
- package/lib/renderers/Tabs.js +21 -0
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/themes/ang-ie11.css +45 -6
- package/lib/themes/ang.css +40 -6
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +45 -6
- package/lib/themes/antd.css +40 -6
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +45 -6
- package/lib/themes/cxd.css +40 -6
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +45 -6
- package/lib/themes/dark.css +40 -6
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +45 -6
- package/lib/themes/default.css +40 -6
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/formula.js +4 -3
- package/lib/utils/formula.js.map +2 -2
- package/package.json +2 -2
- package/schema.json +41 -38
- package/scss/components/_formula.scss +45 -4
- package/scss/components/form/_checks.scss +47 -44
- package/scss/components/form/_select.scss +3 -2
- package/sdk/ang-ie11.css +52 -6
- package/sdk/ang.css +47 -6
- package/sdk/antd-ie11.css +52 -6
- package/sdk/antd.css +47 -6
- 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 +52 -6
- package/sdk/cxd.css +47 -6
- package/sdk/dark-ie11.css +52 -6
- package/sdk/dark.css +47 -6
- package/sdk/exceljs.js +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 +16 -16
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +52 -6
- package/sdk/sdk.css +47 -6
- package/sdk/sdk.js +1339 -1339
- 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/components/Select.tsx +3 -6
- package/src/components/formula/Editor.tsx +51 -23
- package/src/components/formula/Picker.tsx +67 -9
- package/src/locale/zh-CN.ts +1 -1
- package/src/renderers/Action.tsx +2 -1
- package/src/renderers/CRUD.tsx +2 -0
- package/src/renderers/Form/InputFormula.tsx +11 -3
- package/src/renderers/Form/InputTree.tsx +7 -0
- package/src/renderers/Table/index.tsx +9 -7
- package/src/renderers/Tabs.tsx +33 -3
- package/src/utils/formula.ts +5 -3
@@ -778,10 +778,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
778
778
|
})}
|
779
779
|
onClick={this.removeItem.bind(this, index)}
|
780
780
|
>
|
781
|
-
<Icon
|
782
|
-
icon="close"
|
783
|
-
className="icon"
|
784
|
-
/>
|
781
|
+
<Icon icon="close" className="icon" />
|
785
782
|
</span>
|
786
783
|
</div>
|
787
784
|
</TooltipWrapper>
|
@@ -1026,7 +1023,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1026
1023
|
</div>
|
1027
1024
|
) : null}
|
1028
1025
|
|
1029
|
-
<div ref={this.menuItemRef} className={cx('Select-option
|
1026
|
+
<div ref={this.menuItemRef} className={cx('Select-option hidden')}>
|
1030
1027
|
{multiple ? (
|
1031
1028
|
<Checkbox size="sm">Placeholder</Checkbox>
|
1032
1029
|
) : (
|
@@ -1083,7 +1080,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1083
1080
|
overlay
|
1084
1081
|
className={cx('Select-popover')}
|
1085
1082
|
style={{
|
1086
|
-
|
1083
|
+
width: this.target ? this.target.offsetWidth : 'auto'
|
1087
1084
|
}}
|
1088
1085
|
onHide={this.close}
|
1089
1086
|
>
|
@@ -55,6 +55,11 @@ export interface FormulaEditorProps extends ThemeProps, LocaleProps {
|
|
55
55
|
*/
|
56
56
|
variableMode?: 'tabs' | 'tree';
|
57
57
|
|
58
|
+
/**
|
59
|
+
* 只展示变量,不需要其他面板
|
60
|
+
*/
|
61
|
+
onlyVariable?: boolean;
|
62
|
+
|
58
63
|
/**
|
59
64
|
* 函数集合,默认不需要传,即 amis-formula 里面那个函数
|
60
65
|
* 如果有扩充,则需要传。
|
@@ -221,6 +226,19 @@ export class FormulaEditor extends React.Component<
|
|
221
226
|
|
222
227
|
@autobind
|
223
228
|
handleVariableSelect(item: VariableItem) {
|
229
|
+
const {onlyVariable, evalMode} = this.props;
|
230
|
+
|
231
|
+
// 只展示变量时,选择即提交
|
232
|
+
if (onlyVariable) {
|
233
|
+
const onChange = this.props.onChange;
|
234
|
+
const value = item.value
|
235
|
+
? evalMode
|
236
|
+
? item.value
|
237
|
+
: '${' + item.value + '}'
|
238
|
+
: '';
|
239
|
+
return onChange?.(value);
|
240
|
+
}
|
241
|
+
|
224
242
|
this.editorPlugin?.insertContent(
|
225
243
|
{
|
226
244
|
key: item.value,
|
@@ -248,6 +266,7 @@ export class FormulaEditor extends React.Component<
|
|
248
266
|
value,
|
249
267
|
functions,
|
250
268
|
variableMode,
|
269
|
+
onlyVariable,
|
251
270
|
translate: __,
|
252
271
|
classnames: cx,
|
253
272
|
variableClassName,
|
@@ -267,23 +286,30 @@ export class FormulaEditor extends React.Component<
|
|
267
286
|
'is-focused': focused
|
268
287
|
})}
|
269
288
|
>
|
270
|
-
|
271
|
-
<
|
272
|
-
{
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
289
|
+
{onlyVariable ? null : (
|
290
|
+
<section className={cx(`FormulaEditor-content`)}>
|
291
|
+
<header className={cx(`FormulaEditor-header`)}>
|
292
|
+
{__(header || 'FormulaEditor.title')}
|
293
|
+
</header>
|
294
|
+
|
295
|
+
<CodeMirrorEditor
|
296
|
+
className={cx('FormulaEditor-editor')}
|
297
|
+
value={value}
|
298
|
+
onChange={this.handleOnChange}
|
299
|
+
editorFactory={this.editorFactory}
|
300
|
+
editorDidMount={this.handleEditorMounted}
|
301
|
+
onFocus={this.handleFocus}
|
302
|
+
onBlur={this.handleBlur}
|
303
|
+
/>
|
304
|
+
</section>
|
305
|
+
)}
|
306
|
+
|
307
|
+
<section
|
308
|
+
className={cx(
|
309
|
+
'FormulaEditor-settings',
|
310
|
+
onlyVariable ? 'only-variable' : ''
|
311
|
+
)}
|
312
|
+
>
|
287
313
|
<div className={cx('FormulaEditor-panel')}>
|
288
314
|
{variableMode !== 'tabs' ? (
|
289
315
|
<div className={cx('FormulaEditor-panel-header')}>
|
@@ -310,12 +336,14 @@ export class FormulaEditor extends React.Component<
|
|
310
336
|
</div>
|
311
337
|
</div>
|
312
338
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
339
|
+
{onlyVariable ? null : (
|
340
|
+
<FuncList
|
341
|
+
className={functionClassName}
|
342
|
+
title={__('FormulaEditor.function')}
|
343
|
+
data={functionList}
|
344
|
+
onSelect={this.handleFunctionSelect}
|
345
|
+
/>
|
346
|
+
)}
|
319
347
|
</section>
|
320
348
|
</div>
|
321
349
|
);
|
@@ -17,6 +17,7 @@ import {themeable} from '../../theme';
|
|
17
17
|
import {localeable} from '../../locale';
|
18
18
|
import type {SchemaIcon} from '../../Schema';
|
19
19
|
import {parse, Evaluator} from 'amis-formula';
|
20
|
+
import Input from '../Input';
|
20
21
|
|
21
22
|
export interface FormulaPickerProps extends FormulaEditorProps {
|
22
23
|
// 新的属性?
|
@@ -35,13 +36,18 @@ export interface FormulaPickerProps extends FormulaEditorProps {
|
|
35
36
|
/**
|
36
37
|
* 控件模式
|
37
38
|
*/
|
38
|
-
mode?: 'button' | 'input-button';
|
39
|
+
mode?: 'button' | 'input-button' | 'input-group';
|
39
40
|
|
40
41
|
/**
|
41
42
|
* 边框模式,全边框,还是半边框,或者没边框。
|
42
43
|
*/
|
43
44
|
borderMode?: 'full' | 'half' | 'none';
|
44
45
|
|
46
|
+
/**
|
47
|
+
* 只展示变量,不需要其他面板
|
48
|
+
*/
|
49
|
+
onlyVariable?: boolean;
|
50
|
+
|
45
51
|
/**
|
46
52
|
* 按钮Label,inputMode为button时生效
|
47
53
|
*/
|
@@ -132,7 +138,8 @@ export class FormulaPicker extends React.Component<
|
|
132
138
|
}
|
133
139
|
|
134
140
|
static defaultProps = {
|
135
|
-
evalMode: true
|
141
|
+
evalMode: true,
|
142
|
+
onlyVariable: false
|
136
143
|
};
|
137
144
|
|
138
145
|
state: FormulaPickerState = {
|
@@ -173,8 +180,19 @@ export class FormulaPicker extends React.Component<
|
|
173
180
|
this.setState({value}, () => this.handleConfirm());
|
174
181
|
}
|
175
182
|
|
183
|
+
@autobind
|
184
|
+
handleInputGroupChange(e: React.ChangeEvent<HTMLInputElement>) {
|
185
|
+
const onChange = this.props.onChange;
|
186
|
+
onChange && onChange(e.currentTarget.value);
|
187
|
+
}
|
188
|
+
|
176
189
|
@autobind
|
177
190
|
handleEditorChange(value: string) {
|
191
|
+
const {onlyVariable} = this.props;
|
192
|
+
if (onlyVariable) {
|
193
|
+
return this.confirm(value);
|
194
|
+
}
|
195
|
+
|
178
196
|
this.setState({
|
179
197
|
editorValue: value,
|
180
198
|
isError: false
|
@@ -185,6 +203,10 @@ export class FormulaPicker extends React.Component<
|
|
185
203
|
handleEditorConfirm() {
|
186
204
|
const {translate: __} = this.props;
|
187
205
|
const value = this.state.editorValue;
|
206
|
+
this.confirm(value);
|
207
|
+
}
|
208
|
+
|
209
|
+
confirm(value: string) {
|
188
210
|
const validate = this.validate(value);
|
189
211
|
|
190
212
|
if (validate === true) {
|
@@ -274,6 +296,7 @@ export class FormulaPicker extends React.Component<
|
|
274
296
|
functions,
|
275
297
|
children,
|
276
298
|
variableMode,
|
299
|
+
onlyVariable,
|
277
300
|
...rest
|
278
301
|
} = this.props;
|
279
302
|
const {isOpened, value, editorValue, isError} = this.state;
|
@@ -289,8 +312,14 @@ export class FormulaPicker extends React.Component<
|
|
289
312
|
setState: this.updateState
|
290
313
|
})
|
291
314
|
) : (
|
292
|
-
<div
|
293
|
-
{
|
315
|
+
<div
|
316
|
+
className={cx(
|
317
|
+
'FormulaPicker',
|
318
|
+
className,
|
319
|
+
mode === 'input-group' ? 'is-input-group' : ''
|
320
|
+
)}
|
321
|
+
>
|
322
|
+
{mode === 'button' && (
|
294
323
|
<Button
|
295
324
|
className={cx('FormulaPicker-action', 'w-full')}
|
296
325
|
level={level}
|
@@ -319,7 +348,8 @@ export class FormulaPicker extends React.Component<
|
|
319
348
|
{__(btnLabel || 'FormulaEditor.btnLabel')}
|
320
349
|
</span>
|
321
350
|
</Button>
|
322
|
-
)
|
351
|
+
)}
|
352
|
+
{mode === 'input-button' && (
|
323
353
|
<>
|
324
354
|
<ResultBox
|
325
355
|
className={cx(
|
@@ -360,6 +390,29 @@ export class FormulaPicker extends React.Component<
|
|
360
390
|
</Button>
|
361
391
|
</>
|
362
392
|
)}
|
393
|
+
{mode === 'input-group' && (
|
394
|
+
<>
|
395
|
+
<Input
|
396
|
+
className={cx('FormulaPicker-input')}
|
397
|
+
onChange={this.handleInputGroupChange}
|
398
|
+
placeholder={allowInput ? placeholder : ''}
|
399
|
+
autoComplete="off"
|
400
|
+
value={value}
|
401
|
+
disabled={disabled}
|
402
|
+
readOnly={!allowInput}
|
403
|
+
/>
|
404
|
+
|
405
|
+
<a
|
406
|
+
className={cx(`FormulaPicker-toggler`)}
|
407
|
+
onClick={this.handleClick}
|
408
|
+
>
|
409
|
+
<Icon
|
410
|
+
icon={onlyVariable ? 'ellipsis-v' : 'function'}
|
411
|
+
className="icon"
|
412
|
+
/>
|
413
|
+
</a>
|
414
|
+
</>
|
415
|
+
)}
|
363
416
|
</div>
|
364
417
|
)}
|
365
418
|
<Modal
|
@@ -377,6 +430,7 @@ export class FormulaPicker extends React.Component<
|
|
377
430
|
variables={this.state.variables ?? variables}
|
378
431
|
functions={this.state.functions ?? functions}
|
379
432
|
variableMode={this.state.variableMode ?? variableMode}
|
433
|
+
onlyVariable={onlyVariable}
|
380
434
|
value={editorValue}
|
381
435
|
onChange={this.handleEditorChange}
|
382
436
|
/>
|
@@ -389,10 +443,14 @@ export class FormulaPicker extends React.Component<
|
|
389
443
|
</span>
|
390
444
|
</div>
|
391
445
|
) : null}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
446
|
+
{onlyVariable ? null : (
|
447
|
+
<>
|
448
|
+
<Button onClick={this.close}>{__('cancel')}</Button>
|
449
|
+
<Button onClick={this.handleEditorConfirm} level="primary">
|
450
|
+
{__('confirm')}
|
451
|
+
</Button>
|
452
|
+
</>
|
453
|
+
)}
|
396
454
|
</Modal.Footer>
|
397
455
|
</Modal>
|
398
456
|
</>
|
package/src/locale/zh-CN.ts
CHANGED
@@ -202,7 +202,7 @@ register('zh-CN', {
|
|
202
202
|
'Select.clearAll': '移除所有',
|
203
203
|
'Select.createLabel': '新增选项',
|
204
204
|
'Select.placeholder': '请选择',
|
205
|
-
'Select.searchPromptText': '
|
205
|
+
'Select.searchPromptText': '搜索',
|
206
206
|
'sort': '排序',
|
207
207
|
'SubForm.button': '设置',
|
208
208
|
'SubForm.editDetail': '编辑详情',
|
package/src/renderers/Action.tsx
CHANGED
package/src/renderers/CRUD.tsx
CHANGED
@@ -670,6 +670,8 @@ export default class CRUD extends React.Component<CRUDProps, any> {
|
|
670
670
|
throw e;
|
671
671
|
}
|
672
672
|
});
|
673
|
+
} else if (action.actionType === 'reload' && !action.target) {
|
674
|
+
this.reload();
|
673
675
|
} else if (
|
674
676
|
pickerMode &&
|
675
677
|
(action.actionType === 'confirm' || action.actionType === 'submit')
|
@@ -54,7 +54,7 @@ export interface InputFormulaControlSchema extends FormBaseControl {
|
|
54
54
|
/**
|
55
55
|
* 控件模式
|
56
56
|
*/
|
57
|
-
inputMode?: 'button' | 'input-button';
|
57
|
+
inputMode?: 'button' | 'input-button' | 'input-group';
|
58
58
|
|
59
59
|
/**
|
60
60
|
* 外层input是否允许输入,否需要点击fx在弹窗中输入
|
@@ -94,6 +94,11 @@ export interface InputFormulaControlSchema extends FormBaseControl {
|
|
94
94
|
*/
|
95
95
|
borderMode?: 'full' | 'half' | 'none';
|
96
96
|
|
97
|
+
/**
|
98
|
+
* 只展示变量,不需要其他面板
|
99
|
+
*/
|
100
|
+
onlyVariable?: boolean;
|
101
|
+
|
97
102
|
/**
|
98
103
|
* 输入框占位符
|
99
104
|
*/
|
@@ -123,11 +128,12 @@ export interface InputFormulaProps
|
|
123
128
|
export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
|
124
129
|
static defaultProps: Pick<
|
125
130
|
InputFormulaControlSchema,
|
126
|
-
'inputMode' | 'borderMode' | 'evalMode'
|
131
|
+
'inputMode' | 'borderMode' | 'evalMode' | 'onlyVariable'
|
127
132
|
> = {
|
128
133
|
inputMode: 'input-button',
|
129
134
|
borderMode: 'full',
|
130
|
-
evalMode: true
|
135
|
+
evalMode: true,
|
136
|
+
onlyVariable: false
|
131
137
|
};
|
132
138
|
|
133
139
|
ref: any;
|
@@ -162,6 +168,7 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
|
|
162
168
|
onChange,
|
163
169
|
evalMode,
|
164
170
|
variableMode,
|
171
|
+
onlyVariable,
|
165
172
|
header,
|
166
173
|
label,
|
167
174
|
value,
|
@@ -206,6 +213,7 @@ export class InputFormulaRenderer extends React.Component<InputFormulaProps> {
|
|
206
213
|
evalMode={evalMode}
|
207
214
|
variables={variables}
|
208
215
|
variableMode={variableMode}
|
216
|
+
onlyVariable={onlyVariable}
|
209
217
|
functions={functions}
|
210
218
|
header={header || label || ''}
|
211
219
|
borderMode={borderMode}
|
@@ -62,6 +62,11 @@ export interface TreeControlSchema extends FormOptionsControl {
|
|
62
62
|
*/
|
63
63
|
onlyChildren?: boolean;
|
64
64
|
|
65
|
+
/**
|
66
|
+
* 单选时,只运行选择叶子节点
|
67
|
+
*/
|
68
|
+
onlyLeaf?: boolean;
|
69
|
+
|
65
70
|
/**
|
66
71
|
* 顶级节点是否可以创建子节点
|
67
72
|
*/
|
@@ -174,6 +179,7 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
174
179
|
unfoldedLevel,
|
175
180
|
withChildren,
|
176
181
|
onlyChildren,
|
182
|
+
onlyLeaf,
|
177
183
|
loading,
|
178
184
|
hideRoot,
|
179
185
|
rootLabel,
|
@@ -228,6 +234,7 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
228
234
|
unfoldedLevel={unfoldedLevel}
|
229
235
|
withChildren={withChildren}
|
230
236
|
onlyChildren={onlyChildren}
|
237
|
+
onlyLeaf={onlyLeaf}
|
231
238
|
hideRoot={hideRoot}
|
232
239
|
rootLabel={__(rootLabel)}
|
233
240
|
rootValue={rootValue}
|
@@ -972,10 +972,7 @@ export default class Table extends React.Component<TableProps, object> {
|
|
972
972
|
return;
|
973
973
|
}
|
974
974
|
|
975
|
-
onSaveOrder(
|
976
|
-
movedItems,
|
977
|
-
items
|
978
|
-
);
|
975
|
+
onSaveOrder(movedItems, items);
|
979
976
|
}
|
980
977
|
|
981
978
|
syncSelected() {
|
@@ -2300,7 +2297,10 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2300
2297
|
onClick={async () => {
|
2301
2298
|
const {data, dispatchEvent} = this.props;
|
2302
2299
|
|
2303
|
-
const allToggled = !(
|
2300
|
+
const allToggled = !(
|
2301
|
+
store.activeToggaleColumns.length ===
|
2302
|
+
store.toggableColumns.length
|
2303
|
+
);
|
2304
2304
|
const rendererEvent = await dispatchEvent(
|
2305
2305
|
'columnToggled',
|
2306
2306
|
createObject(data, {
|
@@ -2341,9 +2341,11 @@ export default class Table extends React.Component<TableProps, object> {
|
|
2341
2341
|
key={column.index}
|
2342
2342
|
onClick={async () => {
|
2343
2343
|
const {data, dispatchEvent} = this.props;
|
2344
|
-
let columns = store.activeToggaleColumns.map(
|
2344
|
+
let columns = store.activeToggaleColumns.map(
|
2345
|
+
item => item.pristine
|
2346
|
+
);
|
2345
2347
|
if (!column.toggled) {
|
2346
|
-
columns.push(column.pristine)
|
2348
|
+
columns.push(column.pristine);
|
2347
2349
|
} else {
|
2348
2350
|
columns = columns.filter(c => c.name !== column.pristine.name);
|
2349
2351
|
}
|
package/src/renderers/Tabs.tsx
CHANGED
@@ -18,7 +18,8 @@ import {
|
|
18
18
|
BaseSchema,
|
19
19
|
SchemaClassName,
|
20
20
|
SchemaCollection,
|
21
|
-
SchemaIcon
|
21
|
+
SchemaIcon,
|
22
|
+
SchemaExpression
|
22
23
|
} from '../Schema';
|
23
24
|
import {ActionSchema} from './Action';
|
24
25
|
import {filter} from '../utils/tpl';
|
@@ -194,11 +195,16 @@ export interface TabsSchema extends BaseSchema {
|
|
194
195
|
* 自定义增加按钮文案
|
195
196
|
*/
|
196
197
|
addBtnText?: string;
|
198
|
+
|
199
|
+
/**
|
200
|
+
* 默认激活的选项卡,hash值或索引值,支持使用表达式
|
201
|
+
*/
|
202
|
+
activeKey?: SchemaExpression;
|
197
203
|
}
|
198
204
|
|
199
205
|
export interface TabsProps
|
200
206
|
extends RendererProps,
|
201
|
-
Omit<TabsSchema, 'className' | 'contentClassName'> {
|
207
|
+
Omit<TabsSchema, 'className' | 'contentClassName' | 'activeKey'> {
|
202
208
|
activeKey?: string | number;
|
203
209
|
location?: any;
|
204
210
|
tabRender?: (tab: TabSchema, props: TabsProps, index: number) => JSX.Element;
|
@@ -327,6 +333,8 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
327
333
|
componentDidUpdate(preProps: TabsProps, prevState: any) {
|
328
334
|
const props = this.props;
|
329
335
|
let localTabs = this.state.localTabs;
|
336
|
+
const prevActiveKey = tokenize(preProps.defaultActiveKey, preProps.data);
|
337
|
+
const activeKey = tokenize(props.defaultActiveKey, props.data);
|
330
338
|
|
331
339
|
// 响应外部修改 tabs
|
332
340
|
const isTabsModified = isObjectShallowModified(
|
@@ -409,6 +417,26 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
409
417
|
prevKey: undefined,
|
410
418
|
activeKey: (this.activeKey = activeKey)
|
411
419
|
});
|
420
|
+
} else if (prevActiveKey !== activeKey) {
|
421
|
+
if (activeKey == null) {
|
422
|
+
return;
|
423
|
+
}
|
424
|
+
|
425
|
+
let newActivedKey = null;
|
426
|
+
const tab = find(localTabs, item => item.hash === activeKey);
|
427
|
+
|
428
|
+
if (tab) {
|
429
|
+
newActivedKey = tab.hash;
|
430
|
+
} else if (typeof activeKey === 'number' && localTabs[activeKey]) {
|
431
|
+
newActivedKey = activeKey;
|
432
|
+
}
|
433
|
+
|
434
|
+
if (newActivedKey) {
|
435
|
+
this.setState({
|
436
|
+
prevKey: prevActiveKey,
|
437
|
+
activeKey: (this.activeKey = newActivedKey)
|
438
|
+
});
|
439
|
+
}
|
412
440
|
}
|
413
441
|
|
414
442
|
this.autoJumpToNeighbour(this.activeKey);
|
@@ -578,7 +606,9 @@ export default class Tabs extends React.Component<TabsProps, TabsState> {
|
|
578
606
|
}
|
579
607
|
});
|
580
608
|
// 获取激活元素项
|
581
|
-
const tab = localTabs?.find(
|
609
|
+
const tab = localTabs?.find(
|
610
|
+
(item, index) => key === (item.hash ? item.hash : index)
|
611
|
+
);
|
582
612
|
|
583
613
|
const rendererEvent = await dispatchEvent(
|
584
614
|
'change',
|
package/src/utils/formula.ts
CHANGED
@@ -210,12 +210,14 @@ export function registerFormulaExec(execMode: string, formulaExec: Function) {
|
|
210
210
|
|
211
211
|
// 用于判断是否优先使用value。
|
212
212
|
export function isExpression(expression: any): boolean {
|
213
|
-
if (!isString(expression)) {
|
213
|
+
if (!expression || !isString(expression)) {
|
214
214
|
// 非字符串类型,比如:Object、Array类型、boolean、number类型
|
215
215
|
return false;
|
216
216
|
}
|
217
|
-
//
|
218
|
-
|
217
|
+
// 备注1: "\\${xxx}"不作为表达式,至少含一个${xxx}才算是表达式
|
218
|
+
|
219
|
+
// 备注2: safari 不支持 /(?<!\\)(\${).+(\})/.test(expression)
|
220
|
+
return /(^|[^\\])\$\{.+\}/.test(expression);
|
219
221
|
}
|
220
222
|
|
221
223
|
// 用于判断是否需要执行表达式:
|