Skip to content

Commit 2c232e1

Browse files
committed
refactor: upgrade dlightjs to the latest alpha version
1 parent b1da229 commit 2c232e1

File tree

12 files changed

+1552
-1600
lines changed

12 files changed

+1552
-1600
lines changed

frameworks/keyed/dlightjs-subview/package-lock.json

Lines changed: 60 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/keyed/dlightjs-subview/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"url": "https://github.com/dlight-js/dlight.git"
1919
},
2020
"dependencies": {
21-
"@dlightjs/dlight": "1.0.0-alpha.1"
21+
"@dlightjs/dlight": "^1.0.0-alpha.18"
2222
},
2323
"devDependencies": {
24-
"babel-preset-dlight": "1.0.0-alpha.1",
2524
"@babel/core": "7.15.0",
2625
"@babel/plugin-proposal-class-properties": "^7.18.6",
27-
"@babel/plugin-proposal-decorators": "^7.23.0",
26+
"@babel/plugin-proposal-decorators": "^7.23.6",
2827
"@rollup/plugin-babel": "5.3.0",
2928
"@rollup/plugin-node-resolve": "13.0.4",
29+
"babel-preset-dlight": "1.0.0-alpha.13",
3030
"rollup": "2.52.3",
3131
"rollup-plugin-terser": "7.0.2"
3232
}

frameworks/keyed/dlightjs-subview/src/data.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

frameworks/keyed/dlightjs-subview/src/main.js

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
import { View, render } from "@dlightjs/dlight"
2-
import { buildData } from "./data"
2+
3+
let idCounter = 1
4+
5+
const adjectives = ["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"]
6+
const colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"]
7+
const nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"]
8+
9+
function _random(max) { return Math.round(Math.random() * 1000) % max };
10+
11+
function buildData(count) {
12+
const data = new Array(count)
13+
for (let i = 0; i < count; i++) {
14+
data[i] = {
15+
id: idCounter++,
16+
label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`
17+
}
18+
}
19+
return data
20+
}
321

422
@View
523
class Main {
@@ -11,9 +29,7 @@ class Main {
1129

1230
swapRows() {
1331
if (this.rows.length > 998) {
14-
const tmp = this.rows[1]
15-
this.rows[1] = this.rows[998]
16-
this.rows[998] = tmp
32+
[this.rows[1], this.rows[998]] = [this.rows[998], this.rows[1]]
1733
this.rows = [...this.rows]
1834
}
1935
}
@@ -27,20 +43,20 @@ class Main {
2743
}
2844

2945
deleteRow(id) {
30-
this.rows = [...this.rows.filter(row => row.id !== id)]
46+
this.rows = this.rows.filter(row => row.id !== id)
3147
}
3248

3349
addBig() {
3450
this.rows = buildData(10000)
3551
}
3652

3753
append() {
38-
this.rows = [...this.rows, ...buildData(1000)]
54+
this.rows = this.rows.concat(buildData(1000))
3955
}
4056

4157
update() {
4258
for (let i = 0; i < this.rows.length; i += 10) {
43-
this.rows[i] = { ...this.rows[i], label: this.rows[i].label + " !!!" }
59+
this.rows[i].label += " !!!"
4460
}
4561
this.rows = [...this.rows]
4662
}
@@ -64,24 +80,12 @@ class Main {
6480
}
6581
div().class("col-md-6"); {
6682
div().class("row"); {
67-
this.Button("Create 1,000 rows")
68-
.onClick(this.addRows)
69-
.id("run")
70-
this.Button("Create 10,000 rows")
71-
.onClick(this.addBig)
72-
.id("runlots")
73-
this.Button("Append 1,000 rows")
74-
.onClick(this.append)
75-
.id("add")
76-
this.Button("Update every 10th rows")
77-
.onClick(this.update)
78-
.id("update")
79-
this.Button("Clear")
80-
.onClick(this.clearRows)
81-
.id("clear")
82-
this.Button("Swap Rows")
83-
.onClick(this.swapRows)
84-
.id("swaprows")
83+
this.Button("Create 1,000 rows").onClick(this.addRows).id("run")
84+
this.Button("Create 10,000 rows").onClick(this.addBig).id("runlots")
85+
this.Button("Append 1,000 rows").onClick(this.append).id("add")
86+
this.Button("Update every 10th rows").onClick(this.update).id("update")
87+
this.Button("Clear").onClick(this.clearRows).id("clear")
88+
this.Button("Swap Rows").onClick(this.swapRows).id("swaprows")
8589
}
8690
}
8791
}
@@ -93,8 +97,7 @@ class Main {
9397
tr().class(this.selectIdx === id ? "danger" : ""); {
9498
td(id).class("col-md-1")
9599
td().class("col-md-4"); {
96-
a(label)
97-
.onClick(this.selectRow.bind(this, id))
100+
a(label).onClick(this.selectRow.bind(this, id))
98101
}
99102
td().class("col-md-1"); {
100103
a().onClick(this.deleteRow.bind(this, id)); {

0 commit comments

Comments
 (0)