forked from Workiva/react-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_components.dart
62 lines (57 loc) · 1.8 KB
/
test_components.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'package:react/react.dart';
import 'package:react/react_client.dart' show ReactComponentFactory;
/// Base component for event handling classes used in test cases.
class EventComponent extends Component {
getInitialState() => {'text': ''};
onEvent(SyntheticEvent e) => setState({'text': '${e.type} ${e.timeStamp}'});
render() => div(
{
'onBlur': onEvent,
'onChange': onEvent,
'onClick': onEvent,
'onCopy': onEvent,
'onCut': onEvent,
'onDoubleClick': onEvent,
'onDrag': onEvent,
'onDragEnd': onEvent,
'onDragEnter': onEvent,
'onDragExit': onEvent,
'onDragLeave': onEvent,
'onDragOver': onEvent,
'onDragStart': onEvent,
'onDrop': onEvent,
'onFocus': onEvent,
'onInput': onEvent,
'onKeyDown': onEvent,
'onKeyPress': onEvent,
'onKeyUp': onEvent,
'onMouseDown': onEvent,
'onMouseMove': onEvent,
'onMouseOut': onEvent,
'onMouseOver': onEvent,
'onMouseUp': onEvent,
'onPaste': onEvent,
'onScroll': onEvent,
'onSubmit': onEvent,
'onTextInput': onEvent,
'onTouchCancel': onEvent,
'onTouchEnd': onEvent,
'onTouchMove': onEvent,
'onTouchStart': onEvent,
'onWheel': onEvent
},
state['text']
);
}
ReactComponentFactory eventComponent = registerComponent(() =>
new EventComponent());
class SampleComponent extends Component {
render() => div({}, [
h1({}, 'A header'),
div({'className': 'div1'}, 'First div'),
div({}, 'Second div'),
span({'className': 'span1'})
]);
}
ReactComponentFactory sampleComponent = registerComponent(() =>
new SampleComponent());