@lango-project/lango-client 0.4.0 → 0.4.1
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/README.md +37 -4
- package/cli/.lango/runtime.mjs +8 -1
- package/cli/create.mjs +0 -0
- package/dist/.lango/runtime.mjs +8 -1
- package/dist/app.mjs +37 -2
- package/dist/app.mjs.map +1 -1
- package/dist/client.css +7 -0
- package/dist/control.mjs +2 -0
- package/dist/control.mjs.map +1 -1
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/form.mjs +1 -1
- package/dist/form.mjs.map +1 -1
- package/dist/index.html +1 -1
- package/dist/main.mjs +11 -2
- package/dist/main.mjs.map +1 -1
- package/dist/renderer.mjs +15 -13
- package/dist/renderer.mjs.map +1 -1
- package/dist/table_scope.mjs +166 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +798 -115
- package/dist/tables.mjs.map +1 -1
- package/dist/vendor/dompurify.mjs +181 -267
- package/dist/vendor/purify.es.mjs.map +1 -1
- package/docs/implementation.md +51 -0
- package/package.json +2 -2
- package/src/app.lango +35 -3
- package/src/control.lango +3 -0
- package/src/dimensions.lango +65 -0
- package/src/form.lango +1 -1
- package/src/main.lango +9 -0
- package/src/renderer.lango +17 -9
- package/src/table_scope.lango +119 -0
- package/src/tables.lango +620 -105
- package/web/client.css +7 -0
- package/web/index.html +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import js global Object
|
|
2
|
+
import js global Reflect
|
|
3
|
+
import js global Promise
|
|
4
|
+
|
|
5
|
+
export class TableScope(parent)
|
|
6
|
+
properties
|
|
7
|
+
parent
|
|
8
|
+
requestForm
|
|
9
|
+
app
|
|
10
|
+
token
|
|
11
|
+
controls
|
|
12
|
+
owned
|
|
13
|
+
resources
|
|
14
|
+
disposed
|
|
15
|
+
methods
|
|
16
|
+
register(name, control)
|
|
17
|
+
unregister(control)
|
|
18
|
+
find(name)
|
|
19
|
+
getValue()
|
|
20
|
+
setValue(values)
|
|
21
|
+
prepareValue()
|
|
22
|
+
clearValidation()
|
|
23
|
+
clearResources()
|
|
24
|
+
send(url)
|
|
25
|
+
dispose()
|
|
26
|
+
|
|
27
|
+
TableScope(parent)
|
|
28
|
+
@parent = parent
|
|
29
|
+
@app = parent.app
|
|
30
|
+
@requestForm = parent
|
|
31
|
+
if parent.requestForm != null
|
|
32
|
+
@requestForm = parent.requestForm
|
|
33
|
+
token = ()
|
|
34
|
+
return @requestForm.token
|
|
35
|
+
Object/defineProperty(@this, "token", {
|
|
36
|
+
get: token
|
|
37
|
+
})
|
|
38
|
+
@controls = Object/create(null)
|
|
39
|
+
@owned = []
|
|
40
|
+
@resources = []
|
|
41
|
+
@disposed = false
|
|
42
|
+
|
|
43
|
+
TableScope:register(name, control)
|
|
44
|
+
if name != null
|
|
45
|
+
if !is_string(name) or name == "" or name.includes("/") or name in @controls
|
|
46
|
+
control.dispose()
|
|
47
|
+
throw "Invalid or duplicate control name: ${name}"
|
|
48
|
+
@controls[name] = control
|
|
49
|
+
@owned.add(control)
|
|
50
|
+
return control
|
|
51
|
+
|
|
52
|
+
TableScope:unregister(control)
|
|
53
|
+
for Object/keys(@controls) as name
|
|
54
|
+
if @controls[name] == control
|
|
55
|
+
Reflect/deleteProperty(@controls, name)
|
|
56
|
+
index = @owned.indexOf(control)
|
|
57
|
+
if index >= 0
|
|
58
|
+
@owned.splice(index, 1)
|
|
59
|
+
return null
|
|
60
|
+
|
|
61
|
+
TableScope:find(name)
|
|
62
|
+
parts = name.split("/")
|
|
63
|
+
child = @controls[parts.shift()]
|
|
64
|
+
if child == null
|
|
65
|
+
throw "Unknown control: ${name}"
|
|
66
|
+
if parts.length > 0
|
|
67
|
+
if child.find == null
|
|
68
|
+
throw "Control has no named children: ${name}"
|
|
69
|
+
return child.find(parts.join("/"))
|
|
70
|
+
return child
|
|
71
|
+
|
|
72
|
+
TableScope:getValue()
|
|
73
|
+
result = Object/create(null)
|
|
74
|
+
for @controls as name: control
|
|
75
|
+
result[name] = control.getValue()
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
TableScope:setValue(values)
|
|
79
|
+
if !is_object(values) or is_array(values)
|
|
80
|
+
throw "Multiple cell controls require a value map"
|
|
81
|
+
for values as name: value
|
|
82
|
+
find(name).setValue(value)
|
|
83
|
+
return @this
|
|
84
|
+
|
|
85
|
+
TableScope:prepareValue()
|
|
86
|
+
pending = []
|
|
87
|
+
for @owned as control
|
|
88
|
+
if control.prepareValue != null
|
|
89
|
+
ready = control.prepareValue()
|
|
90
|
+
if ready != null
|
|
91
|
+
pending.add(ready)
|
|
92
|
+
if pending.length == 0
|
|
93
|
+
return null
|
|
94
|
+
return Promise/all(pending)
|
|
95
|
+
|
|
96
|
+
TableScope:clearValidation()
|
|
97
|
+
for @owned as control
|
|
98
|
+
if control.clearValidation != null
|
|
99
|
+
control.clearValidation()
|
|
100
|
+
return null
|
|
101
|
+
|
|
102
|
+
TableScope:clearResources()
|
|
103
|
+
return @parent.clearResources()
|
|
104
|
+
|
|
105
|
+
TableScope:send(url)
|
|
106
|
+
return @parent.send(url)
|
|
107
|
+
|
|
108
|
+
TableScope:dispose()
|
|
109
|
+
if @disposed
|
|
110
|
+
return null
|
|
111
|
+
@disposed = true
|
|
112
|
+
for @owned.slice() as control
|
|
113
|
+
control.dispose()
|
|
114
|
+
for @resources as release
|
|
115
|
+
release()
|
|
116
|
+
@owned = []
|
|
117
|
+
@controls = Object/create(null)
|
|
118
|
+
@resources = []
|
|
119
|
+
return null
|