amis 1.4.2-beta.11 → 1.4.2-beta.16
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 +4 -3
- package/lib/Schema.js.map +1 -1
- package/lib/components/AssociatedSelection.js +2 -2
- package/lib/components/AssociatedSelection.js.map +2 -2
- package/lib/components/Checkbox.d.ts +20 -20
- package/lib/components/Collapse.d.ts +51 -23
- package/lib/components/Collapse.js +69 -11
- package/lib/components/Collapse.js.map +2 -2
- package/lib/components/CollapseGroup.d.ts +88 -0
- package/lib/components/CollapseGroup.js +81 -0
- package/lib/components/CollapseGroup.js.map +13 -0
- package/lib/components/Editor.d.ts +84 -84
- package/lib/components/GridNav.d.ts +52 -0
- package/lib/components/GridNav.js +123 -0
- package/lib/components/GridNav.js.map +13 -0
- package/lib/components/InputBox.d.ts +22 -21
- package/lib/components/InputBox.js +10 -2
- package/lib/components/InputBox.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/PickerColumn.js +3 -3
- package/lib/components/PickerColumn.js.map +2 -2
- package/lib/components/ResultBox.d.ts +84 -84
- package/lib/components/ResultBox.js +10 -2
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/Select.js +1 -1
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Selection.js +1 -1
- package/lib/components/Selection.js.map +2 -2
- package/lib/components/Tabs.d.ts +20 -20
- package/lib/components/TabsTransfer.d.ts +84 -84
- package/lib/components/Toast.d.ts +86 -85
- package/lib/components/Toast.js +6 -3
- package/lib/components/Toast.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +85 -84
- package/lib/components/TransferDropDown.js +2 -2
- package/lib/components/TransferDropDown.js.map +2 -2
- package/lib/components/TransferPicker.d.ts +4 -0
- package/lib/components/TransferPicker.js +2 -2
- package/lib/components/TransferPicker.js.map +2 -2
- package/lib/components/Tree.d.ts +115 -84
- package/lib/components/Tree.js +183 -30
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/icons.js +2 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/envOverwrite.d.ts +1 -1
- package/lib/envOverwrite.js +24 -9
- package/lib/envOverwrite.js.map +2 -2
- package/lib/factory.d.ts +11 -1
- package/lib/factory.js +31 -4
- package/lib/factory.js.map +2 -2
- package/lib/icons/download.js +7 -0
- package/lib/icons/drag-bar.js +10 -3
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +1 -0
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Collapse.d.ts +25 -20
- package/lib/renderers/Collapse.js +10 -73
- package/lib/renderers/Collapse.js.map +2 -2
- package/lib/renderers/CollapseGroup.d.ts +42 -0
- package/lib/renderers/CollapseGroup.js +33 -0
- package/lib/renderers/CollapseGroup.js.map +13 -0
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputFile.d.ts +6 -0
- package/lib/renderers/Form/InputFile.js +18 -4
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/Item.js +2 -1
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +1 -0
- package/lib/renderers/Form/Select.js +16 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/Transfer.js +15 -1
- package/lib/renderers/Form/Transfer.js.map +2 -2
- package/lib/renderers/Form/TransferPicker.d.ts +4 -0
- package/lib/renderers/Form/TransferPicker.js +17 -3
- package/lib/renderers/Form/TransferPicker.js.map +2 -2
- package/lib/renderers/Form/index.d.ts +5 -0
- package/lib/renderers/Form/index.js +4 -2
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/GridNav.d.ts +99 -0
- package/lib/renderers/GridNav.js +82 -0
- package/lib/renderers/GridNav.js.map +13 -0
- package/lib/renderers/Table/index.js +1 -1
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/store/formItem.js +44 -4
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.d.ts +1 -0
- package/lib/store/table.js +35 -12
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +272 -31
- package/lib/themes/ang.css +272 -31
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +272 -31
- package/lib/themes/antd.css +272 -31
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +279 -38
- package/lib/themes/cxd.css +279 -38
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +272 -31
- package/lib/themes/dark.css +272 -31
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default.css +279 -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/api.d.ts +1 -0
- package/lib/utils/api.js +77 -6
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/helper.d.ts +6 -0
- package/lib/utils/helper.js +18 -1
- package/lib/utils/helper.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +297 -55
- package/scss/base/_common.scss +3 -0
- package/scss/components/_anchor-nav.scss +1 -0
- package/scss/components/_collapse-group.scss +11 -0
- package/scss/components/_collapse.scss +33 -22
- package/scss/components/_grid-nav.scss +128 -0
- package/scss/components/_input-box.scss +1 -0
- package/scss/components/_nav.scss +1 -1
- package/scss/components/_picker-columns.scss +1 -0
- package/scss/components/_popover.scss +0 -4
- package/scss/components/_result-box.scss +1 -0
- package/scss/components/_spinner.scss +5 -4
- package/scss/components/_table.scss +6 -0
- package/scss/components/form/_combo.scss +4 -0
- package/scss/components/form/_file.scss +11 -0
- package/scss/components/form/_form.scss +48 -0
- package/scss/components/form/_tree.scss +42 -0
- package/scss/themes/_common.scss +3 -0
- package/scss/themes/_cxd-variables.scss +6 -7
- package/scss/themes/cxd.scss +1 -0
- package/sdk/ang-ie11.css +317 -32
- package/sdk/ang.css +312 -31
- package/sdk/antd-ie11.css +317 -32
- package/sdk/antd.css +312 -31
- package/sdk/charts.js +13 -13
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +323 -36
- package/sdk/cxd.css +319 -38
- package/sdk/dark-ie11.css +317 -32
- package/sdk/dark.css +312 -31
- package/sdk/exceljs.js +1 -1
- package/sdk/iconfont.svg +2513 -0
- package/sdk/iconfont.ttf +0 -0
- package/sdk/iconfont.woff +0 -0
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +18 -18
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +323 -36
- package/sdk/sdk.css +319 -38
- package/sdk/sdk.js +1247 -1211
- 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 -1
- package/src/components/AssociatedSelection.tsx +3 -1
- package/src/components/Collapse.tsx +144 -20
- package/src/components/CollapseGroup.tsx +130 -0
- package/src/components/GridNav.tsx +233 -0
- package/src/components/InputBox.tsx +10 -9
- package/src/components/PickerColumn.tsx +1 -1
- package/src/components/ResultBox.tsx +9 -9
- package/src/components/Select.tsx +1 -1
- package/src/components/Selection.tsx +1 -1
- package/src/components/Toast.tsx +23 -16
- package/src/components/TransferDropDown.tsx +4 -1
- package/src/components/TransferPicker.tsx +7 -0
- package/src/components/Tree.tsx +194 -8
- package/src/components/icons.tsx +2 -0
- package/src/envOverwrite.ts +20 -7
- package/src/factory.tsx +52 -6
- package/src/icons/download.svg +4 -0
- package/src/icons/drag-bar.svg +12 -6
- package/src/index.tsx +2 -0
- package/src/locale/en-US.ts +1 -0
- package/src/locale/zh-CN.ts +1 -0
- package/src/renderers/Collapse.tsx +70 -117
- package/src/renderers/CollapseGroup.tsx +80 -0
- package/src/renderers/Form/InputFile.tsx +36 -4
- package/src/renderers/Form/Item.tsx +2 -1
- package/src/renderers/Form/Select.tsx +22 -4
- package/src/renderers/Form/Transfer.tsx +16 -2
- package/src/renderers/Form/TransferPicker.tsx +25 -3
- package/src/renderers/Form/index.tsx +14 -1
- package/src/renderers/GridNav.tsx +204 -0
- package/src/renderers/Table/index.tsx +1 -2
- package/src/store/formItem.ts +94 -2
- package/src/store/table.ts +55 -14
- package/src/types.ts +1 -1
- package/src/utils/api.ts +93 -6
- package/src/utils/helper.ts +19 -0
- package/tsconfig-for-declaration.json +1 -1
@@ -4,7 +4,7 @@ import {InputBoxProps} from './InputBox';
|
|
4
4
|
import {uncontrollable} from 'uncontrollable';
|
5
5
|
import {Icon} from './icons';
|
6
6
|
import Input from './Input';
|
7
|
-
import {autobind} from '../utils/helper';
|
7
|
+
import {autobind, ucFirst} from '../utils/helper';
|
8
8
|
import {LocaleProps, localeable} from '../locale';
|
9
9
|
|
10
10
|
export interface ResultBoxProps
|
@@ -113,20 +113,20 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
|
113
113
|
onKeyPress,
|
114
114
|
onFocus,
|
115
115
|
onBlur,
|
116
|
+
borderMode,
|
116
117
|
...rest
|
117
118
|
} = this.props;
|
118
119
|
const isFocused = this.state.isFocused;
|
119
120
|
|
120
121
|
return (
|
121
122
|
<div
|
122
|
-
className={cx(
|
123
|
-
'
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
)}
|
123
|
+
className={cx('ResultBox', className, {
|
124
|
+
'is-focused': isFocused,
|
125
|
+
'is-disabled': disabled,
|
126
|
+
'is-error': hasError,
|
127
|
+
'is-clickable': onResultClick,
|
128
|
+
[`ResultBox--border${ucFirst(borderMode)}`]: borderMode
|
129
|
+
})}
|
130
130
|
onClick={onResultClick}
|
131
131
|
tabIndex={!allowInput && !disabled && onFocus ? 0 : -1}
|
132
132
|
onKeyPress={allowInput ? undefined : onKeyPress}
|
package/src/components/Toast.tsx
CHANGED
@@ -51,6 +51,7 @@ interface ToastComponentProps extends ThemeProps, LocaleProps {
|
|
51
51
|
closeButton: boolean;
|
52
52
|
showIcon?: boolean;
|
53
53
|
timeout: number;
|
54
|
+
errorTimeout: number;
|
54
55
|
className?: string;
|
55
56
|
}
|
56
57
|
|
@@ -78,11 +79,12 @@ export class ToastComponent extends React.Component<
|
|
78
79
|
> {
|
79
80
|
static defaultProps: Pick<
|
80
81
|
ToastComponentProps,
|
81
|
-
'position' | 'closeButton' | 'timeout'
|
82
|
+
'position' | 'closeButton' | 'timeout' | 'errorTimeout'
|
82
83
|
> = {
|
83
84
|
position: 'top-center',
|
84
85
|
closeButton: false,
|
85
|
-
timeout: 5000
|
86
|
+
timeout: 5000,
|
87
|
+
errorTimeout: 10000 // 错误的时候 time 调长
|
86
88
|
};
|
87
89
|
static themeKey = 'toast';
|
88
90
|
|
@@ -155,6 +157,7 @@ export class ToastComponent extends React.Component<
|
|
155
157
|
classnames: cx,
|
156
158
|
className,
|
157
159
|
timeout,
|
160
|
+
errorTimeout,
|
158
161
|
position,
|
159
162
|
showIcon,
|
160
163
|
translate,
|
@@ -166,7 +169,6 @@ export class ToastComponent extends React.Component<
|
|
166
169
|
|
167
170
|
return Object.keys(groupedItems).map(position => {
|
168
171
|
const toasts = groupedItems[position];
|
169
|
-
|
170
172
|
return (
|
171
173
|
<div
|
172
174
|
key={position}
|
@@ -177,19 +179,24 @@ export class ToastComponent extends React.Component<
|
|
177
179
|
className
|
178
180
|
)}
|
179
181
|
>
|
180
|
-
{toasts.map(item =>
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
182
|
+
{toasts.map(item => {
|
183
|
+
const level = item.level || 'info';
|
184
|
+
const toastTimeout =
|
185
|
+
item.timeout ?? (level === 'error' ? errorTimeout : timeout);
|
186
|
+
return (
|
187
|
+
<ToastMessage
|
188
|
+
classnames={cx}
|
189
|
+
key={item.id}
|
190
|
+
body={item.body}
|
191
|
+
level={level}
|
192
|
+
timeout={toastTimeout}
|
193
|
+
closeButton={item.closeButton ?? closeButton}
|
194
|
+
onDismiss={this.handleDismissed.bind(this, items.indexOf(item))}
|
195
|
+
translate={translate}
|
196
|
+
showIcon={showIcon}
|
197
|
+
/>
|
198
|
+
);
|
199
|
+
})}
|
193
200
|
</div>
|
194
201
|
);
|
195
202
|
});
|
@@ -11,6 +11,7 @@ import PopOverContainer from './PopOverContainer';
|
|
11
11
|
export interface TransferDropDownProps extends TransferProps {
|
12
12
|
// 新的属性?
|
13
13
|
multiple?: boolean;
|
14
|
+
borderMode?: 'full' | 'half' | 'none';
|
14
15
|
}
|
15
16
|
|
16
17
|
export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
@@ -23,7 +24,8 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
23
24
|
className,
|
24
25
|
onChange,
|
25
26
|
onSearch,
|
26
|
-
multiple
|
27
|
+
multiple,
|
28
|
+
borderMode
|
27
29
|
} = this.props;
|
28
30
|
const {inputValue, searchResult} = this.state;
|
29
31
|
|
@@ -84,6 +86,7 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
|
|
84
86
|
className,
|
85
87
|
isOpened ? 'is-active' : ''
|
86
88
|
)}
|
89
|
+
borderMode={borderMode}
|
87
90
|
allowInput={false}
|
88
91
|
result={
|
89
92
|
multiple
|
@@ -11,6 +11,11 @@ import {autobind} from '../utils/helper';
|
|
11
11
|
export interface TransferPickerProps extends Omit<TransferProps, 'itemRender'> {
|
12
12
|
// 新的属性?
|
13
13
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
14
|
+
|
15
|
+
/**
|
16
|
+
* 边框模式,全边框,还是半边框,或者没边框。
|
17
|
+
*/
|
18
|
+
borderMode?: 'full' | 'half' | 'none';
|
14
19
|
}
|
15
20
|
|
16
21
|
export class TransferPicker extends React.Component<TransferPickerProps> {
|
@@ -37,6 +42,7 @@ export class TransferPicker extends React.Component<TransferPickerProps> {
|
|
37
42
|
className,
|
38
43
|
onChange,
|
39
44
|
size,
|
45
|
+
borderMode,
|
40
46
|
...rest
|
41
47
|
} = this.props;
|
42
48
|
|
@@ -64,6 +70,7 @@ export class TransferPicker extends React.Component<TransferPickerProps> {
|
|
64
70
|
onResultClick={onClick}
|
65
71
|
placeholder={__('Select.placeholder')}
|
66
72
|
disabled={disabled}
|
73
|
+
borderMode={borderMode}
|
67
74
|
>
|
68
75
|
<span className={cx('TransferPicker-icon')}>
|
69
76
|
<Icon icon="pencil" className="icon" />
|
package/src/components/Tree.tsx
CHANGED
@@ -24,6 +24,20 @@ import Checkbox from './Checkbox';
|
|
24
24
|
import {LocaleProps, localeable} from '../locale';
|
25
25
|
import Spinner from './Spinner';
|
26
26
|
|
27
|
+
interface IDropIndicator {
|
28
|
+
left: number;
|
29
|
+
top: number;
|
30
|
+
width: number;
|
31
|
+
height?: number;
|
32
|
+
}
|
33
|
+
|
34
|
+
export interface IDropInfo {
|
35
|
+
dragNode: Option | null;
|
36
|
+
node: Option;
|
37
|
+
position: 'top' | 'bottom' | 'self';
|
38
|
+
indicator: IDropIndicator;
|
39
|
+
}
|
40
|
+
|
27
41
|
interface TreeSelectorProps extends ThemeProps, LocaleProps {
|
28
42
|
highlightTxt?: string;
|
29
43
|
|
@@ -97,6 +111,8 @@ interface TreeSelectorProps extends ThemeProps, LocaleProps {
|
|
97
111
|
onDelete?: (value: Option) => void;
|
98
112
|
onDeferLoad?: (option: Option) => void;
|
99
113
|
onExpandTree?: (nodePathArr: any[]) => void;
|
114
|
+
draggable?: boolean;
|
115
|
+
onMove?: (dropInfo: IDropInfo) => void;
|
100
116
|
}
|
101
117
|
|
102
118
|
interface TreeSelectorState {
|
@@ -106,6 +122,9 @@ interface TreeSelectorState {
|
|
106
122
|
isAdding: boolean;
|
107
123
|
isEditing: boolean;
|
108
124
|
editingItem: Option | null;
|
125
|
+
|
126
|
+
// 拖拽指示器
|
127
|
+
dropIndicator?: IDropIndicator;
|
109
128
|
}
|
110
129
|
|
111
130
|
export class TreeSelector extends React.Component<
|
@@ -146,6 +165,16 @@ export class TreeSelector extends React.Component<
|
|
146
165
|
};
|
147
166
|
|
148
167
|
unfolded: WeakMap<Object, boolean> = new WeakMap();
|
168
|
+
dragNode: Option | null;
|
169
|
+
dropInfo: IDropInfo | null;
|
170
|
+
startPoint: {
|
171
|
+
x: number;
|
172
|
+
y: number;
|
173
|
+
} = {
|
174
|
+
x: 0,
|
175
|
+
y: 0
|
176
|
+
};
|
177
|
+
root = React.createRef<HTMLDivElement>();
|
149
178
|
|
150
179
|
constructor(props: TreeSelectorProps) {
|
151
180
|
super(props);
|
@@ -168,7 +197,8 @@ export class TreeSelector extends React.Component<
|
|
168
197
|
addingParent: null,
|
169
198
|
isAdding: false,
|
170
199
|
isEditing: false,
|
171
|
-
editingItem: null
|
200
|
+
editingItem: null,
|
201
|
+
dropIndicator: undefined
|
172
202
|
};
|
173
203
|
|
174
204
|
this.syncUnFolded(props);
|
@@ -603,6 +633,129 @@ export class TreeSelector extends React.Component<
|
|
603
633
|
);
|
604
634
|
}
|
605
635
|
|
636
|
+
getOffsetPosition(element: HTMLElement) {
|
637
|
+
let left = 0;
|
638
|
+
let top = 0;
|
639
|
+
|
640
|
+
while (element.offsetParent) {
|
641
|
+
left += element.offsetLeft;
|
642
|
+
top += element.offsetTop;
|
643
|
+
element = element.offsetParent as HTMLElement;
|
644
|
+
}
|
645
|
+
return {left, top};
|
646
|
+
}
|
647
|
+
|
648
|
+
@autobind
|
649
|
+
getDropInfo(e: React.DragEvent<Element>, node: Option): IDropInfo {
|
650
|
+
let rect = e.currentTarget.getBoundingClientRect();
|
651
|
+
|
652
|
+
const dragNode = this.dragNode;
|
653
|
+
const deltaX = Math.min(50, rect.width * 0.3);
|
654
|
+
const gap = node?.children?.length ? 0 : 16;
|
655
|
+
|
656
|
+
// 计算相对位置
|
657
|
+
let offset = this.getOffsetPosition(this.root.current!);
|
658
|
+
let targetOffset = this.getOffsetPosition(e.currentTarget as HTMLElement);
|
659
|
+
let left = targetOffset.left - offset.left;
|
660
|
+
let top = targetOffset.top - offset.top;
|
661
|
+
|
662
|
+
let {clientX, clientY} = e;
|
663
|
+
|
664
|
+
let position: IDropInfo['position'] =
|
665
|
+
clientY >= rect.top + rect.height / 2 ? 'bottom' : 'top';
|
666
|
+
let indicator;
|
667
|
+
if (position === 'bottom' && clientX >= this.startPoint.x + deltaX) {
|
668
|
+
position = 'self';
|
669
|
+
indicator = {
|
670
|
+
top: top,
|
671
|
+
left: left,
|
672
|
+
width: rect.width,
|
673
|
+
height: rect.height
|
674
|
+
};
|
675
|
+
} else {
|
676
|
+
indicator = {
|
677
|
+
top: position === 'bottom' ? top + rect.height : top,
|
678
|
+
left: left + gap,
|
679
|
+
width: rect.width - gap
|
680
|
+
};
|
681
|
+
}
|
682
|
+
|
683
|
+
return {
|
684
|
+
node,
|
685
|
+
dragNode,
|
686
|
+
position,
|
687
|
+
indicator
|
688
|
+
};
|
689
|
+
}
|
690
|
+
|
691
|
+
@autobind
|
692
|
+
updateDropIndicator(e: React.DragEvent<Element>, node: Option) {
|
693
|
+
const gap = node?.children?.length ? 0 : 16;
|
694
|
+
this.dropInfo = this.getDropInfo(e, node);
|
695
|
+
let {dragNode, indicator} = this.dropInfo;
|
696
|
+
if (node === dragNode) {
|
697
|
+
this.setState({dropIndicator: undefined});
|
698
|
+
return;
|
699
|
+
}
|
700
|
+
this.setState({
|
701
|
+
dropIndicator: indicator
|
702
|
+
});
|
703
|
+
}
|
704
|
+
|
705
|
+
@autobind
|
706
|
+
onDragStart(node: Option) {
|
707
|
+
let draggable = this.props.draggable;
|
708
|
+
return (e: React.DragEvent<Element>) => {
|
709
|
+
if (draggable) {
|
710
|
+
e.dataTransfer.effectAllowed = 'copyMove';
|
711
|
+
|
712
|
+
this.dragNode = node;
|
713
|
+
this.dropInfo = null;
|
714
|
+
this.startPoint = {
|
715
|
+
x: e.clientX,
|
716
|
+
y: e.clientY
|
717
|
+
};
|
718
|
+
|
719
|
+
if (node?.children?.length) {
|
720
|
+
this.unfolded.set(node, false);
|
721
|
+
this.forceUpdate();
|
722
|
+
}
|
723
|
+
} else {
|
724
|
+
this.dragNode = null;
|
725
|
+
this.dropInfo = null;
|
726
|
+
}
|
727
|
+
e.stopPropagation();
|
728
|
+
};
|
729
|
+
}
|
730
|
+
|
731
|
+
@autobind
|
732
|
+
onDragOver(node: Option) {
|
733
|
+
return (e: React.DragEvent<Element>) => {
|
734
|
+
if (!this.dragNode) {
|
735
|
+
return;
|
736
|
+
}
|
737
|
+
this.updateDropIndicator(e, node);
|
738
|
+
e.preventDefault();
|
739
|
+
};
|
740
|
+
}
|
741
|
+
|
742
|
+
@autobind
|
743
|
+
onDragEnd(dragNode: Option) {
|
744
|
+
return (e: React.DragEvent<Element>) => {
|
745
|
+
this.setState({
|
746
|
+
dropIndicator: undefined
|
747
|
+
});
|
748
|
+
let node = this.dropInfo?.node;
|
749
|
+
if (!this.dropInfo || !node || dragNode === node) {
|
750
|
+
return;
|
751
|
+
}
|
752
|
+
this.props.onMove?.(this.dropInfo);
|
753
|
+
this.dragNode = null;
|
754
|
+
this.dropInfo = null;
|
755
|
+
e.preventDefault();
|
756
|
+
};
|
757
|
+
}
|
758
|
+
|
606
759
|
@autobind
|
607
760
|
renderList(
|
608
761
|
list: Options,
|
@@ -633,7 +786,8 @@ export class TreeSelector extends React.Component<
|
|
633
786
|
createTip,
|
634
787
|
editTip,
|
635
788
|
removeTip,
|
636
|
-
translate: __
|
789
|
+
translate: __,
|
790
|
+
draggable
|
637
791
|
} = this.props;
|
638
792
|
const {
|
639
793
|
value: stateValue,
|
@@ -729,7 +883,17 @@ export class TreeSelector extends React.Component<
|
|
729
883
|
'is-checked': checked,
|
730
884
|
'is-disabled': nodeDisabled
|
731
885
|
})}
|
886
|
+
draggable={draggable}
|
887
|
+
onDragStart={this.onDragStart(item)}
|
888
|
+
onDragOver={this.onDragOver(item)}
|
889
|
+
onDragEnd={this.onDragEnd(item)}
|
732
890
|
>
|
891
|
+
{draggable && (
|
892
|
+
<a className={cx('Tree-itemDrager drag-bar')}>
|
893
|
+
<Icon icon="drag-bar" className="icon" />
|
894
|
+
</a>
|
895
|
+
)}
|
896
|
+
|
733
897
|
{item.loading ? (
|
734
898
|
<Spinner
|
735
899
|
size="sm"
|
@@ -756,7 +920,7 @@ export class TreeSelector extends React.Component<
|
|
756
920
|
<i
|
757
921
|
className={cx(
|
758
922
|
`Tree-itemIcon ${
|
759
|
-
|
923
|
+
childrenItems ? 'Tree-folderIcon' : 'Tree-leafIcon'
|
760
924
|
}`
|
761
925
|
)}
|
762
926
|
onClick={() =>
|
@@ -766,9 +930,11 @@ export class TreeSelector extends React.Component<
|
|
766
930
|
: this.handleSelect(item))
|
767
931
|
}
|
768
932
|
>
|
769
|
-
{getIcon(iconValue)
|
770
|
-
|
771
|
-
|
933
|
+
{getIcon(iconValue) ? (
|
934
|
+
<Icon icon={iconValue} className="icon" />
|
935
|
+
) : (
|
936
|
+
<i className={iconValue}></i>
|
937
|
+
)}
|
772
938
|
</i>
|
773
939
|
) : null}
|
774
940
|
|
@@ -872,10 +1038,19 @@ export class TreeSelector extends React.Component<
|
|
872
1038
|
rootCreatable,
|
873
1039
|
rootCreateTip,
|
874
1040
|
disabled,
|
1041
|
+
draggable,
|
875
1042
|
translate: __
|
876
1043
|
} = this.props;
|
877
1044
|
let options = this.props.options;
|
878
|
-
const {
|
1045
|
+
const {
|
1046
|
+
value,
|
1047
|
+
isAdding,
|
1048
|
+
addingParent,
|
1049
|
+
isEditing,
|
1050
|
+
inputValue,
|
1051
|
+
dropIndicator
|
1052
|
+
} = this.state;
|
1053
|
+
|
879
1054
|
let addBtn = null;
|
880
1055
|
|
881
1056
|
if (creatable && rootCreatable !== false && hideRoot) {
|
@@ -896,8 +1071,10 @@ export class TreeSelector extends React.Component<
|
|
896
1071
|
<div
|
897
1072
|
className={cx(`Tree ${className || ''}`, {
|
898
1073
|
'Tree--outline': showOutline,
|
899
|
-
'is-disabled': disabled
|
1074
|
+
'is-disabled': disabled,
|
1075
|
+
'is-draggable': draggable
|
900
1076
|
})}
|
1077
|
+
ref={this.root}
|
901
1078
|
>
|
902
1079
|
{(options && options.length) || addBtn || hideRoot === false ? (
|
903
1080
|
<ul className={cx('Tree-list')}>
|
@@ -957,6 +1134,15 @@ export class TreeSelector extends React.Component<
|
|
957
1134
|
) : (
|
958
1135
|
<div className={cx('Tree-placeholder')}>{placeholder}</div>
|
959
1136
|
)}
|
1137
|
+
|
1138
|
+
{dropIndicator && (
|
1139
|
+
<div
|
1140
|
+
className={cx('Tree-dropIndicator', {
|
1141
|
+
'Tree-dropIndicator--hover': !!dropIndicator.height
|
1142
|
+
})}
|
1143
|
+
style={dropIndicator}
|
1144
|
+
/>
|
1145
|
+
)}
|
960
1146
|
</div>
|
961
1147
|
);
|
962
1148
|
}
|
package/src/components/icons.tsx
CHANGED
@@ -24,6 +24,7 @@ import ViewIcon from '../icons/view.svg';
|
|
24
24
|
import RemoveIcon from '../icons/remove.svg';
|
25
25
|
import RetryIcon from '../icons/retry.svg';
|
26
26
|
import UploadIcon from '../icons/upload.svg';
|
27
|
+
import DownloadIcon from '../icons/download.svg';
|
27
28
|
import FileIcon from '../icons/file.svg';
|
28
29
|
import StatusSuccessIcon from '../icons/status-success.svg';
|
29
30
|
import StatusFailIcon from '../icons/status-fail.svg';
|
@@ -120,6 +121,7 @@ registerIcon('view', ViewIcon);
|
|
120
121
|
registerIcon('remove', RemoveIcon);
|
121
122
|
registerIcon('retry', RetryIcon);
|
122
123
|
registerIcon('upload', UploadIcon);
|
124
|
+
registerIcon('download', DownloadIcon);
|
123
125
|
registerIcon('file', FileIcon);
|
124
126
|
registerIcon('status-success', StatusSuccessIcon);
|
125
127
|
registerIcon('status-fail', StatusFailIcon);
|
package/src/envOverwrite.ts
CHANGED
@@ -4,18 +4,31 @@
|
|
4
4
|
|
5
5
|
import {SchemaNode, Schema} from './types';
|
6
6
|
import {RendererProps, RendererConfig, addSchemaFilter} from './factory';
|
7
|
+
import {findObjectsWithKey} from './utils/helper';
|
7
8
|
const isMobile = (window as any).matchMedia?.('(max-width: 768px)').matches
|
8
9
|
? true
|
9
10
|
: false;
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
// 这里不能用 addSchemaFilter 是因为还需要更深层的替换,比如 select 里的 options
|
13
|
+
export const envOverwrite = (schema: any, locale?: string) => {
|
14
|
+
if (schema.mobile && isMobile) {
|
15
|
+
Object.assign(schema, schema.mobile);
|
16
|
+
delete schema.mobile;
|
14
17
|
}
|
15
18
|
|
16
|
-
if (
|
17
|
-
|
19
|
+
if (locale) {
|
20
|
+
let schemaNodes = findObjectsWithKey(schema, locale);
|
21
|
+
for (let schemaNode of schemaNodes) {
|
22
|
+
Object.assign(schemaNode, schemaNode[locale]);
|
23
|
+
delete schemaNode[locale];
|
24
|
+
}
|
18
25
|
}
|
19
26
|
|
20
|
-
|
21
|
-
|
27
|
+
if (isMobile) {
|
28
|
+
let schemaNodes = findObjectsWithKey(schema, 'mobile');
|
29
|
+
for (let schemaNode of schemaNodes) {
|
30
|
+
Object.assign(schemaNode, schemaNode['mobile']);
|
31
|
+
delete schemaNode['mobile'];
|
32
|
+
}
|
33
|
+
}
|
34
|
+
};
|
package/src/factory.tsx
CHANGED
@@ -3,7 +3,14 @@ import {RendererStore, IRendererStore, IIRendererStore} from './store/index';
|
|
3
3
|
import {getEnv, destroy} from 'mobx-state-tree';
|
4
4
|
import {wrapFetcher} from './utils/api';
|
5
5
|
import {normalizeLink} from './utils/normalizeLink';
|
6
|
-
import {
|
6
|
+
import {
|
7
|
+
findIndex,
|
8
|
+
isObject,
|
9
|
+
JSONTraverse,
|
10
|
+
promisify,
|
11
|
+
qsparse,
|
12
|
+
string2regExp
|
13
|
+
} from './utils/helper';
|
7
14
|
import {
|
8
15
|
Api,
|
9
16
|
fetcherResult,
|
@@ -25,6 +32,7 @@ import {getDefaultLocale, makeTranslator, LocaleProps} from './locale';
|
|
25
32
|
import ScopedRootRenderer, {RootRenderProps} from './Root';
|
26
33
|
import {HocStoreFactory} from './WithStore';
|
27
34
|
import {EnvContext, RendererEnv} from './env';
|
35
|
+
import {envOverwrite} from './envOverwrite';
|
28
36
|
|
29
37
|
export interface TestFunc {
|
30
38
|
(
|
@@ -127,12 +135,20 @@ export interface RenderOptions {
|
|
127
135
|
affixOffsetTop?: number;
|
128
136
|
affixOffsetBottom?: number;
|
129
137
|
richTextToken?: string;
|
138
|
+
/**
|
139
|
+
* 替换文本,用于实现 URL 替换、语言替换等
|
140
|
+
*/
|
141
|
+
replaceText?: {[propName: string]: any};
|
142
|
+
/**
|
143
|
+
* 文本替换的黑名单,因为属性太多了所以改成黑名单的 fangs
|
144
|
+
*/
|
145
|
+
replaceTextIgnoreKeys?: String[];
|
130
146
|
[propName: string]: any;
|
131
147
|
}
|
132
148
|
|
133
149
|
export interface fetcherConfig {
|
134
150
|
url: string;
|
135
|
-
method?: 'get' | 'post' | 'put' | 'patch' | 'delete';
|
151
|
+
method?: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'jsonp';
|
136
152
|
data?: any;
|
137
153
|
config?: any;
|
138
154
|
}
|
@@ -275,19 +291,19 @@ const defaultOptions: RenderOptions = {
|
|
275
291
|
},
|
276
292
|
isCancel() {
|
277
293
|
console.error(
|
278
|
-
'Please
|
294
|
+
'Please implement isCancel. see https://baidu.gitee.io/amis/docs/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
|
279
295
|
);
|
280
296
|
return false;
|
281
297
|
},
|
282
298
|
updateLocation() {
|
283
299
|
console.error(
|
284
|
-
'Please
|
300
|
+
'Please implement updateLocation. see https://baidu.gitee.io/amis/docs/start/getting-started#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97'
|
285
301
|
);
|
286
302
|
},
|
287
303
|
alert,
|
288
304
|
confirm,
|
289
305
|
notify: (type, msg, conf) =>
|
290
|
-
toast[type] ? toast[type](msg) : console.warn('[Notify]', type, msg),
|
306
|
+
toast[type] ? toast[type](msg, conf) : console.warn('[Notify]', type, msg),
|
291
307
|
|
292
308
|
jumpTo: (to: string, action?: any) => {
|
293
309
|
if (to === 'goBack') {
|
@@ -335,7 +351,15 @@ const defaultOptions: RenderOptions = {
|
|
335
351
|
},
|
336
352
|
// 用于跟踪用户在界面中的各种操作
|
337
353
|
tracker(eventTrack: EventTrack, props: PlainObject) {},
|
338
|
-
rendererResolver: resolveRenderer
|
354
|
+
rendererResolver: resolveRenderer,
|
355
|
+
replaceTextIgnoreKeys: [
|
356
|
+
'type',
|
357
|
+
'name',
|
358
|
+
'mode',
|
359
|
+
'target',
|
360
|
+
'reload',
|
361
|
+
'persistData'
|
362
|
+
]
|
339
363
|
};
|
340
364
|
let stores: {
|
341
365
|
[propName: string]: IRendererStore;
|
@@ -355,6 +379,9 @@ export function render(
|
|
355
379
|
const translate = props.translate || makeTranslator(locale);
|
356
380
|
let store = stores[options.session || 'global'];
|
357
381
|
|
382
|
+
// 根据环境覆盖 schema,这个要在最前面做,不然就无法覆盖 validations
|
383
|
+
envOverwrite(schema, locale);
|
384
|
+
|
358
385
|
if (!store) {
|
359
386
|
options = {
|
360
387
|
...defaultOptions,
|
@@ -387,6 +414,25 @@ export function render(
|
|
387
414
|
env.locale = locale;
|
388
415
|
}
|
389
416
|
|
417
|
+
// 进行文本替换
|
418
|
+
if (env.replaceText && isObject(env.replaceText)) {
|
419
|
+
const replaceKeys = Object.keys(env.replaceText);
|
420
|
+
replaceKeys.sort().reverse(); // 避免用户将短的放前面
|
421
|
+
const replaceTextIgnoreKeys = new Set(env.replaceTextIgnoreKeys || []);
|
422
|
+
JSONTraverse(schema, (value: any, key: string, object: any) => {
|
423
|
+
if (typeof value === 'string' && !replaceTextIgnoreKeys.has(key)) {
|
424
|
+
for (const replaceKey of replaceKeys) {
|
425
|
+
if (~value.indexOf(replaceKey)) {
|
426
|
+
object[key] = value.replaceAll(
|
427
|
+
replaceKey,
|
428
|
+
env.replaceText[replaceKey]
|
429
|
+
);
|
430
|
+
}
|
431
|
+
}
|
432
|
+
}
|
433
|
+
});
|
434
|
+
}
|
435
|
+
|
390
436
|
return (
|
391
437
|
<EnvContext.Provider value={env}>
|
392
438
|
<ScopedRootRenderer
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="download" class="svg-inline--fa fa-download fa-w-16" role="img"
|
2
|
+
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
3
|
+
<path fill="currentColor" d="M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"></path>
|
4
|
+
</svg>
|