react-ui-basics 0.0.219 → 0.0.221
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/Animated.js +1 -0
- package/Animated.js.map +1 -1
- package/Button.d.ts +24 -0
- package/Button.js +45 -75
- package/Button.js.map +1 -1
- package/DNDContainer.js +10 -5
- package/DNDContainer.js.map +1 -1
- package/DNDDraggable.d.ts +29 -0
- package/DNDDraggable.js +27 -44
- package/DNDDraggable.js.map +1 -1
- package/DNDDroppable.d.ts +28 -0
- package/DNDDroppable.js +32 -46
- package/DNDDroppable.js.map +1 -1
- package/Dialog.d.ts +29 -0
- package/Dialog.js +84 -143
- package/Dialog.js.map +1 -1
- package/DroppableHorizontalList.js +28 -27
- package/DroppableHorizontalList.js.map +1 -1
- package/DroppableList.js +29 -34
- package/DroppableList.js.map +1 -1
- package/Dropzone.js.map +1 -1
- package/FilteredList.d.ts +62 -0
- package/FilteredList.js +128 -232
- package/FilteredList.js.map +1 -1
- package/FormUploadProgress.d.ts +19 -0
- package/FormUploadProgress.js +14 -39
- package/FormUploadProgress.js.map +1 -1
- package/Modal.d.ts +31 -0
- package/Modal.js +102 -134
- package/Modal.js.map +1 -1
- package/ReactConstants.d.ts +6 -2
- package/ReactConstants.js +1 -1
- package/ReactConstants.js.map +1 -1
- package/ReactCreateElement.d.ts +3 -0
- package/ReactCreateElement.js.map +1 -1
- package/ReadyListener.d.ts +34 -0
- package/ReadyListener.js +34 -56
- package/ReadyListener.js.map +1 -1
- package/Scrollable.css +0 -1
- package/Scrollable.d.ts +33 -0
- package/Scrollable.js +308 -325
- package/Scrollable.js.map +1 -1
- package/ScrollableTable.d.ts +4 -2
- package/ScrollableTable.js +5 -6
- package/ScrollableTable.js.map +1 -1
- package/Table.js +1 -1
- package/Table.js.map +1 -1
- package/TextField.d.ts +36 -0
- package/TextField.js +73 -134
- package/TextField.js.map +1 -1
- package/Tools.d.ts +1 -1
- package/Tools.js +1 -1
- package/Tools.js.map +1 -1
- package/_virtual/_rollupPluginBabelHelpers.js +0 -15
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/bundle.css +903 -904
- package/package.json +1 -1
- package/router/Route.js +1 -0
- package/router/Route.js.map +1 -1
- package/src/Button.tsx +96 -0
- package/src/DNDContainer.tsx +19 -10
- package/src/{DNDDraggable.js → DNDDraggable.tsx} +35 -9
- package/src/{DNDDroppable.js → DNDDroppable.tsx} +35 -8
- package/src/{Dialog.js → Dialog.tsx} +63 -44
- package/src/DroppableHorizontalList.js +33 -32
- package/src/DroppableList.js +34 -41
- package/src/Dropzone.tsx +1 -1
- package/src/{FilteredList.js → FilteredList.tsx} +95 -45
- package/src/{FormUploadProgress.js → FormUploadProgress.tsx} +13 -22
- package/src/{Modal.js → Modal.tsx} +48 -33
- package/src/ReactConstants.ts +14 -6
- package/src/ReactCreateElement.tsx +3 -0
- package/src/ReadyListener.tsx +58 -0
- package/src/Scrollable.css +0 -1
- package/src/Scrollable.scss +0 -1
- package/src/{Scrollable.js → Scrollable.tsx} +72 -60
- package/src/ScrollableTable.tsx +7 -7
- package/src/Table.tsx +3 -3
- package/src/{TextField.js → TextField.tsx} +42 -44
- package/src/Tools.ts +2 -2
- package/src/store/Store.test.js +1 -1
- package/src/store/Store.ts +3 -1
- package/store/Store.js +1 -0
- package/store/Store.js.map +1 -1
- package/src/Button.js +0 -98
- package/src/ReactCreateElement.js +0 -3
- package/src/ReadyListener.js +0 -48
|
@@ -39,6 +39,37 @@ class DroppableHorizontalList extends Component {
|
|
|
39
39
|
let oldIndex;
|
|
40
40
|
let newIndex;
|
|
41
41
|
|
|
42
|
+
const onHover = (e, draggable) => {
|
|
43
|
+
const offset = __pageX(e) - that.scrollOffsetX;
|
|
44
|
+
const transformLeft = 'translateX(' + __width(draggable) + 'px)';
|
|
45
|
+
const transformRight = 'translateX(-' + __width(draggable) + 'px)';
|
|
46
|
+
list.forEach((id, i) => {
|
|
47
|
+
if (i !== oldIndex) {
|
|
48
|
+
const d = draggables[id];
|
|
49
|
+
const bounds = d.bounds;
|
|
50
|
+
const style = d.element.style;
|
|
51
|
+
if (i > oldIndex) {
|
|
52
|
+
if (offset >= __left(bounds))
|
|
53
|
+
style.transform = transformRight;
|
|
54
|
+
else
|
|
55
|
+
style.transform = '';
|
|
56
|
+
} else {
|
|
57
|
+
if (offset <= bounds.right)
|
|
58
|
+
style.transform = transformLeft;
|
|
59
|
+
else
|
|
60
|
+
style.transform = '';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
let i = list.findIndex(id => {
|
|
66
|
+
let bounds = draggables[id].bounds;
|
|
67
|
+
return offset >= __left(bounds) && offset <= bounds.right
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
newIndex = i !== -1 ? i : __length(list);
|
|
71
|
+
};
|
|
72
|
+
|
|
42
73
|
that[ReactConstants[0]] = () => {
|
|
43
74
|
let inTransition = false;
|
|
44
75
|
orNoop(props().provideDraggableEnhancer)(initializer => it => {
|
|
@@ -46,6 +77,7 @@ class DroppableHorizontalList extends Component {
|
|
|
46
77
|
it.createPositionListener = (e, style) => {
|
|
47
78
|
const offset = __pageX(e);
|
|
48
79
|
return e => {
|
|
80
|
+
onHover(e, it)
|
|
49
81
|
__pageX(e) && (style.transform = 'translateX(' + (__pageX(e) - offset) + 'px)');
|
|
50
82
|
};
|
|
51
83
|
};
|
|
@@ -80,41 +112,10 @@ class DroppableHorizontalList extends Component {
|
|
|
80
112
|
})
|
|
81
113
|
};
|
|
82
114
|
|
|
83
|
-
const onHover = (e, draggable) => {
|
|
84
|
-
const offset = __pageX(e) - that.scrollOffsetX;
|
|
85
|
-
const transformLeft = 'translateX(' + __width(draggable) + 'px)';
|
|
86
|
-
const transformRight = 'translateX(-' + __width(draggable) + 'px)';
|
|
87
|
-
list.forEach((id, i) => {
|
|
88
|
-
if (i !== oldIndex) {
|
|
89
|
-
const d = draggables[id];
|
|
90
|
-
const bounds = d.bounds;
|
|
91
|
-
const style = d.element.style;
|
|
92
|
-
if (i > oldIndex) {
|
|
93
|
-
if (offset >= __left(bounds))
|
|
94
|
-
style.transform = transformRight;
|
|
95
|
-
else
|
|
96
|
-
style.transform = '';
|
|
97
|
-
} else {
|
|
98
|
-
if (offset <= bounds.right)
|
|
99
|
-
style.transform = transformLeft;
|
|
100
|
-
else
|
|
101
|
-
style.transform = '';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
let i = list.findIndex(id => {
|
|
107
|
-
let bounds = draggables[id].bounds;
|
|
108
|
-
return offset >= __left(bounds) && offset <= bounds.right
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
newIndex = i !== -1 ? i : __length(list);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
115
|
const onDragStart = (e, draggable) => {
|
|
115
116
|
dragging = true;
|
|
116
117
|
dropped = false;
|
|
117
|
-
oldIndex = list.indexOf(
|
|
118
|
+
oldIndex = list.indexOf(draggable.id);
|
|
118
119
|
that.scrollOffsetX = __pageX(e) - e.clientX;
|
|
119
120
|
|
|
120
121
|
list.forEach((id) => {
|
package/src/DroppableList.js
CHANGED
|
@@ -39,6 +39,37 @@ class DroppableList extends Component {
|
|
|
39
39
|
let oldIndex;
|
|
40
40
|
let newIndex;
|
|
41
41
|
|
|
42
|
+
const onHover = (e, draggable) => {
|
|
43
|
+
const y = __pageY(e) - that.scrollOffsetY;
|
|
44
|
+
const transformUp = 'translateY(' + __height(draggable) + 'px)';
|
|
45
|
+
const transformDown = 'translateY(-' + __height(draggable) + 'px)';
|
|
46
|
+
list.forEach((id, i) => {
|
|
47
|
+
if (i !== oldIndex) {
|
|
48
|
+
const d = draggables[id];
|
|
49
|
+
const bounds = d.bounds;
|
|
50
|
+
const style = d.element.style;
|
|
51
|
+
if (i > oldIndex) {
|
|
52
|
+
if (y >= __top(bounds))
|
|
53
|
+
style.transform = transformDown;
|
|
54
|
+
else
|
|
55
|
+
style.transform = '';
|
|
56
|
+
} else {
|
|
57
|
+
if (y <= bounds.bottom)
|
|
58
|
+
style.transform = transformUp;
|
|
59
|
+
else
|
|
60
|
+
style.transform = '';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
let i = list.findIndex(id => {
|
|
66
|
+
let bounds = draggables[id].bounds;
|
|
67
|
+
return y >= __top(bounds) && y <= bounds.bottom
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
newIndex = i !== -1 ? i : __length(list);
|
|
71
|
+
};
|
|
72
|
+
|
|
42
73
|
that[ReactConstants[0]] = () => {
|
|
43
74
|
let inTransition = false;
|
|
44
75
|
orNoop(props().provideDraggableEnhancer)(initializer => it => {
|
|
@@ -46,7 +77,8 @@ class DroppableList extends Component {
|
|
|
46
77
|
it.createPositionListener = (e, style) => {
|
|
47
78
|
const offsetTop = __pageY(e);
|
|
48
79
|
return e => {
|
|
49
|
-
|
|
80
|
+
onHover(e, it)
|
|
81
|
+
__pageY(e) && (style.transform = 'translateY(' + (__pageY(e) - offsetTop) + 'px)');
|
|
50
82
|
};
|
|
51
83
|
};
|
|
52
84
|
it.initDraggedStyles = NOOP;
|
|
@@ -79,52 +111,13 @@ class DroppableList extends Component {
|
|
|
79
111
|
draggables[getProps(it).id] = it;
|
|
80
112
|
})
|
|
81
113
|
|
|
82
|
-
orNoop(props().provideScrollListener)(e => {
|
|
83
|
-
if (!dragging)
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
that.scrollDiff = that.scroll - orNoop(props().getScrollPosition)() || 0;
|
|
87
|
-
})
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const onHover = (e, draggable) => {
|
|
91
|
-
const y = __pageY(e) - that.scrollOffsetY - that.scrollDiff;
|
|
92
|
-
const transformUp = 'translateY(' + __height(draggable) + 'px)';
|
|
93
|
-
const transformDown = 'translateY(-' + __height(draggable) + 'px)';
|
|
94
|
-
list.forEach((id, i) => {
|
|
95
|
-
if (i !== oldIndex) {
|
|
96
|
-
const d = draggables[id];
|
|
97
|
-
const bounds = d.bounds;
|
|
98
|
-
const style = d.element.style;
|
|
99
|
-
if (i > oldIndex) {
|
|
100
|
-
if (y >= __top(bounds))
|
|
101
|
-
style.transform = transformDown;
|
|
102
|
-
else
|
|
103
|
-
style.transform = '';
|
|
104
|
-
} else {
|
|
105
|
-
if (y <= bounds.bottom)
|
|
106
|
-
style.transform = transformUp;
|
|
107
|
-
else
|
|
108
|
-
style.transform = '';
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
let i = list.findIndex(id => {
|
|
114
|
-
let bounds = draggables[id].bounds;
|
|
115
|
-
return y >= __top(bounds) && y <= bounds.bottom
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
newIndex = i !== -1 ? i : __length(list);
|
|
119
114
|
};
|
|
120
115
|
|
|
121
116
|
const onDragStart = (e, draggable) => {
|
|
122
117
|
dragging = true;
|
|
123
118
|
dropped = false;
|
|
124
|
-
oldIndex = list.indexOf(
|
|
119
|
+
oldIndex = list.indexOf(draggable.id);
|
|
125
120
|
that.scrollOffsetY = __pageY(e) - e.clientY;
|
|
126
|
-
that.scroll = orNoop(props().getScrollPosition)() || 0;
|
|
127
|
-
that.scrollDiff = 0;
|
|
128
121
|
|
|
129
122
|
list.forEach((id) => {
|
|
130
123
|
draggables[id].bounds = draggables[id].element.getBoundingClientRect();
|
package/src/Dropzone.tsx
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, {CSSProperties, MouseEventHandler} from 'react';
|
|
2
2
|
import ReactCreateElement from './ReactCreateElement';
|
|
3
3
|
import './FilteredList.css'
|
|
4
4
|
import Scrollable from "./Scrollable";
|
|
5
5
|
import {classNames, orNoop, ref, stopPropagation, isFunction, isObject} from "./Tools";
|
|
6
6
|
import {PureComponent} from "./ReactConstants";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
type Labels<T> = ((item: T) => string) | { [key: string]: string } | { [key: number]: string };
|
|
9
|
+
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
export const getLabel: (<T extends string | number>(labels: Labels<T>, id: T) => string) = (labels, id) => isFunction(labels) ? labels(id) : labels[id]
|
|
12
|
+
|
|
13
|
+
export interface FilteredListProps<T> {
|
|
14
|
+
nextProvider?: (cb: () => void) => void
|
|
15
|
+
prevProvider?: (cb: () => void) => void
|
|
16
|
+
resetProvider?: (cb: () => void) => void
|
|
17
|
+
selectedProvider?: (cb: () => void) => void
|
|
18
|
+
data: T[]
|
|
19
|
+
labels?: Labels<T>
|
|
20
|
+
filter?: (item: T) => boolean
|
|
21
|
+
className?: string
|
|
22
|
+
selected?: T | { [key: string]: boolean } | { [key: number]: boolean }
|
|
23
|
+
inline?: boolean
|
|
24
|
+
childComponent
|
|
25
|
+
childProps
|
|
26
|
+
style?: CSSProperties
|
|
27
|
+
scroll
|
|
28
|
+
onSelect: (selected: T) => void
|
|
29
|
+
selectSingle?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface FilteredListState<T> {
|
|
33
|
+
selected: T
|
|
34
|
+
}
|
|
9
35
|
|
|
10
|
-
class FilteredList extends PureComponent {
|
|
36
|
+
class FilteredList<T extends string|number> extends PureComponent<FilteredListProps<T>, FilteredListState<T>> {
|
|
11
37
|
|
|
12
38
|
static defaultProps = {
|
|
13
39
|
data: [],
|
|
@@ -18,59 +44,66 @@ class FilteredList extends PureComponent {
|
|
|
18
44
|
filter: () => true,
|
|
19
45
|
};
|
|
20
46
|
|
|
47
|
+
hidden:Map<T, boolean> = new Map();
|
|
48
|
+
elements :Map<T, HTMLDivElement> = new Map();
|
|
49
|
+
list:T[] = [];
|
|
50
|
+
el: Scrollable
|
|
51
|
+
|
|
21
52
|
constructor(props) {
|
|
22
53
|
super(props);
|
|
23
|
-
this.state = {selected:
|
|
24
|
-
this.hidden = {};
|
|
25
|
-
this.elements = {};
|
|
54
|
+
this.state = {selected: null};
|
|
26
55
|
}
|
|
27
56
|
|
|
28
57
|
componentDidMount() {
|
|
29
|
-
orNoop(
|
|
30
|
-
orNoop(
|
|
31
|
-
orNoop(
|
|
32
|
-
orNoop(
|
|
58
|
+
orNoop(this.props.nextProvider)(this.next);
|
|
59
|
+
orNoop(this.props.prevProvider)(this.prev);
|
|
60
|
+
orNoop(this.props.selectedProvider)(this.selected);
|
|
61
|
+
orNoop(this.props.resetProvider)(this.reset);
|
|
33
62
|
|
|
34
|
-
this.updateList(
|
|
63
|
+
this.updateList(this.props)
|
|
35
64
|
}
|
|
36
65
|
|
|
37
66
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
38
|
-
if (
|
|
67
|
+
if (this.props.data === prevProps.data)
|
|
39
68
|
return;
|
|
40
69
|
|
|
41
|
-
this.updateList(
|
|
70
|
+
this.updateList(this.props)
|
|
42
71
|
}
|
|
43
72
|
|
|
44
73
|
updateList = (props) => {
|
|
45
74
|
const {data} = props;
|
|
46
|
-
const {selected} =
|
|
75
|
+
const {selected} = this.state;
|
|
47
76
|
this.list = data || [];
|
|
48
77
|
|
|
49
78
|
if (!this.list.includes(selected))
|
|
50
|
-
this.setState({selected:
|
|
79
|
+
this.setState({selected: null})
|
|
51
80
|
};
|
|
52
81
|
|
|
53
82
|
render() {
|
|
54
|
-
const {data, labels, filter, className, selected, inline, childComponent, childProps, style, scroll} =
|
|
83
|
+
const {data, labels, filter, className, selected, inline, childComponent, childProps, style, scroll} = this.props;
|
|
55
84
|
return (
|
|
56
85
|
<Scrollable className={classNames('FilteredList', className, inline ? 'inline' : 'popup')}
|
|
57
86
|
autoScrollTop={false}
|
|
58
87
|
ref={ref('el', this)} style={style} scrollBarMode={scroll}>
|
|
59
|
-
{(data || []).filter(id => id
|
|
88
|
+
{(data || []).filter(id => !!id || id === 0).map(id => <ItemWrapper
|
|
60
89
|
id={id}
|
|
61
90
|
key={id}
|
|
62
91
|
label={getLabel(labels, id)}
|
|
63
92
|
childComponent={childComponent}
|
|
64
93
|
childProps={childProps}
|
|
65
|
-
element={el => this.elements
|
|
94
|
+
element={el => this.elements.set(id, el)}
|
|
66
95
|
onClick={e => {
|
|
67
96
|
stopPropagation(e);
|
|
68
97
|
this.onSelect(id);
|
|
69
98
|
}}
|
|
70
99
|
onMouseEnter={e => this.setState({selected: id})}
|
|
71
|
-
onMouseLeave={e => id ===
|
|
72
|
-
className={classNames('child',
|
|
73
|
-
classProvider={it =>
|
|
100
|
+
onMouseLeave={e => id === this.state.selected && this.setState({selected: null})}
|
|
101
|
+
className={classNames('child', this.state.selected === id && 'active', selected === id || (isObject(selected) && selected[id as (string | number)]) && 'selected')}
|
|
102
|
+
classProvider={it => {
|
|
103
|
+
const hidden = !filter(it);
|
|
104
|
+
this.hidden.set(id, hidden)
|
|
105
|
+
return hidden && 'hidden';
|
|
106
|
+
}}
|
|
74
107
|
/>)}
|
|
75
108
|
</Scrollable>
|
|
76
109
|
)
|
|
@@ -78,17 +111,17 @@ class FilteredList extends PureComponent {
|
|
|
78
111
|
|
|
79
112
|
onSelect = (id) => {
|
|
80
113
|
this.setState({selected: id});
|
|
81
|
-
|
|
114
|
+
this.props.onSelect(id);
|
|
82
115
|
};
|
|
83
116
|
|
|
84
|
-
selected = () => {
|
|
85
|
-
const {selected: value} =
|
|
86
|
-
const {selectSingle} =
|
|
117
|
+
selected = (): T => {
|
|
118
|
+
const {selected: value} = this.state;
|
|
119
|
+
const {selectSingle} = this.props;
|
|
87
120
|
|
|
88
121
|
|
|
89
|
-
if (value === -1 || this.hidden
|
|
90
|
-
let filtered = this.list.filter(id => !this.hidden
|
|
91
|
-
if (selectSingle &&
|
|
122
|
+
if (value === -1 || this.hidden.get(value)) {
|
|
123
|
+
let filtered = this.list.filter(id => !this.hidden.get(id));
|
|
124
|
+
if (selectSingle && filtered.length === 1)
|
|
92
125
|
return filtered[0];
|
|
93
126
|
|
|
94
127
|
return null;
|
|
@@ -99,16 +132,16 @@ class FilteredList extends PureComponent {
|
|
|
99
132
|
|
|
100
133
|
next = () => {
|
|
101
134
|
const list = this.list;
|
|
102
|
-
const selected =
|
|
135
|
+
const selected = this.state.selected;
|
|
103
136
|
let position = list.findIndex(id => selected === id);
|
|
104
|
-
if (this.hidden
|
|
137
|
+
if (this.hidden.get(list[position]))
|
|
105
138
|
position = -1;
|
|
106
139
|
|
|
107
|
-
while (++position <
|
|
108
|
-
if (!this.hidden
|
|
140
|
+
while (++position < list.length) {
|
|
141
|
+
if (!this.hidden.get(list[position]))
|
|
109
142
|
break
|
|
110
143
|
}
|
|
111
|
-
if (position <
|
|
144
|
+
if (position < list.length) {
|
|
112
145
|
let id = list[position];
|
|
113
146
|
this.setState({selected: id});
|
|
114
147
|
this.updateScroll(id)
|
|
@@ -117,13 +150,13 @@ class FilteredList extends PureComponent {
|
|
|
117
150
|
|
|
118
151
|
prev = () => {
|
|
119
152
|
const list = this.list;
|
|
120
|
-
const selected =
|
|
153
|
+
const selected = this.state.selected;
|
|
121
154
|
let position = list.findIndex(id => selected === id);
|
|
122
|
-
if (this.hidden
|
|
123
|
-
position =
|
|
155
|
+
if (this.hidden.get(list[position]))
|
|
156
|
+
position = list.length;
|
|
124
157
|
|
|
125
158
|
while (--position >= 0) {
|
|
126
|
-
if (!this.hidden
|
|
159
|
+
if (!this.hidden.get(list[position]))
|
|
127
160
|
break
|
|
128
161
|
}
|
|
129
162
|
if (position >= 0) {
|
|
@@ -138,9 +171,9 @@ class FilteredList extends PureComponent {
|
|
|
138
171
|
let container = this.el;
|
|
139
172
|
const scrollTop = container.getScroll();
|
|
140
173
|
const height = container.getHeight();
|
|
141
|
-
let isVisible = scrollTop <= child.offsetTop && scrollTop + height >= child.offsetTop +
|
|
174
|
+
let isVisible = scrollTop <= child.offsetTop && scrollTop + height >= child.offsetTop + child.clientHeight;
|
|
142
175
|
if (!isVisible) {
|
|
143
|
-
let scrollToBottom = child.offsetTop +
|
|
176
|
+
let scrollToBottom = child.offsetTop + child.clientHeight - height;
|
|
144
177
|
let scrollToTop = child.offsetTop;
|
|
145
178
|
if (Math.abs(scrollTop - scrollToTop) < Math.abs(scrollTop - scrollToBottom)) {
|
|
146
179
|
container.setScroll(scrollToTop)
|
|
@@ -151,8 +184,8 @@ class FilteredList extends PureComponent {
|
|
|
151
184
|
};
|
|
152
185
|
|
|
153
186
|
reset = () => {
|
|
154
|
-
this.setState({selected:
|
|
155
|
-
this.el.
|
|
187
|
+
this.setState({selected: null});
|
|
188
|
+
this.el.setScroll(0)
|
|
156
189
|
};
|
|
157
190
|
|
|
158
191
|
scrollTo = (id) => this.el.setScroll(this.elements[id] && this.elements[id].offsetTop);
|
|
@@ -160,9 +193,26 @@ class FilteredList extends PureComponent {
|
|
|
160
193
|
|
|
161
194
|
export default FilteredList;
|
|
162
195
|
|
|
163
|
-
|
|
196
|
+
interface ItemWrapperProps {
|
|
197
|
+
id
|
|
198
|
+
label
|
|
199
|
+
onClick?: MouseEventHandler
|
|
200
|
+
onMouseDown?: MouseEventHandler
|
|
201
|
+
onMouseEnter?: MouseEventHandler
|
|
202
|
+
onMouseLeave?: MouseEventHandler
|
|
203
|
+
classProvider?: (data) => string
|
|
204
|
+
className?: string
|
|
205
|
+
childComponent
|
|
206
|
+
childProps
|
|
207
|
+
element?: (el: HTMLDivElement) => void
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
class ItemWrapper extends React.Component<ItemWrapperProps> {
|
|
211
|
+
data
|
|
212
|
+
el: HTMLDivElement
|
|
213
|
+
|
|
164
214
|
render() {
|
|
165
|
-
const {id, label, onClick, onMouseDown, onMouseEnter, onMouseLeave, classProvider, className, childComponent, childProps} =
|
|
215
|
+
const {id, label, onClick, onMouseDown, onMouseEnter, onMouseLeave, classProvider, className, childComponent, childProps} = this.props;
|
|
166
216
|
const child = React.createElement(childComponent, {
|
|
167
217
|
...childProps,
|
|
168
218
|
id,
|
|
@@ -170,7 +220,7 @@ class ItemWrapper extends React.Component {
|
|
|
170
220
|
dataConsumer: (data) => this.data = data,
|
|
171
221
|
});
|
|
172
222
|
|
|
173
|
-
const cssClass = orNoop(classProvider)(
|
|
223
|
+
const cssClass = orNoop(classProvider)(this.data);
|
|
174
224
|
return (
|
|
175
225
|
<div className={classNames('ItemWrapper', cssClass, className)}
|
|
176
226
|
onMouseEnter={onMouseEnter}
|
|
@@ -185,7 +235,7 @@ class ItemWrapper extends React.Component {
|
|
|
185
235
|
}
|
|
186
236
|
|
|
187
237
|
componentDidMount() {
|
|
188
|
-
orNoop(
|
|
238
|
+
orNoop(this.props.element)(this.el);
|
|
189
239
|
this.forceUpdate();
|
|
190
240
|
}
|
|
191
241
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, {ReactNode} from 'react';
|
|
2
2
|
import ReactCreateElement from './ReactCreateElement';
|
|
3
3
|
import './FormUploadProgress.css'
|
|
4
4
|
import Button from "./Button";
|
|
@@ -6,11 +6,10 @@ import Animated from "./Animated";
|
|
|
6
6
|
import CircleProgress from "./CircleProgress";
|
|
7
7
|
import SpinningProgress from "./SpinningProgress";
|
|
8
8
|
import {formatAbbreviation, formatNumberWithMaxLength} from "./Size";
|
|
9
|
-
import PropTypes from "prop-types";
|
|
10
9
|
import {preventDefault} from "./Tools";
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
const defaultValueFormat = (value, loaded, total) => {
|
|
12
|
+
const defaultValueFormat = (value: number, loaded: number, total: number) => {
|
|
14
13
|
if (total == null)
|
|
15
14
|
return Math.floor(Number.isFinite(value) ? value : 0) + '%';
|
|
16
15
|
|
|
@@ -24,6 +23,16 @@ const defaultValueFormat = (value, loaded, total) => {
|
|
|
24
23
|
</>
|
|
25
24
|
};
|
|
26
25
|
|
|
26
|
+
export interface FormUploadProgressProps {
|
|
27
|
+
value: number
|
|
28
|
+
loaded: number
|
|
29
|
+
total: number
|
|
30
|
+
formatValue?: (value: number, loaded: number, total: number) => ReactNode
|
|
31
|
+
processingLabel?: ReactNode
|
|
32
|
+
cancelLabel?: ReactNode
|
|
33
|
+
cancel?: () => void
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
const FormUploadProgress = ({
|
|
28
37
|
value,
|
|
29
38
|
cancel,
|
|
@@ -32,7 +41,7 @@ const FormUploadProgress = ({
|
|
|
32
41
|
formatValue,
|
|
33
42
|
processingLabel,
|
|
34
43
|
cancelLabel,
|
|
35
|
-
}) => {
|
|
44
|
+
}: FormUploadProgressProps) => {
|
|
36
45
|
return (
|
|
37
46
|
<Animated value={total > 0}>
|
|
38
47
|
<div className="FormUploadProgress">
|
|
@@ -60,22 +69,4 @@ FormUploadProgress.defaultProps = {
|
|
|
60
69
|
formatValue: defaultValueFormat,
|
|
61
70
|
};
|
|
62
71
|
|
|
63
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
64
|
-
FormUploadProgress.propTypes = {
|
|
65
|
-
value: PropTypes.number,
|
|
66
|
-
loaded: PropTypes.number,
|
|
67
|
-
total: PropTypes.number,
|
|
68
|
-
formatValue: PropTypes.func,
|
|
69
|
-
processingLabel: PropTypes.oneOfType([
|
|
70
|
-
PropTypes.string,
|
|
71
|
-
PropTypes.element
|
|
72
|
-
]),
|
|
73
|
-
cancelLabel: PropTypes.oneOfType([
|
|
74
|
-
PropTypes.string,
|
|
75
|
-
PropTypes.element
|
|
76
|
-
]),
|
|
77
|
-
cancel: PropTypes.func,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
72
|
export default FormUploadProgress;
|