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
package/src/components/Badge.tsx
CHANGED
@@ -89,7 +89,8 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
|
|
89
89
|
placeholder,
|
90
90
|
classnames: cx,
|
91
91
|
option2value,
|
92
|
-
onClick
|
92
|
+
onClick,
|
93
|
+
placeholderRender
|
93
94
|
} = this.props;
|
94
95
|
const __ = this.props.translate;
|
95
96
|
|
@@ -106,7 +107,7 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
|
|
106
107
|
body
|
107
108
|
) : (
|
108
109
|
<div className={cx('GroupedSelection-placeholder')}>
|
109
|
-
{__(placeholder)}
|
110
|
+
{placeholderRender?.(this.props) ?? __(placeholder)}
|
110
111
|
</div>
|
111
112
|
)}
|
112
113
|
</div>
|
@@ -11,6 +11,7 @@ import Button from './Button';
|
|
11
11
|
export interface PickerContainerProps extends ThemeProps, LocaleProps {
|
12
12
|
title?: string;
|
13
13
|
showTitle?: boolean;
|
14
|
+
showFooter?: boolean;
|
14
15
|
headerClassName?: string;
|
15
16
|
children: (props: {
|
16
17
|
onClick: (e: React.MouseEvent) => void;
|
@@ -131,7 +132,8 @@ export class PickerContainer extends React.Component<
|
|
131
132
|
showTitle,
|
132
133
|
headerClassName,
|
133
134
|
translate: __,
|
134
|
-
size
|
135
|
+
size,
|
136
|
+
showFooter
|
135
137
|
} = this.props;
|
136
138
|
return (
|
137
139
|
<>
|
@@ -158,15 +160,18 @@ export class PickerContainer extends React.Component<
|
|
158
160
|
ref: this.bodyRef,
|
159
161
|
setState: this.updateState,
|
160
162
|
onClose: this.close,
|
161
|
-
onChange: this.handleChange
|
163
|
+
onChange: this.handleChange,
|
164
|
+
onConfirm: this.confirm
|
162
165
|
})}
|
163
166
|
</Modal.Body>
|
164
|
-
|
165
|
-
<
|
166
|
-
|
167
|
-
{
|
168
|
-
|
169
|
-
|
167
|
+
{showFooter ?? true ? (
|
168
|
+
<Modal.Footer>
|
169
|
+
<Button onClick={this.close}>{__('cancel')}</Button>
|
170
|
+
<Button onClick={this.confirm} level="primary">
|
171
|
+
{__('confirm')}
|
172
|
+
</Button>
|
173
|
+
</Modal.Footer>
|
174
|
+
) : null}
|
170
175
|
</Modal>
|
171
176
|
</>
|
172
177
|
);
|
@@ -1,11 +1,14 @@
|
|
1
1
|
import {ThemeProps, themeable} from '../theme';
|
2
2
|
import React from 'react';
|
3
|
+
import omit from 'lodash/omit';
|
4
|
+
import isInteger from 'lodash/isInteger';
|
3
5
|
import {InputBoxProps} from './InputBox';
|
4
6
|
import {uncontrollable} from 'uncontrollable';
|
5
7
|
import {Icon} from './icons';
|
6
8
|
import Input from './Input';
|
7
9
|
import {autobind, isMobile, ucFirst} from '../utils/helper';
|
8
10
|
import {LocaleProps, localeable} from '../locale';
|
11
|
+
import TooltipWrapper, {TooltipObject} from './TooltipWrapper';
|
9
12
|
import isPlainObject = require('lodash/isPlainObject');
|
10
13
|
|
11
14
|
export interface ResultBoxProps
|
@@ -22,6 +25,8 @@ export interface ResultBoxProps
|
|
22
25
|
inputPlaceholder: string;
|
23
26
|
useMobileUI?: boolean;
|
24
27
|
hasDropDownArrow?: boolean;
|
28
|
+
maxTagCount?: number;
|
29
|
+
overflowTagPopover?: TooltipObject;
|
25
30
|
}
|
26
31
|
|
27
32
|
export class ResultBox extends React.Component<ResultBoxProps> {
|
@@ -94,6 +99,91 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
94
99
|
onChange?.(e.currentTarget.value);
|
95
100
|
}
|
96
101
|
|
102
|
+
renderMultipeTags(tags: any[]) {
|
103
|
+
const {
|
104
|
+
maxTagCount,
|
105
|
+
overflowTagPopover,
|
106
|
+
itemRender,
|
107
|
+
classnames: cx
|
108
|
+
} = this.props;
|
109
|
+
|
110
|
+
if (
|
111
|
+
maxTagCount != null &&
|
112
|
+
isInteger(Math.floor(maxTagCount)) &&
|
113
|
+
Math.floor(maxTagCount) >= 0 &&
|
114
|
+
Math.floor(maxTagCount) < tags.length
|
115
|
+
) {
|
116
|
+
const maxVisibleCount = Math.floor(maxTagCount);
|
117
|
+
const tooltipProps: TooltipObject = {
|
118
|
+
placement: 'top',
|
119
|
+
trigger: 'hover',
|
120
|
+
showArrow: false,
|
121
|
+
offset: [0, -10],
|
122
|
+
tooltipClassName: cx(
|
123
|
+
'ResultBox-overflow',
|
124
|
+
overflowTagPopover?.tooltipClassName
|
125
|
+
),
|
126
|
+
...omit(overflowTagPopover, ['children', 'content', 'tooltipClassName'])
|
127
|
+
};
|
128
|
+
|
129
|
+
return [
|
130
|
+
...tags.slice(0, maxVisibleCount),
|
131
|
+
{label: `+ ${tags.length - maxVisibleCount} ...`}
|
132
|
+
].map((item, index) => {
|
133
|
+
return index === maxVisibleCount ? (
|
134
|
+
<TooltipWrapper
|
135
|
+
key={tags.length}
|
136
|
+
tooltip={{
|
137
|
+
...tooltipProps,
|
138
|
+
children: () => (
|
139
|
+
<div className={cx('ResultBox-overflow-wrapper')}>
|
140
|
+
{tags
|
141
|
+
.slice(maxVisibleCount, tags.length)
|
142
|
+
.map((item, index) => {
|
143
|
+
const itemIndex = index + maxVisibleCount;
|
144
|
+
|
145
|
+
return (
|
146
|
+
<div className={cx('ResultBox-value')} key={itemIndex}>
|
147
|
+
<span className={cx('ResultBox-valueLabel')}>
|
148
|
+
{itemRender(item)}
|
149
|
+
</span>
|
150
|
+
<a data-index={itemIndex} onClick={this.removeItem}>
|
151
|
+
<Icon icon="close" className="icon" />
|
152
|
+
</a>
|
153
|
+
</div>
|
154
|
+
);
|
155
|
+
})}
|
156
|
+
</div>
|
157
|
+
)
|
158
|
+
}}
|
159
|
+
>
|
160
|
+
<div className={cx('ResultBox-value')} key={index}>
|
161
|
+
<span className={cx('ResultBox-valueLabel')}>{item.label}</span>
|
162
|
+
</div>
|
163
|
+
</TooltipWrapper>
|
164
|
+
) : (
|
165
|
+
<div className={cx('ResultBox-value')} key={index}>
|
166
|
+
<span className={cx('ResultBox-valueLabel')}>
|
167
|
+
{itemRender(item)}
|
168
|
+
</span>
|
169
|
+
<a data-index={index} onClick={this.removeItem}>
|
170
|
+
<Icon icon="close" className="icon" />
|
171
|
+
</a>
|
172
|
+
</div>
|
173
|
+
);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
|
177
|
+
return tags.map((item, index) => (
|
178
|
+
<div className={cx('ResultBox-value')} key={index}>
|
179
|
+
<span className={cx('ResultBox-valueLabel')}>{itemRender(item)}</span>
|
180
|
+
<a data-index={index} onClick={this.removeItem}>
|
181
|
+
<Icon icon="close" className="icon" />
|
182
|
+
</a>
|
183
|
+
</div>
|
184
|
+
));
|
185
|
+
}
|
186
|
+
|
97
187
|
render() {
|
98
188
|
const {
|
99
189
|
className,
|
@@ -125,6 +215,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
125
215
|
} = this.props;
|
126
216
|
const isFocused = this.state.isFocused;
|
127
217
|
const mobileUI = useMobileUI && isMobile();
|
218
|
+
|
128
219
|
return (
|
129
220
|
<div
|
130
221
|
className={cx('ResultBox', className, {
|
@@ -144,16 +235,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
144
235
|
onBlur={allowInput ? undefined : onBlur}
|
145
236
|
>
|
146
237
|
{Array.isArray(result) && result.length ? (
|
147
|
-
|
148
|
-
<div className={cx('ResultBox-value')} key={index}>
|
149
|
-
<span className={cx('ResultBox-valueLabel')}>
|
150
|
-
{itemRender(item)}
|
151
|
-
</span>
|
152
|
-
<a data-index={index} onClick={this.removeItem}>
|
153
|
-
<Icon icon="close" className="icon" />
|
154
|
-
</a>
|
155
|
-
</div>
|
156
|
-
))
|
238
|
+
this.renderMultipeTags(result)
|
157
239
|
) : result && !Array.isArray(result) ? (
|
158
240
|
<span className={cx('ResultBox-singleValue')}>
|
159
241
|
{isPlainObject(result) ? itemRender(result) : result}
|
@@ -174,7 +256,9 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
174
256
|
placeholder={__(
|
175
257
|
Array.isArray(result) && result.length
|
176
258
|
? inputPlaceholder
|
177
|
-
:
|
259
|
+
: result
|
260
|
+
? ''
|
261
|
+
: placeholder
|
178
262
|
)}
|
179
263
|
onFocus={this.handleFocus}
|
180
264
|
onBlur={this.handleBlur}
|
@@ -4,19 +4,16 @@
|
|
4
4
|
import React from 'react';
|
5
5
|
import Sortable from 'sortablejs';
|
6
6
|
import {findDOMNode} from 'react-dom';
|
7
|
+
import {cloneDeep} from 'lodash';
|
7
8
|
|
8
9
|
import {Option, Options} from './Select';
|
9
10
|
import {ThemeProps, themeable} from '../theme';
|
10
11
|
import {Icon} from './icons';
|
11
12
|
import {autobind, guid} from '../utils/helper';
|
12
13
|
import {LocaleProps, localeable} from '../locale';
|
13
|
-
import {BaseSelection, BaseSelectionProps} from './Selection';
|
14
14
|
import TransferSearch from './TransferSearch';
|
15
15
|
|
16
|
-
export interface ResultListProps
|
17
|
-
extends ThemeProps,
|
18
|
-
LocaleProps,
|
19
|
-
BaseSelectionProps {
|
16
|
+
export interface ResultListProps extends ThemeProps, LocaleProps {
|
20
17
|
className?: string;
|
21
18
|
value?: Array<Option>;
|
22
19
|
onChange?: (value: Array<Option>, optionModified?: boolean) => void;
|
@@ -26,23 +23,9 @@ export interface ResultListProps
|
|
26
23
|
placeholder: string;
|
27
24
|
itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;
|
28
25
|
itemClassName?: string;
|
29
|
-
columns: Array<{
|
30
|
-
name: string;
|
31
|
-
label: string;
|
32
|
-
[propName: string]: any;
|
33
|
-
}>;
|
34
|
-
cellRender?: (
|
35
|
-
column: {
|
36
|
-
name: string;
|
37
|
-
label: string;
|
38
|
-
[propName: string]: any;
|
39
|
-
},
|
40
|
-
option: Option,
|
41
|
-
colIndex: number,
|
42
|
-
rowIndex: number
|
43
|
-
) => JSX.Element;
|
44
26
|
searchable?: boolean;
|
45
27
|
onSearch?: Function;
|
28
|
+
valueField?: string;
|
46
29
|
}
|
47
30
|
|
48
31
|
export interface ItemRenderStates {
|
@@ -59,15 +42,11 @@ export class ResultList extends React.Component<
|
|
59
42
|
ResultListProps,
|
60
43
|
ResultListState
|
61
44
|
> {
|
62
|
-
|
63
45
|
static itemRender(option: any) {
|
64
46
|
return <span>{`${option.scopeLabel || ''}${option.label}`}</span>;
|
65
47
|
}
|
66
48
|
|
67
|
-
static defaultProps: Pick<
|
68
|
-
ResultListProps,
|
69
|
-
'placeholder' | 'itemRender'
|
70
|
-
> = {
|
49
|
+
static defaultProps: Pick<ResultListProps, 'placeholder' | 'itemRender'> = {
|
71
50
|
placeholder: 'placeholder.selectData',
|
72
51
|
itemRender: ResultList.itemRender
|
73
52
|
};
|
@@ -172,43 +151,60 @@ export class ResultList extends React.Component<
|
|
172
151
|
const searchResult = (value || []).filter(
|
173
152
|
item => onSearch && onSearch(inputValue, item)
|
174
153
|
);
|
175
|
-
this.setState({searchResult})
|
154
|
+
this.setState({searchResult});
|
176
155
|
}
|
177
156
|
|
178
157
|
@autobind
|
179
158
|
clearSearch() {
|
180
|
-
this.setState({searchResult: null})
|
159
|
+
this.setState({searchResult: null});
|
181
160
|
}
|
182
161
|
|
183
|
-
//
|
162
|
+
// 删除项
|
184
163
|
@autobind
|
185
|
-
handleCloseItem(option: Option) {
|
186
|
-
const {
|
164
|
+
handleCloseItem(e: React.MouseEvent<HTMLElement>, option: Option) {
|
165
|
+
const {
|
166
|
+
value,
|
167
|
+
onChange,
|
168
|
+
disabled,
|
169
|
+
searchable,
|
170
|
+
valueField = 'value'
|
171
|
+
} = this.props;
|
187
172
|
|
188
173
|
if (disabled || option.disabled) {
|
189
174
|
return;
|
190
175
|
}
|
191
176
|
|
192
|
-
// 删除普通值
|
193
|
-
let valueArray = BaseSelection.value2array(value, options, option2value);
|
194
|
-
|
195
|
-
let idx = valueArray.indexOf(option);
|
196
|
-
valueArray.splice(idx, 1);
|
197
|
-
let newValue: string | Array<Option> = option2value
|
198
|
-
? valueArray.map(item => option2value(item))
|
199
|
-
: valueArray;
|
200
|
-
onChange && onChange(newValue);
|
201
|
-
|
202
177
|
const {searchResult} = this.state;
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
178
|
+
// 结果搜索
|
179
|
+
if (searchable && searchResult) {
|
180
|
+
// 删除普通值
|
181
|
+
const valueArray = cloneDeep(value) || [];
|
182
|
+
const idx = valueArray.findIndex(
|
183
|
+
(item: Option) => item[valueField] === option[valueField]
|
208
184
|
);
|
209
|
-
|
210
|
-
|
211
|
-
|
185
|
+
if (idx > -1) {
|
186
|
+
valueArray.splice(idx, 1);
|
187
|
+
onChange && onChange(valueArray);
|
188
|
+
}
|
189
|
+
// 删除搜索结果
|
190
|
+
const searchIdx = parseInt(e.currentTarget.getAttribute('data-index')!, 10);
|
191
|
+
if (searchIdx > -1) {
|
192
|
+
searchResult.splice(searchIdx, 1);
|
193
|
+
this.setState({searchResult});
|
194
|
+
}
|
195
|
+
}
|
196
|
+
// 没有搜索,走旧的删除方式
|
197
|
+
else {
|
198
|
+
const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);
|
199
|
+
const {value, onChange} = this.props;
|
200
|
+
|
201
|
+
if (!Array.isArray(value)) {
|
202
|
+
return;
|
203
|
+
}
|
204
|
+
|
205
|
+
const newValue = value.concat();
|
206
|
+
newValue.splice(index, 1);
|
207
|
+
onChange?.(newValue);
|
212
208
|
}
|
213
209
|
}
|
214
210
|
|
@@ -256,7 +252,7 @@ export class ResultList extends React.Component<
|
|
256
252
|
className={cx('Selections-delBtn')}
|
257
253
|
data-index={index}
|
258
254
|
onClick={(e: React.MouseEvent<HTMLElement>) =>
|
259
|
-
this.handleCloseItem(option)
|
255
|
+
this.handleCloseItem(e, option)
|
260
256
|
}
|
261
257
|
>
|
262
258
|
<Icon icon="close" className="icon" />
|
@@ -265,8 +261,9 @@ export class ResultList extends React.Component<
|
|
265
261
|
</div>
|
266
262
|
))}
|
267
263
|
</div>
|
268
|
-
) :
|
269
|
-
|
264
|
+
) : (
|
265
|
+
<div className={cx('Selections-placeholder')}>{__(placeholder)}</div>
|
266
|
+
)}
|
270
267
|
</>
|
271
268
|
);
|
272
269
|
}
|
@@ -43,7 +43,10 @@ export interface ResultTableSelectionState {
|
|
43
43
|
searchTableOptions: Options;
|
44
44
|
}
|
45
45
|
|
46
|
-
export class BaseResultTableSelection extends BaseSelection<
|
46
|
+
export class BaseResultTableSelection extends BaseSelection<
|
47
|
+
ResultTableSelectionProps,
|
48
|
+
ResultTableSelectionState
|
49
|
+
> {
|
47
50
|
static defaultProps = {
|
48
51
|
...BaseSelection.defaultProps,
|
49
52
|
cellRender: (
|
@@ -55,25 +58,21 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
55
58
|
option: Option,
|
56
59
|
colIndex: number,
|
57
60
|
rowIndex: number
|
58
|
-
) => <span>{resolveVariable(column.name, option)}</span
|
61
|
+
) => <span>{resolveVariable(column.name, option)}</span>
|
59
62
|
};
|
60
63
|
|
61
64
|
state: ResultTableSelectionState = {
|
62
65
|
tableOptions: [],
|
63
66
|
searching: false,
|
64
67
|
searchTableOptions: []
|
65
|
-
}
|
68
|
+
};
|
66
69
|
|
67
70
|
static getDerivedStateFromProps(props: ResultTableSelectionProps) {
|
68
|
-
const {
|
69
|
-
options,
|
70
|
-
value,
|
71
|
-
option2value,
|
72
|
-
} = props;
|
71
|
+
const {options, value, option2value} = props;
|
73
72
|
const valueArray = BaseSelection.value2array(value, options, option2value);
|
74
73
|
return {
|
75
74
|
tableOptions: valueArray
|
76
|
-
}
|
75
|
+
};
|
77
76
|
}
|
78
77
|
|
79
78
|
@autobind
|
@@ -117,15 +116,16 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
117
116
|
}
|
118
117
|
|
119
118
|
const {value, onSearch} = this.props;
|
120
|
-
const searchOptions = ((value || []) as Options)
|
121
|
-
|
119
|
+
const searchOptions = ((value || []) as Options).filter(item =>
|
120
|
+
onSearch?.(inputValue, item)
|
121
|
+
);
|
122
122
|
|
123
123
|
this.setState({
|
124
124
|
searching: true,
|
125
125
|
searchTableOptions: searchOptions
|
126
126
|
});
|
127
127
|
}
|
128
|
-
|
128
|
+
|
129
129
|
@autobind
|
130
130
|
clearSearch() {
|
131
131
|
this.setState({
|
@@ -152,9 +152,7 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
152
152
|
|
153
153
|
return (
|
154
154
|
<div className={cx('ResultTableList', className)}>
|
155
|
-
{
|
156
|
-
Array.isArray(value) && value.length ?
|
157
|
-
(
|
155
|
+
{Array.isArray(value) && value.length ? (
|
158
156
|
<TableSelection
|
159
157
|
columns={columns}
|
160
158
|
options={!searching ? tableOptions : searchTableOptions}
|
@@ -163,6 +161,7 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
163
161
|
option2value={option2value}
|
164
162
|
onChange={onChange}
|
165
163
|
multiple={false}
|
164
|
+
resultMode={true}
|
166
165
|
cellRender={(
|
167
166
|
column: {
|
168
167
|
name: string;
|
@@ -176,27 +175,28 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
176
175
|
const raw = cellRender(column, option, colIndex, rowIndex);
|
177
176
|
if (colIndex === columns.length - 1) {
|
178
177
|
return (
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
178
|
+
<>
|
179
|
+
{raw}
|
180
|
+
{
|
181
|
+
<span
|
182
|
+
className={cx('ResultTableList-close-btn')}
|
183
|
+
onClick={(e: React.SyntheticEvent<HTMLElement>) => {
|
184
|
+
e.stopPropagation();
|
185
|
+
this.handleCloseItem(option);
|
186
|
+
}}
|
187
|
+
>
|
188
|
+
<CloseIcon />
|
189
|
+
</span>
|
190
|
+
}
|
191
|
+
</>
|
192
|
+
);
|
193
193
|
}
|
194
194
|
return raw;
|
195
195
|
}}
|
196
196
|
/>
|
197
|
-
|
198
|
-
|
199
|
-
}
|
197
|
+
) : (
|
198
|
+
<div className={cx('Selections-placeholder')}>{__(placeholder)}</div>
|
199
|
+
)}
|
200
200
|
</div>
|
201
201
|
);
|
202
202
|
}
|
@@ -211,7 +211,6 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
|
|
211
211
|
placeholder = __('Transfer.searchKeyword')
|
212
212
|
} = this.props;
|
213
213
|
|
214
|
-
|
215
214
|
return (
|
216
215
|
<div className={cx('Selections', className)}>
|
217
216
|
{title ? <div className={cx('Selections-title')}>{title}</div> : null}
|