@@ -3,49 +3,9 @@ import { htm } from "@ivi/tpl";
3
3
import { Entry , State , Action , ActionType } from "./types.js" ;
4
4
5
5
const random = ( max : number ) => Math . round ( Math . random ( ) * 1000 ) % max ;
6
- const A = [
7
- "pretty" ,
8
- "large" ,
9
- "big" ,
10
- "small" ,
11
- "tall" ,
12
- "short" ,
13
- "long" ,
14
- "handsome" ,
15
- "plain" ,
16
- "quaint" ,
17
- "clean" ,
18
- "elegant" ,
19
- "easy" ,
20
- "angry" ,
21
- "crazy" ,
22
- "helpful" ,
23
- "mushy" ,
24
- "odd" ,
25
- "unsightly" ,
26
- "adorable" ,
27
- "important" ,
28
- "inexpensive" ,
29
- "cheap" ,
30
- "expensive" ,
31
- "fancy" ,
32
- ] ;
6
+ const A = [ "pretty" , "large" , "big" , "small" , "tall" , "short" , "long" , "handsome" , "plain" , "quaint" , "clean" , "elegant" , "easy" , "angry" , "crazy" , "helpful" , "mushy" , "odd" , "unsightly" , "adorable" , "important" , "inexpensive" , "cheap" , "expensive" , "fancy" ] ;
33
7
const C = [ "red" , "yellow" , "blue" , "green" , "pink" , "brown" , "purple" , "brown" , "white" , "black" , "orange" ] ;
34
- const N = [
35
- "table" ,
36
- "chair" ,
37
- "house" ,
38
- "bbq" ,
39
- "desk" ,
40
- "car" ,
41
- "pony" ,
42
- "cookie" ,
43
- "sandwich" ,
44
- "burger" ,
45
- "pizza" ,
46
- "mouse" ,
47
- "keyboard" ,
48
- ] ;
8
+ const N = [ "table" , "chair" , "house" , "bbq" , "desk" , "car" , "pony" , "cookie" , "sandwich" , "burger" , "pizza" , "mouse" , "keyboard" ] ;
49
9
50
10
let nextId = 1 ;
51
11
function buildData ( count : number ) : Entry [ ] {
@@ -104,19 +64,15 @@ interface RowProps {
104
64
}
105
65
106
66
const Row = component < RowProps > ( ( c ) => {
107
- const onSelect = ( ) => {
108
- dispatch ( c , { type : ActionType . Select , entry : getProps ( c ) . entry } ) ;
109
- } ;
110
- const onRemove = ( ) => {
111
- dispatch ( c , { type : ActionType . Remove , entry : getProps ( c ) . entry } ) ;
112
- } ;
67
+ const onSelect = ( ) => { dispatch ( c , { type : ActionType . Select , entry : getProps ( c ) . entry } ) ; } ;
68
+ const onRemove = ( ) => { dispatch ( c , { type : ActionType . Remove , entry : getProps ( c ) . entry } ) ; } ;
113
69
return ( { entry, selected } ) => htm `
114
70
tr${ selected === true ? "danger" : "" }
115
71
td.col-md-1 =${ entry . id }
116
72
td.col-md-4
117
- a.lbl @click=${ onSelect } =${ entry . label }
73
+ a @click=${ onSelect } =${ entry . label }
118
74
td.col-md-1
119
- a.remove @click=${ onRemove } span.remove .glyphicon.glyphicon-remove :aria-hidden='true'
75
+ a @click=${ onRemove } span.glyphicon.glyphicon-remove :aria-hidden='true'
120
76
td.col-md-6
121
77
` ;
122
78
} ) ;
@@ -130,28 +86,14 @@ const Button = (text: string, id: string, onClick: () => void) => /* preventClon
130
86
const App = component ( ( c ) => {
131
87
const [ _state , _dispatch ] = useReducer ( c , INITIAL_STATE , appStateReducer ) ;
132
88
133
- const onDispatch = ( ev : CustomEvent < Action > ) => {
134
- _dispatch ( ev . detail ) ;
135
- } ;
89
+ const onDispatch = ( ev : CustomEvent < Action > ) => { _dispatch ( ev . detail ) ; } ;
136
90
const buttons = [
137
- Button ( "Create 1,000 rows" , "run" , ( ) => {
138
- _dispatch ( { type : ActionType . Run } ) ;
139
- } ) ,
140
- Button ( "Create 10,000 rows" , "runlots" , ( ) => {
141
- _dispatch ( { type : ActionType . RunLots } ) ;
142
- } ) ,
143
- Button ( "Append 1,000 rows" , "add" , ( ) => {
144
- _dispatch ( { type : ActionType . Add } ) ;
145
- } ) ,
146
- Button ( "Update every 10th row" , "update" , ( ) => {
147
- _dispatch ( { type : ActionType . Update } ) ;
148
- } ) ,
149
- Button ( "Clear" , "clear" , ( ) => {
150
- _dispatch ( { type : ActionType . Clear } ) ;
151
- } ) ,
152
- Button ( "Swap Rows" , "swaprows" , ( ) => {
153
- _dispatch ( { type : ActionType . SwapRows } ) ;
154
- } ) ,
91
+ Button ( "Create 1,000 rows" , "run" , ( ) => { _dispatch ( { type : ActionType . Run } ) ; } ) ,
92
+ Button ( "Create 10,000 rows" , "runlots" , ( ) => { _dispatch ( { type : ActionType . RunLots } ) ; } ) ,
93
+ Button ( "Append 1,000 rows" , "add" , ( ) => { _dispatch ( { type : ActionType . Add } ) ; } ) ,
94
+ Button ( "Update every 10th row" , "update" , ( ) => { _dispatch ( { type : ActionType . Update } ) ; } ) ,
95
+ Button ( "Clear" , "clear" , ( ) => { _dispatch ( { type : ActionType . Clear } ) ; } ) ,
96
+ Button ( "Swap Rows" , "swaprows" , ( ) => { _dispatch ( { type : ActionType . SwapRows } ) ; } ) ,
155
97
] ;
156
98
157
99
return ( ) => {
@@ -164,20 +106,16 @@ const App = component((c) => {
164
106
div.col-md-6 div.row ${ buttons }
165
107
table.table.table-hover.table-striped.test-data
166
108
@dispatch=${ onDispatch }
167
- ${
168
- data . length
169
- ? htm `tbody ${ List ( data , getEntryId , ( entry ) => Row ( { entry, selected : selected === entry . id } ) ) } `
170
- : htm `tbody`
171
- }
109
+ ${ data . length
110
+ ? htm `tbody ${ List ( data , getEntryId , ( entry ) => Row ( { entry, selected : selected === entry . id } ) ) } `
111
+ : htm `tbody` }
172
112
span.preloadicon.glyphicon.glyphicon-remove :aria-hidden='true'
173
113
` ;
174
114
} ;
175
115
} ) ;
176
116
177
117
update (
178
118
// Defines a custom root node that disables batching for benchmark.
179
- defineRoot ( ( root ) => {
180
- dirtyCheck ( root ) ;
181
- } ) ( document . getElementById ( "main" ) ! ) ,
119
+ defineRoot ( ( root ) => { dirtyCheck ( root ) ; } ) ( document . getElementById ( "main" ) ! ) ,
182
120
App ( )
183
121
) ;
0 commit comments