amis 1.7.0 → 1.8.0-beta.0
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 +3 -2
- package/lib/Schema.js +0 -1
- package/lib/Schema.js.map +2 -2
- package/lib/components/Alert2.js +4 -2
- package/lib/components/Alert2.js.map +2 -2
- package/lib/components/Avatar.d.ts +20 -20
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/CityArea.js +3 -0
- package/lib/components/CityArea.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/Tabs.d.ts +27 -23
- package/lib/components/Tabs.js +37 -22
- package/lib/components/Tabs.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +21 -20
- package/lib/components/TooltipWrapper.js +2 -2
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/icons.js +2 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/icons/trash.js +10 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/renderers/Action.d.ts +1 -1
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/ButtonGroup.d.ts +2 -2
- package/lib/renderers/ButtonGroup.js.map +1 -1
- package/lib/renderers/Form/Combo.d.ts +4 -3
- package/lib/renderers/Form/Combo.js +81 -32
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/InputCity.js +4 -1
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputRange.d.ts +2 -2
- package/lib/renderers/Form/InputRange.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +10 -2
- package/lib/renderers/Tabs.js +2 -2
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +104 -0
- package/lib/renderers/TooltipWrapper.js +59 -0
- package/lib/renderers/TooltipWrapper.js.map +13 -0
- package/lib/themes/ang-ie11.css +192 -33
- package/lib/themes/ang.css +200 -28
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +192 -33
- package/lib/themes/antd.css +200 -28
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +181 -22
- package/lib/themes/cxd.css +202 -29
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +192 -33
- package/lib/themes/dark.css +200 -28
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +181 -22
- package/lib/themes/default.css +202 -29
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +286 -52
- package/scss/_properties.scss +23 -12
- package/scss/components/_alert.scss +1 -1
- package/scss/components/_button-group.scss +15 -0
- package/scss/components/_tabs.scss +145 -13
- package/scss/components/_tooltip.scss +72 -0
- package/scss/components/form/_number.scss +2 -0
- package/scss/themes/_cxd-variables.scss +2 -1
- package/sdk/ang-ie11.css +229 -34
- package/sdk/ang.css +237 -29
- package/sdk/antd-ie11.css +229 -34
- package/sdk/antd.css +237 -29
- 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 +218 -23
- package/sdk/cxd.css +239 -30
- package/sdk/dark-ie11.css +229 -34
- package/sdk/dark.css +237 -29
- 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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +218 -23
- package/sdk/sdk.css +239 -30
- package/sdk/sdk.js +1250 -1246
- 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 +5 -2
- package/src/components/Alert2.tsx +9 -3
- package/src/components/CityArea.tsx +3 -0
- package/src/components/Tabs.tsx +51 -21
- package/src/components/TooltipWrapper.tsx +4 -1
- package/src/components/icons.tsx +2 -0
- package/src/icons/trash.svg +8 -0
- package/src/index.tsx +1 -0
- package/src/renderers/Action.tsx +2 -1
- package/src/renderers/ButtonGroup.tsx +2 -2
- package/src/renderers/Form/Combo.tsx +84 -26
- package/src/renderers/Form/InputCity.tsx +13 -1
- package/src/renderers/Form/InputRange.tsx +2 -6
- package/src/renderers/Tabs.tsx +15 -3
- package/src/renderers/TooltipWrapper.tsx +219 -0
package/src/Schema.ts
CHANGED
@@ -52,6 +52,7 @@ import {DialogSchema, DialogSchemaBase} from './renderers/Dialog';
|
|
52
52
|
import {DrawerSchema} from './renderers/Drawer';
|
53
53
|
import {SearchBoxSchema} from './renderers/SearchBox';
|
54
54
|
import {SparkLineSchema} from './renderers/SparkLine';
|
55
|
+
import {TooltipWrapperSchema} from './renderers/TooltipWrapper';
|
55
56
|
import {PaginationWrapperSchema} from './renderers/PaginationWrapper';
|
56
57
|
import {PaginationSchema} from './renderers/Pagination';
|
57
58
|
import {AnchorNavSchema} from './renderers/AnchorNav';
|
@@ -331,7 +332,8 @@ export type SchemaType =
|
|
331
332
|
| 'native-date'
|
332
333
|
| 'native-time'
|
333
334
|
| 'native-number'
|
334
|
-
| 'code'
|
335
|
+
| 'code'
|
336
|
+
| 'tooltip-wrapper';
|
335
337
|
|
336
338
|
export type SchemaObject =
|
337
339
|
| PageSchema
|
@@ -389,6 +391,7 @@ export type SchemaObject =
|
|
389
391
|
| VideoSchema
|
390
392
|
| WizardSchema
|
391
393
|
| WrapperSchema
|
394
|
+
| TooltipWrapperSchema
|
392
395
|
| FormSchema
|
393
396
|
| AnchorNavSchema
|
394
397
|
| StepsSchema
|
@@ -882,4 +885,4 @@ export interface ToastSchemaBase extends BaseSchema {
|
|
882
885
|
* 持续时间
|
883
886
|
*/
|
884
887
|
timeout: number;
|
885
|
-
}
|
888
|
+
}
|
@@ -5,7 +5,8 @@
|
|
5
5
|
|
6
6
|
import React from 'react';
|
7
7
|
import {ClassNamesFn, themeable} from '../theme';
|
8
|
-
import {
|
8
|
+
import {generateIcon} from '../utils/icon';
|
9
|
+
import {Icon, getIcon} from './icons';
|
9
10
|
|
10
11
|
export interface AlertProps {
|
11
12
|
level: 'danger' | 'info' | 'success' | 'warning';
|
@@ -73,16 +74,21 @@ export class Alert extends React.Component<AlertProps, AlertState> {
|
|
73
74
|
closeButtonClassName
|
74
75
|
} = this.props;
|
75
76
|
|
77
|
+
// 优先使用内置svg,其次使用icon库
|
76
78
|
const iconNode = icon ? (
|
77
79
|
typeof icon === 'string' ? (
|
78
|
-
|
80
|
+
getIcon(icon) ? (
|
81
|
+
<Icon icon={icon} className={cx(`icon`)} />
|
82
|
+
) : (
|
83
|
+
generateIcon(cx, icon, 'icon')
|
84
|
+
)
|
79
85
|
) : React.isValidElement(icon) ? (
|
80
86
|
React.cloneElement(icon, {
|
81
87
|
className: cx(`Alert-icon`, icon.props?.className)
|
82
88
|
})
|
83
89
|
) : null
|
84
90
|
) : showIcon ? (
|
85
|
-
<Icon icon={`alert-${level}`} className={cx(`
|
91
|
+
<Icon icon={`alert-${level}`} className={cx(`icon`)} />
|
86
92
|
) : null;
|
87
93
|
|
88
94
|
return this.state.show ? (
|
@@ -145,8 +145,11 @@ const CityArea = memo<AreaProps>(props => {
|
|
145
145
|
} else {
|
146
146
|
onChange({
|
147
147
|
code,
|
148
|
+
provinceCode: province,
|
148
149
|
province: db[province],
|
150
|
+
cityCode: city,
|
149
151
|
city: db[city],
|
152
|
+
districtCode: district,
|
150
153
|
district: db[district],
|
151
154
|
street
|
152
155
|
});
|
package/src/components/Tabs.tsx
CHANGED
@@ -16,6 +16,7 @@ import {Icon} from './icons';
|
|
16
16
|
import debounce from 'lodash/debounce';
|
17
17
|
import {findDOMNode} from 'react-dom';
|
18
18
|
import TooltipWrapper, {TooltipObject, Trigger} from './TooltipWrapper';
|
19
|
+
import {resizeSensor} from '../utils/resize-sensor';
|
19
20
|
|
20
21
|
import Sortable from 'sortablejs';
|
21
22
|
|
@@ -26,7 +27,7 @@ const transitionStyles: {
|
|
26
27
|
[ENTERED]: 'in'
|
27
28
|
};
|
28
29
|
|
29
|
-
export type TabsMode = '' | 'line' | 'card' | 'radio' | 'vertical' | 'chrome' | 'simple' | 'strong';
|
30
|
+
export type TabsMode = '' | 'line' | 'card' | 'radio' | 'vertical' | 'chrome' | 'simple' | 'strong' | 'tiled' |'sidebar';
|
30
31
|
|
31
32
|
export interface TabProps extends ThemeProps {
|
32
33
|
title?: string | React.ReactNode; // 标题
|
@@ -114,6 +115,8 @@ export interface TabsProps extends ThemeProps {
|
|
114
115
|
scrollable?: boolean; // 属性废弃,为了兼容暂且保留
|
115
116
|
editable?: boolean;
|
116
117
|
onEdit?: (index: number, text: string) => void;
|
118
|
+
sidePosition?: 'left' | 'right';
|
119
|
+
addBtnText?: string;
|
117
120
|
}
|
118
121
|
|
119
122
|
export interface IDragInfo {
|
@@ -122,21 +125,25 @@ export interface IDragInfo {
|
|
122
125
|
|
123
126
|
export class Tabs extends React.Component<TabsProps, any> {
|
124
127
|
static defaultProps: Pick<TabsProps,
|
125
|
-
'mode' | 'contentClassName' | 'showTip' | 'showTipClassName'
|
128
|
+
'mode' | 'contentClassName' | 'showTip' | 'showTipClassName' | 'sidePosition' | 'addBtnText'
|
126
129
|
> = {
|
127
130
|
mode: '',
|
128
131
|
contentClassName: '',
|
129
132
|
showTip: false,
|
130
|
-
showTipClassName: ''
|
133
|
+
showTipClassName: '',
|
134
|
+
sidePosition: 'left',
|
135
|
+
addBtnText: '增加'
|
131
136
|
};
|
132
137
|
|
133
138
|
static Tab = Tab;
|
134
|
-
navMain = React.createRef<
|
139
|
+
navMain = React.createRef<HTMLUListElement>(); // HTMLDivElement
|
135
140
|
scroll: boolean = false;
|
136
141
|
sortable?: Sortable;
|
137
142
|
dragTip?: HTMLElement;
|
138
143
|
id: string = guid();
|
139
144
|
draging: boolean = false;
|
145
|
+
toDispose: Array<() => void> = [];
|
146
|
+
resizeDom = React.createRef<HTMLDivElement>();
|
140
147
|
|
141
148
|
checkArrowStatus = debounce(
|
142
149
|
() => {
|
@@ -200,6 +207,12 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
200
207
|
});
|
201
208
|
this.checkArrowStatus();
|
202
209
|
}
|
210
|
+
|
211
|
+
this.resizeDom?.current && this.toDispose.push(
|
212
|
+
resizeSensor(this.resizeDom.current as HTMLElement, () =>
|
213
|
+
this.computedWidth()
|
214
|
+
)
|
215
|
+
);
|
203
216
|
}
|
204
217
|
|
205
218
|
componentDidUpdate() {
|
@@ -212,6 +225,8 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
212
225
|
|
213
226
|
componentWillUnmount() {
|
214
227
|
this.checkArrowStatus.cancel();
|
228
|
+
this.toDispose.forEach(fn => fn());
|
229
|
+
this.toDispose = [];
|
215
230
|
}
|
216
231
|
|
217
232
|
/**
|
@@ -220,7 +235,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
220
235
|
computedWidth() {
|
221
236
|
const {mode: dMode, tabsMode} = this.props;
|
222
237
|
const mode = tabsMode || dMode;
|
223
|
-
if (
|
238
|
+
if (['vertical', 'sidebar'].includes(mode)) {
|
224
239
|
return;
|
225
240
|
}
|
226
241
|
|
@@ -246,7 +261,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
246
261
|
const {mode: dMode, tabsMode} = this.props;
|
247
262
|
const {isOverflow} = this.state;
|
248
263
|
const mode = tabsMode || dMode;
|
249
|
-
if (
|
264
|
+
if (['vertical', 'sidebar'].includes(mode) || !isOverflow) {
|
250
265
|
return;
|
251
266
|
}
|
252
267
|
const {activeKey, children} = this.props;
|
@@ -254,7 +269,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
254
269
|
const currentIndex = (children as any[])?.findIndex(
|
255
270
|
(item: any) => item.props.eventKey === currentKey
|
256
271
|
);
|
257
|
-
const li = this.navMain.current?.children
|
272
|
+
const li = this.navMain.current?.children || [];
|
258
273
|
const currentLi = li[currentIndex] as HTMLElement;
|
259
274
|
const liOffsetLeft = currentLi?.offsetLeft;
|
260
275
|
const liClientWidth = currentLi?.clientWidth;
|
@@ -569,7 +584,7 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
569
584
|
renderArrow(type: 'left' | 'right') {
|
570
585
|
const {mode: dMode, tabsMode} = this.props;
|
571
586
|
const mode = tabsMode || dMode;
|
572
|
-
if (
|
587
|
+
if (['vertical', 'sidebar'].includes(mode)) {
|
573
588
|
return;
|
574
589
|
}
|
575
590
|
const {classnames: cx} = this.props;
|
@@ -607,7 +622,9 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
607
622
|
toolbar,
|
608
623
|
linksClassName,
|
609
624
|
addable,
|
610
|
-
draggable
|
625
|
+
draggable,
|
626
|
+
sidePosition,
|
627
|
+
addBtnText
|
611
628
|
} = this.props;
|
612
629
|
|
613
630
|
const {isOverflow} = this.state;
|
@@ -617,19 +634,35 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
617
634
|
|
618
635
|
const mode = tabsMode || dMode;
|
619
636
|
|
637
|
+
const toolButtons = (
|
638
|
+
<>
|
639
|
+
{addable && (
|
640
|
+
<div className={cx('Tabs-addable')} onClick={() => this.handleAddBtn()}>
|
641
|
+
<Icon icon="plus" className={cx('Tabs-addable-icon')} />
|
642
|
+
{addBtnText}
|
643
|
+
</div>
|
644
|
+
)}
|
645
|
+
{toolbar}
|
646
|
+
</>
|
647
|
+
);
|
648
|
+
|
620
649
|
return (
|
621
650
|
<div
|
622
651
|
className={cx(
|
623
652
|
`Tabs`,
|
624
653
|
{
|
625
|
-
[`Tabs--${mode}`]: mode
|
654
|
+
[`Tabs--${mode}`]: mode,
|
655
|
+
[`sidebar--${sidePosition}`]: mode === 'sidebar'
|
626
656
|
},
|
627
657
|
className
|
628
658
|
)}
|
629
659
|
>
|
630
660
|
{
|
631
|
-
!['vertical', 'chrome'].includes(mode) ? (
|
632
|
-
<div
|
661
|
+
!['vertical', 'sidebar', 'chrome'].includes(mode) ? (
|
662
|
+
<div
|
663
|
+
className={cx('Tabs-linksContainer-wrapper', toolbar && 'Tabs-linksContainer-wrapper--toolbar')}
|
664
|
+
ref={this.resizeDom}
|
665
|
+
>
|
633
666
|
<div
|
634
667
|
className={cx(
|
635
668
|
'Tabs-linksContainer',
|
@@ -637,22 +670,19 @@ export class Tabs extends React.Component<TabsProps, any> {
|
|
637
670
|
)}
|
638
671
|
>
|
639
672
|
{this.renderArrow('left')}
|
640
|
-
<div className={cx('Tabs-linksContainer-main')}
|
641
|
-
<ul className={cx('Tabs-links', linksClassName)} role="tablist">
|
673
|
+
<div className={cx('Tabs-linksContainer-main')}>
|
674
|
+
<ul className={cx('Tabs-links', linksClassName)} role="tablist" ref={this.navMain}>
|
642
675
|
{children.map((tab, index) => this.renderNav(tab, index))}
|
643
676
|
{additionBtns}
|
644
|
-
{
|
677
|
+
{
|
678
|
+
!isOverflow && toolButtons
|
679
|
+
}
|
645
680
|
</ul>
|
646
681
|
</div>
|
647
682
|
{this.renderArrow('right')}
|
648
683
|
</div>
|
649
684
|
{
|
650
|
-
|
651
|
-
<div className={cx('Tabs-addable')} onClick={() => this.handleAddBtn()}>
|
652
|
-
<Icon icon="plus" className={cx('Tabs-addable-icon')} />
|
653
|
-
增加
|
654
|
-
</div>
|
655
|
-
)
|
685
|
+
isOverflow && toolButtons
|
656
686
|
}
|
657
687
|
</div>
|
658
688
|
) : (
|
@@ -33,6 +33,7 @@ export interface TooltipWrapperProps {
|
|
33
33
|
delay: number;
|
34
34
|
theme?: string;
|
35
35
|
tooltipClassName?: string;
|
36
|
+
style?: React.CSSProperties;
|
36
37
|
}
|
37
38
|
|
38
39
|
interface TooltipWrapperState {
|
@@ -167,7 +168,8 @@ export class TooltipWrapper extends React.Component<
|
|
167
168
|
container,
|
168
169
|
trigger,
|
169
170
|
rootClose,
|
170
|
-
tooltipClassName
|
171
|
+
tooltipClassName,
|
172
|
+
style
|
171
173
|
} = this.props;
|
172
174
|
|
173
175
|
const child = React.Children.only(children);
|
@@ -210,6 +212,7 @@ export class TooltipWrapper extends React.Component<
|
|
210
212
|
>
|
211
213
|
<Tooltip
|
212
214
|
title={typeof tooltip !== 'string' ? tooltip.title : undefined}
|
215
|
+
style={style}
|
213
216
|
className={tooltipClassName}
|
214
217
|
onMouseEnter={~triggers.indexOf('hover') && this.handleMouseOver}
|
215
218
|
onMouseLeave={~triggers.indexOf('hover') && this.handleMouseOut}
|
package/src/components/icons.tsx
CHANGED
@@ -83,6 +83,7 @@ import AlertDanger from '../icons/alert-danger.svg';
|
|
83
83
|
import FunctionIcon from '../icons/function.svg';
|
84
84
|
import InputClearIcon from '../icons/input-clear.svg';
|
85
85
|
import SliderHandleIcon from '../icons/slider-handle-icon.svg';
|
86
|
+
import TrashIcon from '../icons/trash.svg';
|
86
87
|
|
87
88
|
// 兼容原来的用法,后续不直接试用。
|
88
89
|
|
@@ -192,6 +193,7 @@ registerIcon('slider-handle', SliderHandleIcon);
|
|
192
193
|
registerIcon('cloud-upload', CloudUploadIcon);
|
193
194
|
registerIcon('image', ImageIcon);
|
194
195
|
registerIcon('refresh', RefreshIcon);
|
196
|
+
registerIcon('trash', TrashIcon);
|
195
197
|
|
196
198
|
export function Icon({
|
197
199
|
icon,
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<title>4.图标元件/3.操作/删除</title>
|
4
|
+
<g id="4.图标元件/3.操作/删除" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
5
|
+
<rect id="矩形" stroke="#979797" fill="#D8D8D8" opacity="0" x="0.5" y="0.5" width="15" height="15"></rect>
|
6
|
+
<path d="M14,3.499 L14,4.5 L12.497,4.5 L12.498,14.5 L3.498,14.5 L3.497,4.5 L2,4.5 L2,3.499 L14,3.499 Z M11.498,4.5 L4.497,4.5 L4.497,13.5 L11.498,13.5 L11.498,4.5 Z M6.998,7.499 L6.998,11.499 L5.998,11.499 L5.998,7.499 L6.998,7.499 Z M9.998,7.499 L9.998,11.499 L8.998,11.499 L8.998,7.499 L9.998,7.499 Z M9.999,1.5 L9.999,2.499 L5.998,2.499 L5.998,1.5 L9.999,1.5 Z" id="形状结合" fill="#151B26"></path>
|
7
|
+
</g>
|
8
|
+
</svg>
|
package/src/index.tsx
CHANGED
package/src/renderers/Action.tsx
CHANGED
@@ -15,12 +15,12 @@ export interface ButtonGroupSchema extends BaseSchema {
|
|
15
15
|
type: 'button-group';
|
16
16
|
|
17
17
|
/**
|
18
|
-
* 给 Button 配置 className
|
18
|
+
* @deprecated 给 Button 配置 className。建议用btnLevel
|
19
19
|
*/
|
20
20
|
btnClassName?: SchemaClassName;
|
21
21
|
|
22
22
|
/**
|
23
|
-
* 给选中态 Button 配置 className
|
23
|
+
* @deprecated 给选中态 Button 配置 className。建议用btnActiveLevel
|
24
24
|
*/
|
25
25
|
btnActiveClassName: string;
|
26
26
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import {findDOMNode} from 'react-dom';
|
3
|
+
import cloneDeep from 'lodash/cloneDeep';
|
3
4
|
import {
|
4
5
|
FormItem,
|
5
6
|
FormControlProps,
|
@@ -9,6 +10,7 @@ import {
|
|
9
10
|
import {Schema, Action, Api} from '../../types';
|
10
11
|
import {ComboStore, IComboStore} from '../../store/combo';
|
11
12
|
import {default as CTabs, Tab} from '../../components/Tabs';
|
13
|
+
import Button from '../../components/Button';
|
12
14
|
|
13
15
|
import {
|
14
16
|
guid,
|
@@ -255,6 +257,8 @@ export interface ComboControlSchema extends FormBaseControl {
|
|
255
257
|
};
|
256
258
|
}
|
257
259
|
|
260
|
+
export type ComboRendererEvent = 'add' | 'delete' | 'tabsChange';
|
261
|
+
|
258
262
|
function pickVars(vars: any, fields: Array<string>) {
|
259
263
|
return fields.reduce((data: any, key: string) => {
|
260
264
|
data[key] = resolveVariable(key, vars);
|
@@ -291,6 +295,8 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
291
295
|
| 'tabsMode'
|
292
296
|
| 'tabsStyle'
|
293
297
|
| 'placeholder'
|
298
|
+
| 'itemClassName'
|
299
|
+
| 'itemsWrapperClassName'
|
294
300
|
> = {
|
295
301
|
minLength: 0,
|
296
302
|
maxLength: 0,
|
@@ -307,7 +313,9 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
307
313
|
deleteIcon: '',
|
308
314
|
tabsMode: false,
|
309
315
|
tabsStyle: '',
|
310
|
-
placeholder: 'placeholder.empty'
|
316
|
+
placeholder: 'placeholder.empty',
|
317
|
+
itemClassName: '',
|
318
|
+
itemsWrapperClassName: ''
|
311
319
|
};
|
312
320
|
static propsList: Array<string> = [
|
313
321
|
'minLength',
|
@@ -334,7 +342,9 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
334
342
|
'items',
|
335
343
|
'conditions',
|
336
344
|
'messages',
|
337
|
-
'formStore'
|
345
|
+
'formStore',
|
346
|
+
'itemClassName',
|
347
|
+
'itemsWrapperClassName'
|
338
348
|
];
|
339
349
|
|
340
350
|
subForms: Array<any> = [];
|
@@ -469,9 +479,17 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
469
479
|
this.props.onChange(value, submitOnChange, true);
|
470
480
|
}
|
471
481
|
|
472
|
-
addItem() {
|
473
|
-
const {
|
474
|
-
|
482
|
+
async addItem() {
|
483
|
+
const {
|
484
|
+
flat,
|
485
|
+
joinValues,
|
486
|
+
delimiter,
|
487
|
+
scaffold,
|
488
|
+
disabled,
|
489
|
+
submitOnChange,
|
490
|
+
data,
|
491
|
+
dispatchEvent
|
492
|
+
} = this.props;
|
475
493
|
|
476
494
|
if (disabled) {
|
477
495
|
return;
|
@@ -479,6 +497,18 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
479
497
|
|
480
498
|
let value = this.getValueAsArray();
|
481
499
|
|
500
|
+
const rendererEvent = await dispatchEvent(
|
501
|
+
'add',
|
502
|
+
createObject(data, {
|
503
|
+
value:
|
504
|
+
flat && joinValues ? value.join(delimiter || ',') : cloneDeep(value)
|
505
|
+
})
|
506
|
+
);
|
507
|
+
|
508
|
+
if (rendererEvent?.prevented) {
|
509
|
+
return;
|
510
|
+
}
|
511
|
+
|
482
512
|
value.push(
|
483
513
|
flat
|
484
514
|
? scaffold || ''
|
@@ -505,7 +535,8 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
505
535
|
deleteConfirmText,
|
506
536
|
data,
|
507
537
|
env,
|
508
|
-
translate: __
|
538
|
+
translate: __,
|
539
|
+
dispatchEvent
|
509
540
|
} = this.props;
|
510
541
|
|
511
542
|
if (disabled) {
|
@@ -515,6 +546,19 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
515
546
|
let value = this.getValueAsArray();
|
516
547
|
const ctx = createObject(data, value[key]);
|
517
548
|
|
549
|
+
const rendererEvent = await dispatchEvent(
|
550
|
+
'delete',
|
551
|
+
createObject(data, {
|
552
|
+
key,
|
553
|
+
value:
|
554
|
+
flat && joinValues ? value.join(delimiter || ',') : cloneDeep(value)
|
555
|
+
})
|
556
|
+
);
|
557
|
+
|
558
|
+
if (rendererEvent?.prevented) {
|
559
|
+
return;
|
560
|
+
}
|
561
|
+
|
518
562
|
if (isEffectiveApi(deleteApi, ctx)) {
|
519
563
|
const confirmed = await env.confirm(
|
520
564
|
deleteConfirmText ? filter(deleteConfirmText, ctx) : __('deleteConfirm')
|
@@ -866,8 +910,19 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
866
910
|
}
|
867
911
|
|
868
912
|
@autobind
|
869
|
-
handleTabSelect(key: number) {
|
870
|
-
const {store} = this.props;
|
913
|
+
async handleTabSelect(key: number) {
|
914
|
+
const {store, data, dispatchEvent} = this.props;
|
915
|
+
|
916
|
+
const rendererEvent = await dispatchEvent(
|
917
|
+
'tabsChange',
|
918
|
+
createObject(data, {
|
919
|
+
key
|
920
|
+
})
|
921
|
+
);
|
922
|
+
|
923
|
+
if (rendererEvent?.prevented) {
|
924
|
+
return;
|
925
|
+
}
|
871
926
|
|
872
927
|
store.setActiveKey(key);
|
873
928
|
}
|
@@ -1138,7 +1193,9 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1138
1193
|
lazyLoad,
|
1139
1194
|
changeImmediately,
|
1140
1195
|
placeholder,
|
1141
|
-
translate: __
|
1196
|
+
translate: __,
|
1197
|
+
itemClassName,
|
1198
|
+
itemsWrapperClassName
|
1142
1199
|
} = this.props;
|
1143
1200
|
|
1144
1201
|
let items = this.props.items;
|
@@ -1165,7 +1222,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1165
1222
|
: ''
|
1166
1223
|
)}
|
1167
1224
|
>
|
1168
|
-
<div className={cx(`Combo-items
|
1225
|
+
<div className={cx(`Combo-items`, itemsWrapperClassName)}>
|
1169
1226
|
{Array.isArray(value) && value.length ? (
|
1170
1227
|
value.map((value, index, thelist) => {
|
1171
1228
|
let delBtn: any = null;
|
@@ -1176,21 +1233,20 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1176
1233
|
evalExpression(itemRemovableOn, value) !== false)
|
1177
1234
|
) {
|
1178
1235
|
delBtn = (
|
1179
|
-
<
|
1180
|
-
onClick={this.removeItem.bind(this, index)}
|
1236
|
+
<Button
|
1181
1237
|
key="remove"
|
1182
|
-
className={cx(
|
1183
|
-
|
1184
|
-
)}
|
1185
|
-
|
1186
|
-
|
1238
|
+
className={cx('Combo-delBtn')}
|
1239
|
+
disabled={!store.removable}
|
1240
|
+
tooltip={__('delete')}
|
1241
|
+
tooltipPlacement="bottom"
|
1242
|
+
onClick={this.removeItem.bind(this, index)}
|
1187
1243
|
>
|
1188
1244
|
{deleteIcon ? (
|
1189
1245
|
<i className={deleteIcon} />
|
1190
1246
|
) : (
|
1191
1247
|
<Icon icon="status-close" className="icon" />
|
1192
1248
|
)}
|
1193
|
-
</
|
1249
|
+
</Button>
|
1194
1250
|
);
|
1195
1251
|
}
|
1196
1252
|
|
@@ -1214,7 +1270,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1214
1270
|
|
1215
1271
|
return (
|
1216
1272
|
<div
|
1217
|
-
className={cx(`Combo-item
|
1273
|
+
className={cx(`Combo-item`, itemClassName)}
|
1218
1274
|
key={this.keys[index] || (this.keys[index] = guid())}
|
1219
1275
|
>
|
1220
1276
|
{!disabled && draggable && thelist.length > 1 ? (
|
@@ -1315,15 +1371,16 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1315
1371
|
}
|
1316
1372
|
)
|
1317
1373
|
) : (
|
1318
|
-
<
|
1319
|
-
|
1374
|
+
<Button
|
1375
|
+
level="default"
|
1376
|
+
className={cx(`Combo-addBtn`, addButtonClassName)}
|
1377
|
+
block
|
1378
|
+
tooltip={__('Combo.add')}
|
1320
1379
|
onClick={this.addItem}
|
1321
|
-
className={cx(`Button Combo-addBtn`, addButtonClassName)}
|
1322
|
-
data-tooltip={__('Combo.add')}
|
1323
1380
|
>
|
1324
1381
|
{addIcon ? <Icon icon="plus" className="icon" /> : null}
|
1325
1382
|
<span>{__(addButtonText || 'Combo.add')}</span>
|
1326
|
-
</
|
1383
|
+
</Button>
|
1327
1384
|
)
|
1328
1385
|
) : null}
|
1329
1386
|
{draggable ? (
|
@@ -1352,7 +1409,8 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1352
1409
|
disabled,
|
1353
1410
|
typeSwitchable,
|
1354
1411
|
nullable,
|
1355
|
-
translate: __
|
1412
|
+
translate: __,
|
1413
|
+
itemClassName
|
1356
1414
|
} = this.props;
|
1357
1415
|
|
1358
1416
|
let items = this.props.items;
|
@@ -1373,7 +1431,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
|
1373
1431
|
disabled ? 'is-disabled' : ''
|
1374
1432
|
)}
|
1375
1433
|
>
|
1376
|
-
<div className={cx(`Combo-item
|
1434
|
+
<div className={cx(`Combo-item`, itemClassName)}>
|
1377
1435
|
{condition && typeSwitchable !== false ? (
|
1378
1436
|
<div className={cx('Combo-itemTag')}>
|
1379
1437
|
<label>{__('Combo.type')}</label>
|
@@ -299,7 +299,16 @@ export class CityPicker extends React.Component<
|
|
299
299
|
const {onChange, allowStreet, joinValues, extractValue, delimiter} =
|
300
300
|
this.props;
|
301
301
|
|
302
|
-
const {
|
302
|
+
const {
|
303
|
+
code,
|
304
|
+
province,
|
305
|
+
city,
|
306
|
+
district,
|
307
|
+
street,
|
308
|
+
provinceCode,
|
309
|
+
cityCode,
|
310
|
+
districtCode
|
311
|
+
} = this.state;
|
303
312
|
|
304
313
|
if (typeof extractValue === 'undefined' ? joinValues : extractValue) {
|
305
314
|
code
|
@@ -312,8 +321,11 @@ export class CityPicker extends React.Component<
|
|
312
321
|
} else {
|
313
322
|
onChange({
|
314
323
|
code,
|
324
|
+
provinceCode,
|
315
325
|
province,
|
326
|
+
cityCode,
|
316
327
|
city,
|
328
|
+
districtCode,
|
317
329
|
district,
|
318
330
|
street
|
319
331
|
});
|
@@ -22,12 +22,8 @@ import {Action} from '../../types';
|
|
22
22
|
export type Value = string | MultipleValue | number | [number, number];
|
23
23
|
export type FormatValue = MultipleValue | number;
|
24
24
|
export type TooltipPosType = 'auto' | 'top' | 'right' | 'bottom' | 'left';
|
25
|
-
export type
|
26
|
-
|
27
|
-
| 'afterChange'
|
28
|
-
| 'blur'
|
29
|
-
| 'focus';
|
30
|
-
export type InputTextRendererAction = 'clear';
|
25
|
+
export type InputRangeRendererEvent = 'change' | 'blur' | 'focus';
|
26
|
+
export type InputRangeRendererAction = 'clear';
|
31
27
|
export interface RangeControlSchema extends FormBaseControl {
|
32
28
|
type: 'input-range';
|
33
29
|
|