amis 1.9.1-beta.12 → 1.9.1-beta.21
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/lib/components/AssociatedSelection.d.ts +40 -40
- package/lib/components/Badge.d.ts +1 -1
- package/lib/components/Badge.js.map +1 -1
- package/lib/components/ChainedSelection.d.ts +40 -40
- package/lib/components/GroupedSelection.d.ts +40 -40
- package/lib/components/GroupedSelection.js +3 -2
- package/lib/components/GroupedSelection.js.map +2 -2
- package/lib/components/PickerContainer.d.ts +1 -0
- package/lib/components/PickerContainer.js +4 -4
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/Radios.d.ts +10 -10
- package/lib/components/ResultBox.d.ts +44 -40
- package/lib/components/ResultBox.js +40 -6
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/ResultList.d.ts +43 -53
- package/lib/components/ResultList.js +34 -22
- package/lib/components/ResultList.js.map +2 -2
- package/lib/components/ResultTableList.d.ts +40 -40
- package/lib/components/ResultTableList.js +16 -17
- package/lib/components/ResultTableList.js.map +2 -2
- package/lib/components/ResultTreeList.d.ts +40 -40
- package/lib/components/Select.d.ts +498 -294
- package/lib/components/Select.js +58 -10
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Selection.d.ts +41 -40
- package/lib/components/Selection.js.map +2 -2
- package/lib/components/TableSelection.d.ts +42 -40
- package/lib/components/TableSelection.js +7 -2
- package/lib/components/TableSelection.js.map +2 -2
- package/lib/components/TabsTransfer.d.ts +2 -2
- package/lib/components/TabsTransfer.js.map +1 -1
- package/lib/components/TooltipWrapper.d.ts +1 -1
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +40 -40
- package/lib/components/Transfer.js +1 -1
- package/lib/components/Transfer.js.map +2 -2
- package/lib/components/TransferDropDown.d.ts +43 -40
- package/lib/components/TransferDropDown.js +2 -2
- package/lib/components/TransferDropDown.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +40 -40
- package/lib/components/TreeSelection.js +3 -2
- package/lib/components/TreeSelection.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +45 -41
- package/lib/components/formula/Editor.js +8 -2
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.d.ts +43 -41
- package/lib/components/formula/Picker.js +40 -20
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/formula/VariableList.d.ts +2 -0
- package/lib/components/formula/VariableList.js +15 -5
- package/lib/components/formula/VariableList.js.map +2 -2
- package/lib/components/index.d.ts +3 -1
- package/lib/components/index.js +5 -1
- package/lib/components/index.js.map +2 -2
- package/lib/components/schema-editor/SchemaVariableList.d.ts +1 -0
- package/lib/components/schema-editor/SchemaVariableList.js +2 -2
- package/lib/components/schema-editor/SchemaVariableList.js.map +2 -2
- package/lib/components/schema-editor/SchemaVariableListPicker.d.ts +1 -0
- package/lib/components/schema-editor/SchemaVariableListPicker.js +2 -2
- package/lib/components/schema-editor/SchemaVariableListPicker.js.map +2 -2
- package/lib/components/table/HeadCellFilter.js +4 -1
- package/lib/components/table/HeadCellFilter.js.map +2 -2
- package/lib/components/table/HeadCellSort.js +30 -24
- package/lib/components/table/HeadCellSort.js.map +2 -2
- package/lib/components/table/index.d.ts +6 -3
- package/lib/components/table/index.js +72 -86
- package/lib/components/table/index.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +1 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +1 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +1 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +21 -4
- package/lib/renderers/Action.js +44 -20
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Breadcrumb.js +2 -2
- package/lib/renderers/Breadcrumb.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 +5 -1
- package/lib/renderers/Form/InputFormula.js +2 -2
- package/lib/renderers/Form/InputFormula.js.map +2 -2
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputTag.d.ts +8 -0
- package/lib/renderers/Form/InputTag.js +2 -2
- package/lib/renderers/Form/InputTag.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/Form/Picker.d.ts +1 -1
- package/lib/renderers/Form/Picker.js +38 -23
- package/lib/renderers/Form/Picker.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +19 -0
- package/lib/renderers/Form/Select.js +2 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/Transfer.d.ts +1 -0
- package/lib/renderers/Form/Transfer.js +4 -0
- package/lib/renderers/Form/Transfer.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +10 -10
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/QRCode.d.ts +16 -0
- package/lib/renderers/QRCode.js +25 -1
- package/lib/renderers/QRCode.js.map +2 -2
- package/lib/renderers/Service.js +0 -1
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Steps.d.ts +2 -2
- package/lib/renderers/Steps.js +1 -1
- package/lib/renderers/Steps.js.map +2 -2
- package/lib/renderers/Table/exportExcel.js +50 -36
- package/lib/renderers/Table/exportExcel.js.map +2 -2
- package/lib/renderers/Table/index.js +2 -1
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.d.ts +1 -1
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.js +38 -24
- package/lib/renderers/Table-v2/HeadCellSearchDropdown.js.map +2 -2
- package/lib/renderers/Table-v2/index.d.ts +10 -4
- package/lib/renderers/Table-v2/index.js +109 -58
- package/lib/renderers/Table-v2/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/store/table-v2.d.ts +210 -4
- package/lib/store/table-v2.js +82 -5
- package/lib/store/table-v2.js.map +2 -2
- package/lib/themes/ang-ie11.css +140 -44
- package/lib/themes/ang.css +140 -33
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +140 -44
- package/lib/themes/antd.css +140 -33
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +297 -197
- package/lib/themes/cxd.css +151 -38
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +140 -44
- package/lib/themes/dark.css +140 -33
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +297 -197
- package/lib/themes/default.css +151 -38
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/formula.js +7 -5
- package/lib/utils/formula.js.map +2 -2
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +11 -1
- package/lib/utils/helper.js.map +2 -2
- package/package.json +2 -2
- package/schema.json +103 -35
- package/scss/_properties.scss +11 -6
- package/scss/components/_formula.scss +45 -4
- package/scss/components/_modal.scss +1 -1
- package/scss/components/_result-box.scss +34 -2
- package/scss/components/form/_checks.scss +47 -44
- package/scss/components/form/_date.scss +28 -19
- package/scss/components/form/_icon-picker.scss +10 -6
- package/scss/components/form/_select.scss +77 -34
- package/scss/components/form/_selection.scss +9 -6
- package/scss/components/form/_switch.scss +1 -0
- package/scss/components/form/_text.scss +2 -0
- package/scss/components/form/_transfer.scss +2 -1
- package/scss/themes/_cxd-variables.scss +3 -1
- package/scss/themes/cxd.scss +9 -6
- package/sdk/ang-ie11.css +159 -46
- package/sdk/ang.css +159 -35
- package/sdk/antd-ie11.css +159 -46
- package/sdk/antd.css +159 -35
- 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 +317 -199
- package/sdk/cxd.css +171 -40
- package/sdk/dark-ie11.css +159 -46
- package/sdk/dark.css +159 -35
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +2 -2
- 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 +317 -199
- package/sdk/sdk.css +171 -40
- package/sdk/sdk.js +1353 -1351
- 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/Badge.tsx +1 -1
- package/src/components/GroupedSelection.tsx +3 -2
- package/src/components/PickerContainer.tsx +13 -8
- package/src/components/ResultBox.tsx +95 -11
- package/src/components/ResultList.tsx +48 -51
- package/src/components/ResultTableList.tsx +32 -33
- package/src/components/Select.tsx +138 -17
- package/src/components/Selection.tsx +1 -0
- package/src/components/TableSelection.tsx +15 -8
- package/src/components/TabsTransfer.tsx +2 -2
- package/src/components/TooltipWrapper.tsx +20 -14
- package/src/components/Transfer.tsx +0 -4
- package/src/components/TransferDropDown.tsx +9 -1
- package/src/components/TreeSelection.tsx +2 -1
- package/src/components/formula/Editor.tsx +17 -2
- package/src/components/formula/Picker.tsx +44 -7
- package/src/components/formula/VariableList.tsx +36 -2
- package/src/components/index.tsx +4 -0
- package/src/components/schema-editor/SchemaVariableList.tsx +4 -2
- package/src/components/schema-editor/SchemaVariableListPicker.tsx +4 -1
- package/src/components/table/HeadCellFilter.tsx +4 -1
- package/src/components/table/HeadCellSort.tsx +1 -1
- package/src/components/table/index.tsx +66 -90
- package/src/locale/de-DE.ts +2 -2
- package/src/locale/en-US.ts +2 -2
- package/src/locale/zh-CN.ts +1 -1
- package/src/renderers/Action.tsx +64 -19
- package/src/renderers/Breadcrumb.tsx +11 -12
- package/src/renderers/CRUD.tsx +2 -0
- package/src/renderers/Form/InputFormula.tsx +9 -2
- package/src/renderers/Form/InputImage.tsx +4 -2
- package/src/renderers/Form/InputTag.tsx +14 -0
- package/src/renderers/Form/InputTree.tsx +7 -0
- package/src/renderers/Form/Picker.tsx +11 -1
- package/src/renderers/Form/Select.tsx +32 -1
- package/src/renderers/Form/Transfer.tsx +6 -0
- package/src/renderers/Form/wrapControl.tsx +10 -10
- package/src/renderers/QRCode.tsx +50 -1
- package/src/renderers/Service.tsx +0 -1
- package/src/renderers/Steps.tsx +5 -5
- package/src/renderers/Table/exportExcel.ts +29 -12
- package/src/renderers/Table/index.tsx +9 -7
- package/src/renderers/Table-v2/HeadCellSearchDropdown.tsx +14 -9
- package/src/renderers/Table-v2/index.tsx +130 -58
- package/src/renderers/Tabs.tsx +33 -3
- package/src/store/table-v2.ts +104 -7
- package/src/types.ts +2 -1
- package/src/utils/formula.ts +7 -5
- package/src/utils/helper.ts +12 -2
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
import {uncontrollable} from 'uncontrollable';
|
9
9
|
import React from 'react';
|
10
|
+
import isInteger from 'lodash/isInteger';
|
11
|
+
import omit from 'lodash/omit';
|
10
12
|
import VirtualList from './virtual-list';
|
11
13
|
import Overlay from './Overlay';
|
12
14
|
import PopOver from './PopOver';
|
@@ -24,15 +26,12 @@ import {
|
|
24
26
|
normalizeNodePath,
|
25
27
|
isMobile
|
26
28
|
} from '../utils/helper';
|
27
|
-
import find from 'lodash/find';
|
28
29
|
import isPlainObject from 'lodash/isPlainObject';
|
29
|
-
import union from 'lodash/union';
|
30
30
|
import {highlight} from '../renderers/Form/Options';
|
31
31
|
import {findDOMNode} from 'react-dom';
|
32
32
|
import {ClassNamesFn, themeable, ThemeProps} from '../theme';
|
33
33
|
import Checkbox from './Checkbox';
|
34
34
|
import Input from './Input';
|
35
|
-
import {Api} from '../types';
|
36
35
|
import {LocaleProps, localeable} from '../locale';
|
37
36
|
import Spinner from './Spinner';
|
38
37
|
import {Option, Options} from '../Schema';
|
@@ -40,6 +39,8 @@ import {RemoteOptionsProps, withRemoteConfig} from './WithRemoteConfig';
|
|
40
39
|
import Picker from './Picker';
|
41
40
|
import PopUp from './PopUp';
|
42
41
|
|
42
|
+
import type {TooltipObject} from '../components/TooltipWrapper';
|
43
|
+
|
43
44
|
export {Option, Options};
|
44
45
|
|
45
46
|
export interface OptionProps {
|
@@ -60,6 +61,8 @@ export interface OptionProps {
|
|
60
61
|
disabled?: boolean;
|
61
62
|
creatable?: boolean;
|
62
63
|
pathSeparator?: string;
|
64
|
+
itemHeight?: number; // 每个选项的高度,主要用于虚拟渲染
|
65
|
+
virtualThreshold?: number; // 数据量多大的时候开启虚拟渲染
|
63
66
|
hasError?: boolean;
|
64
67
|
block?: boolean;
|
65
68
|
onAdd?: (
|
@@ -350,6 +353,16 @@ interface SelectProps extends OptionProps, ThemeProps, LocaleProps {
|
|
350
353
|
* 移动端样式类名
|
351
354
|
*/
|
352
355
|
mobileClassName?: string;
|
356
|
+
|
357
|
+
/**
|
358
|
+
* 标签的最大展示数量,超出数量后以收纳浮层的方式展示,仅在多选模式开启后生效
|
359
|
+
*/
|
360
|
+
maxTagCount?: number;
|
361
|
+
|
362
|
+
/**
|
363
|
+
* 收纳标签的Popover配置
|
364
|
+
*/
|
365
|
+
overflowTagPopover?: TooltipObject;
|
353
366
|
}
|
354
367
|
|
355
368
|
interface SelectState {
|
@@ -382,7 +395,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
382
395
|
checkAll: false,
|
383
396
|
checkAllLabel: 'Select.checkAll',
|
384
397
|
defaultCheckAll: false,
|
385
|
-
overlayPlacement: 'auto'
|
398
|
+
overlayPlacement: 'auto',
|
399
|
+
virtualThreshold: 100
|
386
400
|
};
|
387
401
|
|
388
402
|
input: HTMLInputElement;
|
@@ -723,11 +737,11 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
723
737
|
placeholder,
|
724
738
|
labelField,
|
725
739
|
disabled,
|
740
|
+
maxTagCount,
|
741
|
+
overflowTagPopover,
|
726
742
|
translate: __
|
727
743
|
} = this.props;
|
728
|
-
|
729
744
|
const selection = this.state.selection;
|
730
|
-
// console.log('selection', selection);
|
731
745
|
|
732
746
|
if (!selection.length) {
|
733
747
|
return (
|
@@ -737,6 +751,114 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
737
751
|
);
|
738
752
|
}
|
739
753
|
|
754
|
+
if (
|
755
|
+
multiple &&
|
756
|
+
maxTagCount != null &&
|
757
|
+
isInteger(Math.floor(maxTagCount)) &&
|
758
|
+
Math.floor(maxTagCount) >= 0 &&
|
759
|
+
Math.floor(maxTagCount) < selection.length
|
760
|
+
) {
|
761
|
+
const maxVisibleCount = Math.floor(maxTagCount);
|
762
|
+
const tooltipProps: TooltipObject = {
|
763
|
+
placement: 'top',
|
764
|
+
trigger: 'hover',
|
765
|
+
showArrow: false,
|
766
|
+
offset: [0, -10],
|
767
|
+
tooltipClassName: cx(
|
768
|
+
'Select-overflow',
|
769
|
+
overflowTagPopover?.tooltipClassName
|
770
|
+
),
|
771
|
+
...omit(overflowTagPopover, ['children', 'content', 'tooltipClassName'])
|
772
|
+
};
|
773
|
+
return [
|
774
|
+
...selection.slice(0, maxVisibleCount),
|
775
|
+
{label: `+ ${selection.length - maxVisibleCount} ...`}
|
776
|
+
].map((item, index) => {
|
777
|
+
if (index === maxVisibleCount) {
|
778
|
+
return (
|
779
|
+
<TooltipWrapper
|
780
|
+
key={selection.length}
|
781
|
+
tooltip={{
|
782
|
+
...tooltipProps,
|
783
|
+
children: () => (
|
784
|
+
<div className={cx('Select-overflow-wrapper')}>
|
785
|
+
{selection
|
786
|
+
.slice(maxVisibleCount, selection.length)
|
787
|
+
.map((item, index) => {
|
788
|
+
const itemIndex = index + maxVisibleCount;
|
789
|
+
return (
|
790
|
+
<div
|
791
|
+
key={itemIndex}
|
792
|
+
className={cx('Select-value', {
|
793
|
+
'is-disabled': disabled,
|
794
|
+
'is-invalid': item.__unmatched
|
795
|
+
})}
|
796
|
+
>
|
797
|
+
<span className={cx('Select-valueLabel')}>
|
798
|
+
{item[labelField || 'label']}
|
799
|
+
</span>
|
800
|
+
<span
|
801
|
+
className={cx('Select-valueIcon', {
|
802
|
+
'is-disabled': disabled || item.disabled
|
803
|
+
})}
|
804
|
+
onClick={this.removeItem.bind(this, itemIndex)}
|
805
|
+
>
|
806
|
+
<Icon icon="close" className="icon" />
|
807
|
+
</span>
|
808
|
+
</div>
|
809
|
+
);
|
810
|
+
})}
|
811
|
+
</div>
|
812
|
+
)
|
813
|
+
}}
|
814
|
+
>
|
815
|
+
<div
|
816
|
+
className={cx('Select-value', {
|
817
|
+
'is-disabled': disabled,
|
818
|
+
'is-invalid': item.__unmatched
|
819
|
+
})}
|
820
|
+
onClick={(e: React.MouseEvent) =>
|
821
|
+
e.stopPropagation()
|
822
|
+
} /** 避免点击查看浮窗时呼出下拉菜单 */
|
823
|
+
>
|
824
|
+
<span className={cx('Select-valueLabel')}>
|
825
|
+
{item[labelField || 'label']}
|
826
|
+
</span>
|
827
|
+
</div>
|
828
|
+
</TooltipWrapper>
|
829
|
+
);
|
830
|
+
}
|
831
|
+
|
832
|
+
return (
|
833
|
+
<TooltipWrapper
|
834
|
+
placement={'top'}
|
835
|
+
tooltip={item[labelField || 'label']}
|
836
|
+
trigger={'hover'}
|
837
|
+
key={index}
|
838
|
+
>
|
839
|
+
<div
|
840
|
+
className={cx('Select-value', {
|
841
|
+
'is-disabled': disabled,
|
842
|
+
'is-invalid': item.__unmatched
|
843
|
+
})}
|
844
|
+
>
|
845
|
+
<span className={cx('Select-valueLabel')}>
|
846
|
+
{item[labelField || 'label']}
|
847
|
+
</span>
|
848
|
+
<span
|
849
|
+
className={cx('Select-valueIcon', {
|
850
|
+
'is-disabled': disabled || item.disabled
|
851
|
+
})}
|
852
|
+
onClick={this.removeItem.bind(this, index)}
|
853
|
+
>
|
854
|
+
<Icon icon="close" className="icon" />
|
855
|
+
</span>
|
856
|
+
</div>
|
857
|
+
</TooltipWrapper>
|
858
|
+
);
|
859
|
+
});
|
860
|
+
}
|
861
|
+
|
740
862
|
return selection.map((item, index) => {
|
741
863
|
if (!multiple) {
|
742
864
|
return (
|
@@ -778,10 +900,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
778
900
|
})}
|
779
901
|
onClick={this.removeItem.bind(this, index)}
|
780
902
|
>
|
781
|
-
<Icon
|
782
|
-
icon="close"
|
783
|
-
className="icon"
|
784
|
-
/>
|
903
|
+
<Icon icon="close" className="icon" />
|
785
904
|
</span>
|
786
905
|
</div>
|
787
906
|
</TooltipWrapper>
|
@@ -825,6 +944,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
825
944
|
hideSelected,
|
826
945
|
renderMenu,
|
827
946
|
mobileClassName,
|
947
|
+
virtualThreshold = 200,
|
828
948
|
useMobileUI = false
|
829
949
|
} = this.props;
|
830
950
|
const {selection} = this.state;
|
@@ -853,7 +973,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
853
973
|
);
|
854
974
|
}
|
855
975
|
|
856
|
-
|
976
|
+
// 用于虚拟渲染的每项高度
|
977
|
+
const virtualItemHeight = this.props.itemHeight || this.state.itemHeight;
|
857
978
|
|
858
979
|
// 渲染单个选项
|
859
980
|
const renderItem = ({index, style}: {index: number; style?: object}) => {
|
@@ -980,7 +1101,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
980
1101
|
ref={this.menu}
|
981
1102
|
className={cx('Select-menu', {
|
982
1103
|
'Select--longlist':
|
983
|
-
filtedOptions.length && filtedOptions.length >
|
1104
|
+
filtedOptions.length && filtedOptions.length > virtualThreshold,
|
984
1105
|
'is-mobile': mobileUI
|
985
1106
|
})}
|
986
1107
|
>
|
@@ -1026,7 +1147,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1026
1147
|
</div>
|
1027
1148
|
) : null}
|
1028
1149
|
|
1029
|
-
<div ref={this.menuItemRef} className={cx('Select-option
|
1150
|
+
<div ref={this.menuItemRef} className={cx('Select-option hidden')}>
|
1030
1151
|
{multiple ? (
|
1031
1152
|
<Checkbox size="sm">Placeholder</Checkbox>
|
1032
1153
|
) : (
|
@@ -1042,15 +1163,15 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1042
1163
|
) : null}
|
1043
1164
|
|
1044
1165
|
{filtedOptions.length ? (
|
1045
|
-
filtedOptions.length >
|
1166
|
+
filtedOptions.length > virtualThreshold ? ( // 较多数据时才启用 virtuallist,避免滚动条问题
|
1046
1167
|
<VirtualList
|
1047
1168
|
height={
|
1048
1169
|
filtedOptions.length > 8
|
1049
1170
|
? 266
|
1050
|
-
: filtedOptions.length *
|
1171
|
+
: filtedOptions.length * virtualItemHeight
|
1051
1172
|
}
|
1052
1173
|
itemCount={filtedOptions.length}
|
1053
|
-
itemSize={
|
1174
|
+
itemSize={virtualItemHeight}
|
1054
1175
|
renderItem={renderItem}
|
1055
1176
|
/>
|
1056
1177
|
) : (
|
@@ -1083,7 +1204,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
|
|
1083
1204
|
overlay
|
1084
1205
|
className={cx('Select-popover')}
|
1085
1206
|
style={{
|
1086
|
-
|
1207
|
+
width: this.target ? this.target.offsetWidth : 'auto'
|
1087
1208
|
}}
|
1088
1209
|
onHide={this.close}
|
1089
1210
|
>
|
@@ -33,6 +33,7 @@ export interface BaseSelectionProps extends ThemeProps, LocaleProps {
|
|
33
33
|
itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;
|
34
34
|
disabled?: boolean;
|
35
35
|
onClick?: (e: React.MouseEvent) => void;
|
36
|
+
placeholderRender?: (props: any) => JSX.Element | null;
|
36
37
|
}
|
37
38
|
|
38
39
|
export interface ItemRenderStates {
|
@@ -5,9 +5,12 @@ import {uncontrollable} from 'uncontrollable';
|
|
5
5
|
import Checkbox from './Checkbox';
|
6
6
|
import {Option} from './Select';
|
7
7
|
import {resolveVariable} from '../utils/tpl-builtin';
|
8
|
+
import {noop} from '../utils/helper';
|
8
9
|
import {localeable} from '../locale';
|
9
10
|
|
10
11
|
export interface TableSelectionProps extends BaseSelectionProps {
|
12
|
+
/** 是否为结果渲染列表 */
|
13
|
+
resultMode?: boolean;
|
11
14
|
columns: Array<{
|
12
15
|
name: string;
|
13
16
|
label: string;
|
@@ -108,7 +111,8 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
|
|
108
111
|
multiple,
|
109
112
|
option2value,
|
110
113
|
translate: __,
|
111
|
-
itemClassName
|
114
|
+
itemClassName,
|
115
|
+
resultMode
|
112
116
|
} = this.props;
|
113
117
|
const columns = this.getColumns();
|
114
118
|
let valueArray = BaseSelection.value2array(value, options, option2value);
|
@@ -122,6 +126,12 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
|
|
122
126
|
return (
|
123
127
|
<tr
|
124
128
|
key={rowIndex}
|
129
|
+
/** 被ResultTableList引用,如果设置click事件,会导致错误删除结果列表的内容,先加一个开关判断 */
|
130
|
+
onClick={
|
131
|
+
resultMode
|
132
|
+
? noop
|
133
|
+
: e => e.defaultPrevented || this.toggleOption(option)
|
134
|
+
}
|
125
135
|
className={cx(
|
126
136
|
itemClassName,
|
127
137
|
option.className,
|
@@ -130,18 +140,15 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
|
|
130
140
|
)}
|
131
141
|
>
|
132
142
|
{multiple ? (
|
133
|
-
<td
|
143
|
+
<td
|
144
|
+
className={cx('Table-checkCell')}
|
134
145
|
key="checkbox"
|
135
146
|
onClick={e => {
|
136
147
|
e.stopPropagation();
|
137
148
|
this.toggleOption(option);
|
138
149
|
}}
|
139
150
|
>
|
140
|
-
<Checkbox
|
141
|
-
size="sm"
|
142
|
-
checked={checked}
|
143
|
-
disabled={disabled}
|
144
|
-
/>
|
151
|
+
<Checkbox size="sm" checked={checked} disabled={disabled} />
|
145
152
|
</td>
|
146
153
|
) : null}
|
147
154
|
{columns.map((column, colIndex) => (
|
@@ -183,4 +190,4 @@ export default themeable(
|
|
183
190
|
value: 'onChange'
|
184
191
|
})
|
185
192
|
)
|
186
|
-
);
|
193
|
+
);
|
@@ -45,8 +45,8 @@ export interface TabsTransferProps
|
|
45
45
|
colIndex: number,
|
46
46
|
rowIndex: number
|
47
47
|
) => JSX.Element;
|
48
|
-
onTabChange
|
49
|
-
activeKey
|
48
|
+
onTabChange?: (key: number) => void;
|
49
|
+
activeKey?: number
|
50
50
|
}
|
51
51
|
|
52
52
|
export interface TabsTransferState {
|
@@ -63,7 +63,7 @@ export interface TooltipObject {
|
|
63
63
|
/**
|
64
64
|
* 浮层内容可通过JSX渲染
|
65
65
|
*/
|
66
|
-
children?: () => JSX.Element
|
66
|
+
children?: () => JSX.Element;
|
67
67
|
/**
|
68
68
|
* 挂载容器元素
|
69
69
|
*/
|
@@ -98,7 +98,7 @@ export interface TooltipWrapperProps {
|
|
98
98
|
/**
|
99
99
|
* 显示&隐藏时触发
|
100
100
|
*/
|
101
|
-
|
101
|
+
onVisibleChange?: (visible: boolean) => void;
|
102
102
|
}
|
103
103
|
|
104
104
|
interface TooltipWrapperState {
|
@@ -153,25 +153,31 @@ export class TooltipWrapper extends React.Component<
|
|
153
153
|
}
|
154
154
|
|
155
155
|
show() {
|
156
|
-
this.setState(
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
this.setState(
|
157
|
+
{
|
158
|
+
show: true
|
159
|
+
},
|
160
|
+
() => {
|
161
|
+
if (this.props.onVisibleChange) {
|
162
|
+
this.props.onVisibleChange(true);
|
163
|
+
}
|
161
164
|
}
|
162
|
-
|
165
|
+
);
|
163
166
|
}
|
164
167
|
|
165
168
|
hide() {
|
166
169
|
waitToHide = null;
|
167
170
|
this.moutned &&
|
168
|
-
this.setState(
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
this.setState(
|
172
|
+
{
|
173
|
+
show: false
|
174
|
+
},
|
175
|
+
() => {
|
176
|
+
if (this.props.onVisibleChange) {
|
177
|
+
this.props.onVisibleChange(false);
|
178
|
+
}
|
173
179
|
}
|
174
|
-
|
180
|
+
);
|
175
181
|
}
|
176
182
|
|
177
183
|
getChildProps() {
|
@@ -664,10 +664,6 @@ export class Transfer<
|
|
664
664
|
onChange={onChange}
|
665
665
|
placeholder={placeholder}
|
666
666
|
itemRender={resultItemRender}
|
667
|
-
columns={columns!}
|
668
|
-
options={options || []}
|
669
|
-
option2value={option2value}
|
670
|
-
cellRender={cellRender}
|
671
667
|
searchable={searchable}
|
672
668
|
onSearch={onResultSearch}
|
673
669
|
/>
|
@@ -9,6 +9,8 @@ import InputBox from './InputBox';
|
|
9
9
|
import PopOverContainer from './PopOverContainer';
|
10
10
|
import {isMobile} from '../utils/helper';
|
11
11
|
|
12
|
+
import type {TooltipObject} from './TooltipWrapper';
|
13
|
+
|
12
14
|
export interface TransferDropDownProps extends TransferProps {
|
13
15
|
// 新的属性?
|
14
16
|
multiple?: boolean;
|
@@ -16,6 +18,8 @@ export interface TransferDropDownProps extends TransferProps {
|
|
16
18
|
useMobileUI?: boolean;
|
17
19
|
popOverContainer?: any;
|
18
20
|
itemRender: (value: any) => JSX.Element | string;
|
21
|
+
maxTagCount?: number;
|
22
|
+
overflowTagPopover?: TooltipObject;
|
19
23
|
}
|
20
24
|
|
21
25
|
export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
@@ -33,7 +37,9 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
33
37
|
multiple,
|
34
38
|
borderMode,
|
35
39
|
useMobileUI,
|
36
|
-
popOverContainer
|
40
|
+
popOverContainer,
|
41
|
+
maxTagCount,
|
42
|
+
overflowTagPopover
|
37
43
|
} = this.props;
|
38
44
|
const {inputValue, searchResult} = this.state;
|
39
45
|
|
@@ -109,6 +115,8 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
109
115
|
placeholder={__('Select.placeholder')}
|
110
116
|
disabled={disabled}
|
111
117
|
clearable={clearable}
|
118
|
+
maxTagCount={maxTagCount}
|
119
|
+
overflowTagPopover={overflowTagPopover}
|
112
120
|
ref={ref}
|
113
121
|
itemRender={itemRender}
|
114
122
|
useMobileUI={useMobileUI}
|
@@ -282,6 +282,7 @@ export class TreeSelection extends BaseSelection<
|
|
282
282
|
placeholder,
|
283
283
|
classnames: cx,
|
284
284
|
option2value,
|
285
|
+
placeholderRender,
|
285
286
|
translate: __
|
286
287
|
} = this.props;
|
287
288
|
|
@@ -298,7 +299,7 @@ export class TreeSelection extends BaseSelection<
|
|
298
299
|
body
|
299
300
|
) : (
|
300
301
|
<div className={cx('TreeSelection-placeholder')}>
|
301
|
-
{__(placeholder)}
|
302
|
+
{placeholderRender?.(this.props) ?? __(placeholder)}
|
302
303
|
</div>
|
303
304
|
)}
|
304
305
|
</div>
|
@@ -13,12 +13,13 @@ import CodeMirrorEditor from '../CodeMirror';
|
|
13
13
|
import {autobind, eachTree} from '../../utils/helper';
|
14
14
|
import {themeable, ThemeProps} from '../../theme';
|
15
15
|
import {localeable, LocaleProps} from '../../locale';
|
16
|
+
import {toast} from '../Toast';
|
16
17
|
|
17
18
|
export interface VariableItem {
|
18
19
|
label: string;
|
19
20
|
value?: string;
|
20
21
|
children?: Array<VariableItem>;
|
21
|
-
type
|
22
|
+
type?: string;
|
22
23
|
tag?: string;
|
23
24
|
selectMode?: 'tree' | 'tabs';
|
24
25
|
}
|
@@ -69,6 +70,11 @@ export interface FormulaEditorProps extends ThemeProps, LocaleProps {
|
|
69
70
|
variableClassName?: string;
|
70
71
|
|
71
72
|
functionClassName?: string;
|
73
|
+
|
74
|
+
/**
|
75
|
+
* 当前输入项字段 name: 用于避免循环绑定自身导致无限渲染
|
76
|
+
*/
|
77
|
+
selfVariableName?: string;
|
72
78
|
}
|
73
79
|
|
74
80
|
export interface FunctionsProps {
|
@@ -221,6 +227,13 @@ export class FormulaEditor extends React.Component<
|
|
221
227
|
|
222
228
|
@autobind
|
223
229
|
handleVariableSelect(item: VariableItem) {
|
230
|
+
const {evalMode, selfVariableName} = this.props;
|
231
|
+
|
232
|
+
if (item && item.label && selfVariableName === item.label) {
|
233
|
+
toast.warning('不能使用当前变量[self],避免循环引用。');
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
224
237
|
this.editorPlugin?.insertContent(
|
225
238
|
{
|
226
239
|
key: item.value,
|
@@ -252,7 +265,8 @@ export class FormulaEditor extends React.Component<
|
|
252
265
|
classnames: cx,
|
253
266
|
variableClassName,
|
254
267
|
functionClassName,
|
255
|
-
classPrefix
|
268
|
+
classPrefix,
|
269
|
+
selfVariableName
|
256
270
|
} = this.props;
|
257
271
|
const {focused} = this.state;
|
258
272
|
const customFunctions = Array.isArray(functions) ? functions : [];
|
@@ -306,6 +320,7 @@ export class FormulaEditor extends React.Component<
|
|
306
320
|
selectMode={variableMode}
|
307
321
|
data={variables!}
|
308
322
|
onSelect={this.handleVariableSelect}
|
323
|
+
selfVariableName={selfVariableName}
|
309
324
|
/>
|
310
325
|
</div>
|
311
326
|
</div>
|
@@ -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,7 +36,7 @@ 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
|
* 边框模式,全边框,还是半边框,或者没边框。
|
@@ -173,6 +174,12 @@ export class FormulaPicker extends React.Component<
|
|
173
174
|
this.setState({value}, () => this.handleConfirm());
|
174
175
|
}
|
175
176
|
|
177
|
+
@autobind
|
178
|
+
handleInputGroupChange(e: React.ChangeEvent<HTMLInputElement>) {
|
179
|
+
const onChange = this.props.onChange;
|
180
|
+
onChange && onChange(e.currentTarget.value);
|
181
|
+
}
|
182
|
+
|
176
183
|
@autobind
|
177
184
|
handleEditorChange(value: string) {
|
178
185
|
this.setState({
|
@@ -185,6 +192,10 @@ export class FormulaPicker extends React.Component<
|
|
185
192
|
handleEditorConfirm() {
|
186
193
|
const {translate: __} = this.props;
|
187
194
|
const value = this.state.editorValue;
|
195
|
+
this.confirm(value);
|
196
|
+
}
|
197
|
+
|
198
|
+
confirm(value: string) {
|
188
199
|
const validate = this.validate(value);
|
189
200
|
|
190
201
|
if (validate === true) {
|
@@ -237,13 +248,11 @@ export class FormulaPicker extends React.Component<
|
|
237
248
|
const {translate: __} = this.props;
|
238
249
|
|
239
250
|
try {
|
240
|
-
|
251
|
+
parse(value, {
|
241
252
|
evalMode: this.props.evalMode,
|
242
253
|
allowFilter: false
|
243
254
|
});
|
244
255
|
|
245
|
-
new Evaluator({}).evalute(ast);
|
246
|
-
|
247
256
|
return true;
|
248
257
|
} catch (e) {
|
249
258
|
if (/\s(\d+:\d+)$/.test(e.message)) {
|
@@ -291,8 +300,14 @@ export class FormulaPicker extends React.Component<
|
|
291
300
|
setState: this.updateState
|
292
301
|
})
|
293
302
|
) : (
|
294
|
-
<div
|
295
|
-
{
|
303
|
+
<div
|
304
|
+
className={cx(
|
305
|
+
'FormulaPicker',
|
306
|
+
className,
|
307
|
+
mode === 'input-group' ? 'is-input-group' : ''
|
308
|
+
)}
|
309
|
+
>
|
310
|
+
{mode === 'button' && (
|
296
311
|
<Button
|
297
312
|
className={cx('FormulaPicker-action', 'w-full')}
|
298
313
|
level={level}
|
@@ -321,7 +336,8 @@ export class FormulaPicker extends React.Component<
|
|
321
336
|
{__(btnLabel || 'FormulaEditor.btnLabel')}
|
322
337
|
</span>
|
323
338
|
</Button>
|
324
|
-
)
|
339
|
+
)}
|
340
|
+
{mode === 'input-button' && (
|
325
341
|
<>
|
326
342
|
<ResultBox
|
327
343
|
className={cx(
|
@@ -362,6 +378,26 @@ export class FormulaPicker extends React.Component<
|
|
362
378
|
</Button>
|
363
379
|
</>
|
364
380
|
)}
|
381
|
+
{mode === 'input-group' && (
|
382
|
+
<>
|
383
|
+
<Input
|
384
|
+
className={cx('FormulaPicker-input')}
|
385
|
+
onChange={this.handleInputGroupChange}
|
386
|
+
placeholder={allowInput ? placeholder : ''}
|
387
|
+
autoComplete="off"
|
388
|
+
value={value}
|
389
|
+
disabled={disabled}
|
390
|
+
readOnly={!allowInput}
|
391
|
+
/>
|
392
|
+
|
393
|
+
<a
|
394
|
+
className={cx(`FormulaPicker-toggler`)}
|
395
|
+
onClick={this.handleClick}
|
396
|
+
>
|
397
|
+
<Icon icon="function" className="icon" />
|
398
|
+
</a>
|
399
|
+
</>
|
400
|
+
)}
|
365
401
|
</div>
|
366
402
|
)}
|
367
403
|
<Modal
|
@@ -381,6 +417,7 @@ export class FormulaPicker extends React.Component<
|
|
381
417
|
variableMode={this.state.variableMode ?? variableMode}
|
382
418
|
value={editorValue}
|
383
419
|
onChange={this.handleEditorChange}
|
420
|
+
selfVariableName={this.props.selfVariableName}
|
384
421
|
/>
|
385
422
|
</Modal.Body>
|
386
423
|
<Modal.Footer>
|