| 13 | // creats rows but it keep track of created data so |
| 14 | // that it's possible to modify it and reflect next time it's needed |
| 15 | export const create = (count, add) => { |
| 16 | if (count < 1) { |
| 17 | if (count < 0) return DATA; |
| 18 | else TR = null; |
| 19 | } |
| 20 | if (add) count += SIZE; |
| 21 | else DATA = []; |
| 22 | for (let i = add ? SIZE : 0; i < count; i++) { |
| 23 | const id = ID++; |
| 24 | DATA[i] = { id, label: label(), selected: SEL === id }; |
| 25 | } |
| 26 | SIZE = count; |
| 27 | return DATA; |
| 28 | }; |
| 29 | |
| 30 | // create once a handler that keep data state updated |
| 31 | // by selecting something or removing it |