@lango-project/lango-client 0.4.0 → 0.4.2
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 +63 -4
- package/cli/.lango/runtime.mjs +24 -1
- package/cli/create.mjs +0 -0
- package/dist/.lango/runtime.mjs +24 -1
- package/dist/accordion.mjs +9 -8
- package/dist/accordion.mjs.map +1 -1
- package/dist/activities.mjs +8 -7
- package/dist/activities.mjs.map +1 -1
- package/dist/app.mjs +500 -50
- package/dist/app.mjs.map +1 -1
- package/dist/boot.mjs +3 -2
- package/dist/boot.mjs.map +1 -1
- package/dist/button.mjs +8 -7
- package/dist/button.mjs.map +1 -1
- package/dist/chip.mjs +5 -4
- package/dist/chip.mjs.map +1 -1
- package/dist/client.css +7 -0
- package/dist/combo_box.mjs +15 -14
- package/dist/combo_box.mjs.map +1 -1
- package/dist/content.mjs +9 -8
- package/dist/content.mjs.map +1 -1
- package/dist/control.mjs +2 -0
- package/dist/control.mjs.map +1 -1
- package/dist/date_input.mjs +3 -2
- package/dist/date_input.mjs.map +1 -1
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/error_reporter.mjs +6 -5
- package/dist/error_reporter.mjs.map +1 -1
- package/dist/fields.mjs +9 -8
- package/dist/fields.mjs.map +1 -1
- package/dist/file_input.mjs +19 -18
- package/dist/file_input.mjs.map +1 -1
- package/dist/form.mjs +15 -3
- package/dist/form.mjs.map +1 -1
- package/dist/heartbeat.mjs +12 -11
- package/dist/heartbeat.mjs.map +1 -1
- package/dist/index.html +1 -1
- package/dist/input_changes.mjs +5 -4
- package/dist/input_changes.mjs.map +1 -1
- package/dist/longpoll.mjs +12 -11
- package/dist/longpoll.mjs.map +1 -1
- package/dist/main.mjs +45 -19
- package/dist/main.mjs.map +1 -1
- package/dist/menus.mjs +19 -18
- package/dist/menus.mjs.map +1 -1
- package/dist/navigation.mjs +7 -6
- package/dist/navigation.mjs.map +1 -1
- package/dist/numeric_input.mjs +9 -8
- package/dist/numeric_input.mjs.map +1 -1
- package/dist/otp_input.mjs +5 -4
- package/dist/otp_input.mjs.map +1 -1
- package/dist/presentations.mjs +17 -16
- package/dist/presentations.mjs.map +1 -1
- package/dist/renderer.mjs +88 -12
- package/dist/renderer.mjs.map +1 -1
- package/dist/table_scope.mjs +167 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +809 -125
- package/dist/tables.mjs.map +1 -1
- package/dist/tabs.mjs +7 -6
- package/dist/tabs.mjs.map +1 -1
- package/dist/widgets.mjs +5 -4
- package/dist/widgets.mjs.map +1 -1
- package/docs/implementation.md +51 -0
- package/package.json +4 -3
- package/src/app.lango +358 -12
- package/src/control.lango +3 -0
- package/src/dimensions.lango +65 -0
- package/src/form.lango +13 -3
- package/src/heartbeat.lango +2 -2
- package/src/main.lango +24 -0
- package/src/renderer.lango +78 -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
package/dist/tables.mjs
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import { measure } from "./dimensions.mjs";
|
|
2
|
+
import { TableScope } from "./table_scope.mjs";
|
|
1
3
|
import { Control } from "./control.mjs";
|
|
4
|
+
import { Form } from "./form.mjs";
|
|
2
5
|
import { cloneMarkup } from "./templates.mjs";
|
|
3
6
|
import { appendContent, bindAction, decorate } from "./content.mjs";
|
|
4
7
|
import {
|
|
5
8
|
hostGlobal as __hostGlobal,
|
|
9
|
+
hostGlobalCall as __hostGlobalCall,
|
|
6
10
|
xmlEscape as __xmlEscape,
|
|
11
|
+
bindContexts as __bindContexts,
|
|
12
|
+
getClass as __getClass,
|
|
13
|
+
isKindof as __isKindof,
|
|
7
14
|
isNumber as __isNumber,
|
|
8
15
|
isString as __isString,
|
|
9
16
|
isBool as __isBool,
|
|
10
17
|
isObject as __isObject,
|
|
11
18
|
isArray as __isArray,
|
|
19
|
+
includes as __includes,
|
|
12
20
|
entries as __entries,
|
|
13
21
|
add as __add,
|
|
14
22
|
remove as __remove,
|
|
@@ -16,113 +24,468 @@ import {
|
|
|
16
24
|
normalize as __normalize,
|
|
17
25
|
finite as __finite,
|
|
18
26
|
numericAdd as __numericAdd,
|
|
27
|
+
call as __call,
|
|
19
28
|
boundary as __boundary,
|
|
20
29
|
requireArity as __requireArity,
|
|
21
30
|
withArity as __withArity,
|
|
22
31
|
} from "./.lango/runtime.mjs";
|
|
23
32
|
|
|
24
33
|
export class Table extends Control {
|
|
34
|
+
rows;
|
|
35
|
+
columns;
|
|
36
|
+
#renderer;
|
|
37
|
+
#props;
|
|
38
|
+
#building;
|
|
39
|
+
#mode;
|
|
40
|
+
#layout;
|
|
41
|
+
#lookup;
|
|
42
|
+
#header;
|
|
43
|
+
#aliases;
|
|
44
|
+
#table;
|
|
45
|
+
#body;
|
|
46
|
+
#template;
|
|
25
47
|
constructor(form, props, renderer) {
|
|
26
48
|
super(form, props, cloneMarkup("table", ["<div class=\"table-responsive\"><table class=\"table\"><colgroup></colgroup><tbody></tbody></table></div>"].join("")));
|
|
27
49
|
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
28
50
|
form = __boundary(form);
|
|
29
51
|
props = __boundary(props);
|
|
30
52
|
renderer = __boundary(renderer);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let width = 1;
|
|
38
|
-
let header = null;
|
|
39
|
-
if (__requireBoolean(__normalize(props.stripedRows) === true)) {
|
|
40
|
-
__add(table.classList, "table-striped");
|
|
53
|
+
this.#renderer = renderer;
|
|
54
|
+
this.#props = props;
|
|
55
|
+
this.#building = true;
|
|
56
|
+
this.#mode = __normalize(props.valueMode);
|
|
57
|
+
if (__requireBoolean(__normalize(this.#mode) === null)) {
|
|
58
|
+
this.#mode = "none";
|
|
41
59
|
}
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
let modes = ["none", "cells", "rows", "mixed"];
|
|
61
|
+
if (__requireBoolean(!__requireBoolean(__normalize(modes.includes(__normalize(this.#mode)))))) {
|
|
62
|
+
throw "Table valueMode must be none, cells, rows or mixed";
|
|
44
63
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
this.#layout = new TableScope(form);
|
|
65
|
+
this.#lookup = new TableScope(form);
|
|
66
|
+
this.rows = [];
|
|
67
|
+
this.columns = [];
|
|
68
|
+
this.#header = null;
|
|
69
|
+
this.#aliases = __normalize(__hostGlobal(["Object"]).create(null));
|
|
70
|
+
this.#table = __normalize(this.element.firstElementChild);
|
|
71
|
+
this.#body = __normalize(this.#table.lastElementChild);
|
|
72
|
+
this.#template = __normalize(props.rowTemplate);
|
|
73
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#template) !== null) && __requireBoolean(__normalize(this.#template.type) !== "tableRowTemplate"))) {
|
|
74
|
+
throw "Table rowTemplate requires a TableRowTemplate";
|
|
50
75
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
76
|
+
let table = __normalize(this.#table);
|
|
77
|
+
let group = __normalize(table.firstElementChild);
|
|
78
|
+
let headings = [];
|
|
79
|
+
let hasCaptions = false;
|
|
80
|
+
try {
|
|
81
|
+
if (__requireBoolean(__normalize(props.stripedRows) === true)) {
|
|
82
|
+
__add(table.classList, "table-striped");
|
|
83
|
+
}
|
|
84
|
+
if (__requireBoolean(__normalize(props.stripedColumns) === true)) {
|
|
85
|
+
__add(table.classList, "table-striped-columns");
|
|
86
|
+
}
|
|
87
|
+
if (__requireBoolean(__normalize(props.hoverableRows) === true)) {
|
|
88
|
+
__add(table.classList, "table-hover");
|
|
89
|
+
}
|
|
90
|
+
if (__requireBoolean(__normalize(props.small) === true)) {
|
|
91
|
+
__add(table.classList, "table-sm");
|
|
92
|
+
}
|
|
93
|
+
if (__requireBoolean(__requireBoolean(__normalize(props.border) !== null) && __requireBoolean(__normalize(props.border) !== false))) {
|
|
94
|
+
__add(table.classList, "table-bordered");
|
|
95
|
+
if (__requireBoolean(__isObject(__normalize(props.border)))) {
|
|
96
|
+
if (__requireBoolean(props.border.color !== null)) {
|
|
97
|
+
__normalize(table.style.setProperty("--bs-table-border-color", props.border.color));
|
|
98
|
+
}
|
|
99
|
+
if (__requireBoolean(props.border.width !== null)) {
|
|
100
|
+
__normalize(table.style.setProperty("--bs-border-width", `${props.border.width}px`));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (__requireBoolean(__normalize(props.caption) !== null)) {
|
|
105
|
+
let caption = __normalize(__hostGlobal(["document"]).createElement("caption"));
|
|
106
|
+
appendContent(__normalize(this.#layout), caption, __normalize(props.caption), renderer);
|
|
107
|
+
__normalize(table.prepend(caption));
|
|
108
|
+
}
|
|
109
|
+
if (__requireBoolean(__normalize(props.aria) !== null)) {
|
|
110
|
+
for (const [name, value] of __entries(__normalize(props.aria))) {
|
|
111
|
+
__normalize(table.setAttribute(`aria-${name}`, value));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (__requireBoolean(__normalize(props.controls) !== null)) {
|
|
115
|
+
for (const definition of __normalize(props.controls)) {
|
|
116
|
+
if (__normalize(definition.type) === "tableCol") {
|
|
117
|
+
let col = new TableCol(__normalize(this.#layout), definition);
|
|
118
|
+
__normalize(this.#layout.register(null, col));
|
|
119
|
+
col.name = __normalize(definition.name);
|
|
120
|
+
if (__requireBoolean(__normalize(col.name) !== null)) {
|
|
121
|
+
for (const previous of __normalize(this.columns)) {
|
|
122
|
+
if (__requireBoolean(__normalize(previous.name) === __normalize(col.name))) {
|
|
123
|
+
throw `Duplicate column name: ${__normalize(col.name)}`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.columns.push(col);
|
|
128
|
+
headings.push({ type: "tableCell", colSpan: __normalize(definition.colSpan), controls: __normalize(definition.caption) });
|
|
129
|
+
if (__requireBoolean(__normalize(definition.caption) !== null)) {
|
|
130
|
+
hasCaptions = true;
|
|
131
|
+
}
|
|
132
|
+
__normalize(group.appendChild(__normalize(col.element)));
|
|
133
|
+
} else if (__normalize(definition.type) === "tableHeader") {
|
|
134
|
+
if (__requireBoolean(__normalize(this.#header) !== null)) {
|
|
135
|
+
throw "Table accepts one TableHeader";
|
|
136
|
+
}
|
|
137
|
+
this.#header = new TableHeader(__normalize(this.#layout), definition, renderer);
|
|
138
|
+
__normalize(this.#layout.register(__normalize(definition.name), __normalize(this.#header)));
|
|
139
|
+
__normalize(table.insertBefore(__normalize(this.#header.element), __normalize(this.#body)));
|
|
140
|
+
} else if (__normalize(definition.type) === "tableRow") {
|
|
141
|
+
let row = new TableRow(form, definition, renderer, false);
|
|
142
|
+
this.rows.push(row);
|
|
143
|
+
__normalize(this.#body.appendChild(__normalize(row.element)));
|
|
144
|
+
} else if (__normalize(definition.type) === "tableDivider") {
|
|
145
|
+
let divider = new TableDivider(__normalize(this.#layout), definition);
|
|
146
|
+
__normalize(this.#layout.register(__normalize(definition.name), divider));
|
|
147
|
+
__normalize(this.#body.appendChild(__normalize(divider.element)));
|
|
148
|
+
} else {
|
|
149
|
+
throw `Unsupported Table child: ${__normalize(definition.type)}`;
|
|
150
|
+
}
|
|
56
151
|
}
|
|
57
|
-
|
|
58
|
-
|
|
152
|
+
}
|
|
153
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#header) === null) && __requireBoolean(hasCaptions))) {
|
|
154
|
+
let generated = { controls: [{ type: "tableRow", controls: headings }] };
|
|
155
|
+
this.#header = new TableHeader(__normalize(this.#layout), generated, renderer);
|
|
156
|
+
__normalize(this.#layout.register(null, __normalize(this.#header)));
|
|
157
|
+
__normalize(table.insertBefore(__normalize(this.#header.element), __normalize(this.#body)));
|
|
158
|
+
}
|
|
159
|
+
let width = 1;
|
|
160
|
+
for (const row of __normalize(this.rows)) {
|
|
161
|
+
width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
|
|
162
|
+
}
|
|
163
|
+
for (const child of __normalize(this.#layout.owned)) {
|
|
164
|
+
if (__requireBoolean(__isKindof(child, TableDivider))) {
|
|
165
|
+
applySpan(child.element.firstElementChild, "colspan", width);
|
|
59
166
|
}
|
|
60
167
|
}
|
|
168
|
+
if (__requireBoolean(__normalize(props.value) !== null)) {
|
|
169
|
+
this.setValue(__normalize(props.value));
|
|
170
|
+
} else {
|
|
171
|
+
this.publish(this.names(__normalize(this.rows)));
|
|
172
|
+
this.resize(__normalize(this.rows));
|
|
173
|
+
}
|
|
174
|
+
this.#building = false;
|
|
175
|
+
} catch (error) {
|
|
176
|
+
this.dispose();
|
|
177
|
+
throw error;
|
|
61
178
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
179
|
+
}
|
|
180
|
+
find(name) {
|
|
181
|
+
__requireArity(arguments.length, [0], "find");
|
|
182
|
+
name = __boundary(name);
|
|
183
|
+
return __normalize(this.#lookup.find(name));
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
names(rows, replace = false) {
|
|
187
|
+
__requireArity(arguments.length, [0], "names");
|
|
188
|
+
rows = __boundary(rows);
|
|
189
|
+
replace = __boundary(replace);
|
|
190
|
+
let result = __normalize(__hostGlobal(["Object"]).create(null));
|
|
191
|
+
for (const [name, control] of __entries(__normalize(this.#layout.controls))) {
|
|
192
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(replace)) || __requireBoolean(!__requireBoolean(__isKindof(control, TableDivider))))) {
|
|
193
|
+
addName(result, name, control);
|
|
194
|
+
}
|
|
66
195
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
196
|
+
let sources = __normalize(rows.slice());
|
|
197
|
+
if (__requireBoolean(__normalize(this.#header) !== null)) {
|
|
198
|
+
for (const row of __normalize(this.#header.rows)) {
|
|
199
|
+
__add(sources, row);
|
|
70
200
|
}
|
|
71
201
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
columns.push(col);
|
|
78
|
-
__normalize(group.appendChild(__normalize(col.element)));
|
|
79
|
-
} else if (__normalize(definition.type) === "tableHeader") {
|
|
80
|
-
if (__requireBoolean(header !== null)) {
|
|
81
|
-
throw "Table accepts one TableHeader";
|
|
82
|
-
}
|
|
83
|
-
header = new TableHeader(form, definition, renderer);
|
|
84
|
-
__normalize(form.register(__normalize(definition.name), header));
|
|
85
|
-
__normalize(table.insertBefore(__normalize(header.element), body));
|
|
86
|
-
for (const heading of __normalize(header.rows)) {
|
|
87
|
-
rows.push(heading);
|
|
88
|
-
}
|
|
89
|
-
} else if (__normalize(definition.type) === "tableRow") {
|
|
90
|
-
let row = new TableRow(form, definition, renderer, false);
|
|
91
|
-
__normalize(form.register(__normalize(definition.name), row));
|
|
92
|
-
rows.push(row);
|
|
93
|
-
__normalize(body.appendChild(__normalize(row.element)));
|
|
94
|
-
} else if (__normalize(definition.type) === "tableDivider") {
|
|
95
|
-
let divider = new TableDivider(form, definition);
|
|
96
|
-
__normalize(form.register(__normalize(definition.name), divider));
|
|
97
|
-
dividers.push(divider);
|
|
98
|
-
__normalize(body.appendChild(__normalize(divider.element)));
|
|
202
|
+
for (const row of sources) {
|
|
203
|
+
addName(result, __normalize(row.name), row);
|
|
204
|
+
for (const cell of __normalize(row.cells)) {
|
|
205
|
+
if (__requireBoolean(__normalize(cell.name) !== null)) {
|
|
206
|
+
addName(result, __normalize(cell.name), cell);
|
|
99
207
|
} else {
|
|
100
|
-
|
|
208
|
+
if (__requireBoolean(!__requireBoolean(__normalize(row.generated)))) {
|
|
209
|
+
for (const [name, control] of __entries(cell.scope.controls)) {
|
|
210
|
+
addName(result, name, control);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
publish(names) {
|
|
220
|
+
__requireArity(arguments.length, [0], "publish");
|
|
221
|
+
names = __boundary(names);
|
|
222
|
+
if (__requireBoolean(__normalize(this.#props.name) === null)) {
|
|
223
|
+
for (const [name, control] of __entries(names)) {
|
|
224
|
+
if (__requireBoolean(__requireBoolean(__includes(name, __normalize(this.form.controls))) && __requireBoolean(__normalize(this.form.controls[name]) !== __normalize(this.#aliases[name])))) {
|
|
225
|
+
throw `Invalid or duplicate control name: ${name}`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const [name, control] of __entries(__normalize(this.#aliases))) {
|
|
229
|
+
if (__requireBoolean(__normalize(this.form.controls[name]) === control)) {
|
|
230
|
+
__normalize(__hostGlobal(["Reflect"]).deleteProperty(__normalize(this.form.controls), name));
|
|
101
231
|
}
|
|
102
232
|
}
|
|
233
|
+
for (const [name, control] of __entries(names)) {
|
|
234
|
+
this.form.controls[name] = control;
|
|
235
|
+
}
|
|
236
|
+
this.#aliases = names;
|
|
237
|
+
}
|
|
238
|
+
this.#lookup.controls = names;
|
|
239
|
+
return null;
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
getValue() {
|
|
243
|
+
if (__requireBoolean(__normalize(this.#mode) === "none")) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
if (__requireBoolean(__normalize(this.#mode) === "cells")) {
|
|
247
|
+
return __normalize(this.#lookup.getValue());
|
|
103
248
|
}
|
|
249
|
+
let rows = [];
|
|
250
|
+
for (const row of __normalize(this.rows)) {
|
|
251
|
+
rows.push(__normalize(row.getRowValue(__normalize(this.columns))));
|
|
252
|
+
}
|
|
253
|
+
if (__requireBoolean(__normalize(this.#mode) === "rows")) {
|
|
254
|
+
return rows;
|
|
255
|
+
}
|
|
256
|
+
return { cells: __normalize(this.#lookup.getValue()), rows: rows };
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
prepareValue() {
|
|
260
|
+
let pending = [];
|
|
261
|
+
let ready = __normalize(this.#layout.prepareValue());
|
|
262
|
+
if (__requireBoolean(ready !== null)) {
|
|
263
|
+
pending.push(ready);
|
|
264
|
+
}
|
|
265
|
+
for (const row of __normalize(this.rows)) {
|
|
266
|
+
ready = __normalize(row.prepareValue());
|
|
267
|
+
if (__requireBoolean(ready !== null)) {
|
|
268
|
+
pending.push(ready);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return allReady(pending);
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
clearValidation() {
|
|
275
|
+
super.clearValidation();
|
|
276
|
+
if (__requireBoolean(__normalize(this.#layout) !== null)) {
|
|
277
|
+
__normalize(this.#layout.clearValidation());
|
|
278
|
+
}
|
|
279
|
+
if (__requireBoolean(__normalize(this.rows) !== null)) {
|
|
280
|
+
for (const row of __normalize(this.rows)) {
|
|
281
|
+
__normalize(row.clearValidation());
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
createRow(value) {
|
|
288
|
+
__requireArity(arguments.length, [0], "createRow");
|
|
289
|
+
value = __boundary(value);
|
|
290
|
+
rowValue(value);
|
|
291
|
+
let definition = null;
|
|
292
|
+
if (__requireBoolean(__normalize(this.#template) !== null)) {
|
|
293
|
+
definition = __hostGlobalCall(["structuredClone"], __normalize(this.#template));
|
|
294
|
+
} else {
|
|
295
|
+
let cells = [];
|
|
296
|
+
for (const column of __normalize(this.columns)) {
|
|
297
|
+
cells.push({ type: "tableCell", colSpan: __normalize(column.span) });
|
|
298
|
+
}
|
|
299
|
+
definition = { controls: cells };
|
|
300
|
+
}
|
|
301
|
+
let row = new TableRow(__normalize(this.form), definition, __normalize(this.#renderer), false);
|
|
302
|
+
row.generated = true;
|
|
303
|
+
try {
|
|
304
|
+
__normalize(row.setRowValue(value, __normalize(this.columns)));
|
|
305
|
+
} catch (error) {
|
|
306
|
+
__normalize(row.dispose());
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
return row;
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
setValue(values) {
|
|
313
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
314
|
+
values = __boundary(values);
|
|
315
|
+
if (__requireBoolean(values === null)) {
|
|
316
|
+
values = [];
|
|
317
|
+
}
|
|
318
|
+
if (__requireBoolean(!__requireBoolean(__isArray(values)))) {
|
|
319
|
+
throw "Table value must be an array of row maps";
|
|
320
|
+
}
|
|
321
|
+
let staged = [];
|
|
322
|
+
try {
|
|
323
|
+
for (const value of values) {
|
|
324
|
+
staged.push(this.createRow(value));
|
|
325
|
+
}
|
|
326
|
+
let next = this.names(staged, true);
|
|
327
|
+
validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
|
|
328
|
+
this.publish(next);
|
|
329
|
+
} catch (error) {
|
|
330
|
+
for (const row of staged) {
|
|
331
|
+
__normalize(row.dispose());
|
|
332
|
+
}
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
if (__requireBoolean(!__requireBoolean(__normalize(this.#building)))) {
|
|
336
|
+
__normalize(this.form.clearResources());
|
|
337
|
+
}
|
|
338
|
+
for (const row of __normalize(this.rows)) {
|
|
339
|
+
__normalize(row.dispose());
|
|
340
|
+
}
|
|
341
|
+
this.rows = staged;
|
|
342
|
+
__normalize(this.#body.replaceChildren());
|
|
343
|
+
for (const child of __normalize(this.#layout.owned.slice())) {
|
|
344
|
+
if (__requireBoolean(__isKindof(child, TableDivider))) {
|
|
345
|
+
__normalize(this.#layout.unregister(child));
|
|
346
|
+
__normalize(child.dispose());
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
for (const row of staged) {
|
|
350
|
+
__normalize(this.#body.appendChild(__normalize(row.element)));
|
|
351
|
+
}
|
|
352
|
+
this.resize(staged);
|
|
353
|
+
return this;
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
addRow(value = null) {
|
|
357
|
+
value = __boundary(value);
|
|
358
|
+
return this.insertRow(__normalize(this.rows.length), value);
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
insertRow(beforeIndex, value = null) {
|
|
362
|
+
__requireArity(arguments.length, [0], "insertRow");
|
|
363
|
+
beforeIndex = __boundary(beforeIndex);
|
|
364
|
+
value = __boundary(value);
|
|
365
|
+
tableIndex(beforeIndex, __normalize(this.rows.length), true);
|
|
366
|
+
let row = this.createRow(value);
|
|
367
|
+
let staged = __normalize(this.rows.slice());
|
|
368
|
+
__normalize(staged.splice(beforeIndex, 0, row));
|
|
369
|
+
try {
|
|
370
|
+
let next = this.names(staged);
|
|
371
|
+
validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
|
|
372
|
+
this.publish(next);
|
|
373
|
+
} catch (error) {
|
|
374
|
+
__normalize(row.dispose());
|
|
375
|
+
throw error;
|
|
376
|
+
}
|
|
377
|
+
__normalize(this.form.clearResources());
|
|
378
|
+
let anchor = null;
|
|
379
|
+
if (__requireBoolean(beforeIndex < __normalize(this.rows.length))) {
|
|
380
|
+
anchor = __normalize(__normalize(this.rows[beforeIndex]).element);
|
|
381
|
+
}
|
|
382
|
+
__normalize(this.#body.insertBefore(__normalize(row.element), anchor));
|
|
383
|
+
this.rows = staged;
|
|
384
|
+
this.resize(staged);
|
|
385
|
+
return this;
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
deleteRow(index) {
|
|
389
|
+
__requireArity(arguments.length, [0], "deleteRow");
|
|
390
|
+
index = __boundary(index);
|
|
391
|
+
tableIndex(index, __normalize(this.rows.length));
|
|
392
|
+
let staged = __normalize(this.rows.slice());
|
|
393
|
+
let row = __normalize(__normalize(staged.splice(index, 1))[0]);
|
|
394
|
+
validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
|
|
395
|
+
this.publish(this.names(staged));
|
|
396
|
+
__normalize(this.form.clearResources());
|
|
397
|
+
__normalize(row.dispose());
|
|
398
|
+
__remove(row.element);
|
|
399
|
+
this.rows = staged;
|
|
400
|
+
this.resize(staged);
|
|
401
|
+
return this;
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
setRowValue(index, value) {
|
|
405
|
+
__requireArity(arguments.length, [0, 1], "setRowValue");
|
|
406
|
+
index = __boundary(index);
|
|
407
|
+
value = __boundary(value);
|
|
408
|
+
tableIndex(index, __normalize(this.rows.length));
|
|
409
|
+
__normalize(__normalize(this.rows[index]).setRowValue(value, __normalize(this.columns)));
|
|
410
|
+
return this;
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
setRowData(index, value) {
|
|
414
|
+
__requireArity(arguments.length, [0, 1], "setRowData");
|
|
415
|
+
index = __boundary(index);
|
|
416
|
+
value = __boundary(value);
|
|
417
|
+
tableIndex(index, __normalize(this.rows.length));
|
|
418
|
+
let row = __normalize(this.rows[index]);
|
|
419
|
+
row.data = __hostGlobalCall(["structuredClone"], value);
|
|
420
|
+
return this;
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
setCellValue(index, column, value) {
|
|
424
|
+
__requireArity(arguments.length, [0, 1, 2], "setCellValue");
|
|
425
|
+
index = __boundary(index);
|
|
426
|
+
column = __boundary(column);
|
|
427
|
+
value = __boundary(value);
|
|
428
|
+
tableIndex(index, __normalize(this.rows.length));
|
|
429
|
+
let selected = columnIndex(column, __normalize(this.columns));
|
|
430
|
+
let row = __normalize(this.rows[index]);
|
|
431
|
+
tableIndex(selected, row.cells.length);
|
|
432
|
+
__normalize(row.cells[selected].setValue(value));
|
|
433
|
+
return this;
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
resize(rows) {
|
|
437
|
+
__requireArity(arguments.length, [0], "resize");
|
|
438
|
+
rows = __boundary(rows);
|
|
439
|
+
let width = 1;
|
|
104
440
|
for (const row of rows) {
|
|
105
|
-
|
|
106
|
-
|
|
441
|
+
width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
|
|
442
|
+
}
|
|
443
|
+
if (__requireBoolean(__normalize(this.#header) !== null)) {
|
|
444
|
+
for (const row of __normalize(this.#header.rows)) {
|
|
445
|
+
width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
|
|
107
446
|
}
|
|
108
447
|
}
|
|
109
|
-
for (const
|
|
110
|
-
|
|
448
|
+
for (const child of __normalize(this.#layout.owned)) {
|
|
449
|
+
if (__requireBoolean(__isKindof(child, TableDivider))) {
|
|
450
|
+
applySpan(child.element.firstElementChild, "colspan", width);
|
|
451
|
+
}
|
|
111
452
|
}
|
|
112
|
-
|
|
113
|
-
|
|
453
|
+
for (const col of __normalize(this.columns)) {
|
|
454
|
+
__normalize(col.detach());
|
|
455
|
+
}
|
|
456
|
+
let first = validateBoundaries(__normalize(this.#header), rows, __normalize(this.columns));
|
|
457
|
+
if (__requireBoolean(first !== null)) {
|
|
114
458
|
let offset = 0;
|
|
115
|
-
for (const col of columns) {
|
|
459
|
+
for (const col of __normalize(this.columns)) {
|
|
116
460
|
offset = __numericAdd(offset, __normalize(col.span));
|
|
117
461
|
if (__requireBoolean(__normalize(col.resize))) {
|
|
118
|
-
|
|
119
|
-
if (__requireBoolean(anchor === null)) {
|
|
120
|
-
throw "Resizable column must end at a first-row cell boundary";
|
|
121
|
-
}
|
|
122
|
-
__normalize(col.attach(anchor, table));
|
|
462
|
+
__normalize(col.attach(__normalize(first.boundary(offset)), __normalize(this.#table)));
|
|
123
463
|
}
|
|
124
464
|
}
|
|
125
465
|
}
|
|
466
|
+
return null;
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
dispose() {
|
|
470
|
+
if (__requireBoolean(__normalize(this.#aliases) !== null)) {
|
|
471
|
+
for (const [name, control] of __entries(__normalize(this.#aliases))) {
|
|
472
|
+
if (__requireBoolean(__normalize(this.form.controls[name]) === control)) {
|
|
473
|
+
__normalize(__hostGlobal(["Reflect"]).deleteProperty(__normalize(this.form.controls), name));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
this.#aliases = __normalize(__hostGlobal(["Object"]).create(null));
|
|
477
|
+
}
|
|
478
|
+
if (__requireBoolean(__normalize(this.rows) !== null)) {
|
|
479
|
+
for (const row of __normalize(this.rows)) {
|
|
480
|
+
__normalize(row.dispose());
|
|
481
|
+
}
|
|
482
|
+
this.rows = [];
|
|
483
|
+
}
|
|
484
|
+
if (__requireBoolean(__normalize(this.#layout) !== null)) {
|
|
485
|
+
__normalize(this.#layout.dispose());
|
|
486
|
+
}
|
|
487
|
+
return super.dispose();
|
|
488
|
+
return null;
|
|
126
489
|
}
|
|
127
490
|
}
|
|
128
491
|
|
|
@@ -136,23 +499,60 @@ export class TableHeader extends Control {
|
|
|
136
499
|
renderer = __boundary(renderer);
|
|
137
500
|
decorate(this, props);
|
|
138
501
|
this.rows = [];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
502
|
+
try {
|
|
503
|
+
if (__requireBoolean(__normalize(props.controls) !== null)) {
|
|
504
|
+
for (const definition of __normalize(props.controls)) {
|
|
505
|
+
if (__requireBoolean(__normalize(definition.type) !== "tableRow")) {
|
|
506
|
+
throw "TableHeader accepts TableRow definitions";
|
|
507
|
+
}
|
|
508
|
+
let row = new TableRow(form, definition, renderer, true);
|
|
509
|
+
this.rows.push(row);
|
|
510
|
+
__normalize(this.element.appendChild(__normalize(row.element)));
|
|
143
511
|
}
|
|
144
|
-
let row = new TableRow(form, definition, renderer, true);
|
|
145
|
-
__normalize(form.register(__normalize(definition.name), row));
|
|
146
|
-
this.rows.push(row);
|
|
147
|
-
__normalize(this.element.appendChild(__normalize(row.element)));
|
|
148
512
|
}
|
|
513
|
+
} catch (error) {
|
|
514
|
+
this.dispose();
|
|
515
|
+
throw error;
|
|
149
516
|
}
|
|
150
517
|
}
|
|
518
|
+
prepareValue() {
|
|
519
|
+
let pending = [];
|
|
520
|
+
for (const row of __normalize(this.rows)) {
|
|
521
|
+
let ready = __normalize(row.prepareValue());
|
|
522
|
+
if (__requireBoolean(ready !== null)) {
|
|
523
|
+
pending.push(ready);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return allReady(pending);
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
clearValidation() {
|
|
530
|
+
super.clearValidation();
|
|
531
|
+
if (__requireBoolean(__normalize(this.rows) !== null)) {
|
|
532
|
+
for (const row of __normalize(this.rows)) {
|
|
533
|
+
__normalize(row.clearValidation());
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return null;
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
dispose() {
|
|
540
|
+
for (const row of __normalize(this.rows)) {
|
|
541
|
+
__normalize(row.dispose());
|
|
542
|
+
}
|
|
543
|
+
this.rows = [];
|
|
544
|
+
return super.dispose();
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
151
547
|
}
|
|
152
548
|
|
|
153
549
|
export class TableRow extends Control {
|
|
550
|
+
name;
|
|
551
|
+
data;
|
|
552
|
+
generated;
|
|
154
553
|
width;
|
|
155
|
-
|
|
554
|
+
cells;
|
|
555
|
+
#scope;
|
|
156
556
|
constructor(form, props, renderer, heading) {
|
|
157
557
|
super(form, props, cloneMarkup("table-row", ["<tr></tr>"].join("")));
|
|
158
558
|
__requireArity(arguments.length, [0, 1, 2, 3], "constructor");
|
|
@@ -161,27 +561,36 @@ export class TableRow extends Control {
|
|
|
161
561
|
renderer = __boundary(renderer);
|
|
162
562
|
heading = __boundary(heading);
|
|
163
563
|
decorate(this, props);
|
|
564
|
+
this.name = __normalize(props.name);
|
|
565
|
+
this.data = __hostGlobalCall(["structuredClone"], __normalize(props.data));
|
|
566
|
+
this.generated = false;
|
|
164
567
|
this.width = 0;
|
|
165
|
-
this
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
568
|
+
this.cells = [];
|
|
569
|
+
this.#scope = new TableScope(form);
|
|
570
|
+
try {
|
|
571
|
+
if (__requireBoolean(__normalize(props.controls) !== null)) {
|
|
572
|
+
for (const definition of __normalize(props.controls)) {
|
|
573
|
+
if (__requireBoolean(__normalize(definition.type) !== "tableCell")) {
|
|
574
|
+
throw "TableRow accepts TableCell definitions";
|
|
575
|
+
}
|
|
576
|
+
let cell = new TableCell(__normalize(this.#scope), definition, renderer, heading);
|
|
577
|
+
__normalize(this.#scope.register(__normalize(definition.name), cell));
|
|
578
|
+
this.cells.push(cell);
|
|
579
|
+
this.width = __numericAdd(__normalize(this.width), cell.element.colSpan);
|
|
580
|
+
__normalize(this.element.appendChild(__normalize(cell.element)));
|
|
170
581
|
}
|
|
171
|
-
let cell = new TableCell(form, definition, renderer, heading);
|
|
172
|
-
__normalize(form.register(__normalize(definition.name), cell));
|
|
173
|
-
this.#cells.push(cell);
|
|
174
|
-
this.width = __numericAdd(__normalize(this.width), cell.element.colSpan);
|
|
175
|
-
__normalize(this.element.appendChild(__normalize(cell.element)));
|
|
176
582
|
}
|
|
583
|
+
bindAction(this, __normalize(this.element), __normalize(props.url));
|
|
584
|
+
} catch (error) {
|
|
585
|
+
this.dispose();
|
|
586
|
+
throw error;
|
|
177
587
|
}
|
|
178
|
-
bindAction(this, __normalize(this.element), __normalize(props.url));
|
|
179
588
|
}
|
|
180
589
|
boundary(column) {
|
|
181
590
|
__requireArity(arguments.length, [0], "boundary");
|
|
182
591
|
column = __boundary(column);
|
|
183
592
|
let offset = 0;
|
|
184
|
-
for (const cell of __normalize(this
|
|
593
|
+
for (const cell of __normalize(this.cells)) {
|
|
185
594
|
offset = __numericAdd(offset, cell.element.colSpan);
|
|
186
595
|
if (__requireBoolean(offset === column)) {
|
|
187
596
|
return __normalize(cell.element);
|
|
@@ -190,9 +599,72 @@ export class TableRow extends Control {
|
|
|
190
599
|
return null;
|
|
191
600
|
return null;
|
|
192
601
|
}
|
|
602
|
+
setRowValue(value, columns) {
|
|
603
|
+
__requireArity(arguments.length, [0, 1], "setRowValue");
|
|
604
|
+
value = __boundary(value);
|
|
605
|
+
columns = __boundary(columns);
|
|
606
|
+
rowValue(value);
|
|
607
|
+
for (const [index, cell] of __entries(__normalize(this.cells))) {
|
|
608
|
+
let name = __normalize(cell.name);
|
|
609
|
+
if (__requireBoolean(index < __normalize(columns.length))) {
|
|
610
|
+
name = __normalize(__normalize(columns[index]).name);
|
|
611
|
+
}
|
|
612
|
+
let field = null;
|
|
613
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(value !== null) && __requireBoolean(name !== null)) && __requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(value, name))))) {
|
|
614
|
+
field = __normalize(value[name]);
|
|
615
|
+
}
|
|
616
|
+
__normalize(cell.setValue(field));
|
|
617
|
+
}
|
|
618
|
+
return this;
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
getRowValue(columns) {
|
|
622
|
+
__requireArity(arguments.length, [0], "getRowValue");
|
|
623
|
+
columns = __boundary(columns);
|
|
624
|
+
let result = __normalize(__hostGlobal(["Object"]).create(null));
|
|
625
|
+
for (const [index, cell] of __entries(__normalize(this.cells))) {
|
|
626
|
+
let name = __normalize(cell.name);
|
|
627
|
+
if (__requireBoolean(index < __normalize(columns.length))) {
|
|
628
|
+
name = __normalize(__normalize(columns[index]).name);
|
|
629
|
+
}
|
|
630
|
+
if (__requireBoolean(name !== null)) {
|
|
631
|
+
if (__requireBoolean(__includes(name, result))) {
|
|
632
|
+
throw `Duplicate row value name: ${name}`;
|
|
633
|
+
}
|
|
634
|
+
result[name] = __normalize(cell.getValue());
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return result;
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
getValue() {
|
|
641
|
+
return __normalize(this.#scope.getValue());
|
|
642
|
+
return null;
|
|
643
|
+
}
|
|
644
|
+
prepareValue() {
|
|
645
|
+
return __normalize(this.#scope.prepareValue());
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
clearValidation() {
|
|
649
|
+
super.clearValidation();
|
|
650
|
+
if (__requireBoolean(__normalize(this.#scope) !== null)) {
|
|
651
|
+
__normalize(this.#scope.clearValidation());
|
|
652
|
+
}
|
|
653
|
+
return null;
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
dispose() {
|
|
657
|
+
if (__requireBoolean(__normalize(this.#scope) !== null)) {
|
|
658
|
+
__normalize(this.#scope.dispose());
|
|
659
|
+
}
|
|
660
|
+
return super.dispose();
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
193
663
|
}
|
|
194
664
|
|
|
195
665
|
export class TableCell extends Control {
|
|
666
|
+
name;
|
|
667
|
+
scope;
|
|
196
668
|
constructor(form, props, renderer, heading) {
|
|
197
669
|
super(form, props, cellElement(heading));
|
|
198
670
|
__requireArity(arguments.length, [0, 1, 2, 3], "constructor");
|
|
@@ -200,26 +672,92 @@ export class TableCell extends Control {
|
|
|
200
672
|
props = __boundary(props);
|
|
201
673
|
renderer = __boundary(renderer);
|
|
202
674
|
heading = __boundary(heading);
|
|
203
|
-
this.
|
|
204
|
-
this.
|
|
205
|
-
|
|
206
|
-
this.element
|
|
675
|
+
this.name = __normalize(props.name);
|
|
676
|
+
this.scope = new TableScope(form);
|
|
677
|
+
try {
|
|
678
|
+
applySpan(__normalize(this.element), "colspan", __normalize(props.colSpan));
|
|
679
|
+
applySpan(__normalize(this.element), "rowspan", __normalize(props.rowSpan));
|
|
680
|
+
if (__requireBoolean(__normalize(props.verticalAlignment) !== null)) {
|
|
681
|
+
this.element.style.verticalAlign = __normalize(props.verticalAlignment);
|
|
682
|
+
}
|
|
683
|
+
if (__requireBoolean(__normalize(props.horizontalAlignment) !== null)) {
|
|
684
|
+
this.element.style.textAlign = __normalize(props.horizontalAlignment);
|
|
685
|
+
}
|
|
686
|
+
appendContent(__normalize(this.scope), __normalize(this.element), __normalize(props.controls), renderer);
|
|
687
|
+
decorate(this, props);
|
|
688
|
+
bindAction(this, __normalize(this.element), __normalize(props.url));
|
|
689
|
+
} catch (error) {
|
|
690
|
+
this.dispose();
|
|
691
|
+
throw error;
|
|
207
692
|
}
|
|
208
|
-
|
|
209
|
-
|
|
693
|
+
}
|
|
694
|
+
find(name) {
|
|
695
|
+
__requireArity(arguments.length, [0], "find");
|
|
696
|
+
name = __boundary(name);
|
|
697
|
+
return __normalize(this.scope.find(name));
|
|
698
|
+
return null;
|
|
699
|
+
}
|
|
700
|
+
getValue() {
|
|
701
|
+
if (__requireBoolean(__normalize(this.scope.owned.length) === 0)) {
|
|
702
|
+
return null;
|
|
210
703
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
for (const [name, value] of __entries(__normalize(props.style))) {
|
|
214
|
-
__normalize(this.element.style.setProperty(name, value));
|
|
215
|
-
}
|
|
704
|
+
if (__requireBoolean(__normalize(this.scope.owned.length) === 1)) {
|
|
705
|
+
return __normalize(__normalize(this.scope.owned[0]).getValue());
|
|
216
706
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
707
|
+
return __normalize(this.scope.getValue());
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
setValue(value) {
|
|
711
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
712
|
+
value = __boundary(value);
|
|
713
|
+
if (__requireBoolean(__normalize(this.scope.owned.length) === 0)) {
|
|
714
|
+
let text = "";
|
|
715
|
+
if (__requireBoolean(value !== null)) {
|
|
716
|
+
if (__requireBoolean(__requireBoolean(__isObject(value)) || __requireBoolean(__isArray(value)))) {
|
|
717
|
+
text = __normalize(__hostGlobal(["JSON"]).stringify(value));
|
|
718
|
+
} else {
|
|
719
|
+
text = `${value}`;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
let handle = __normalize(this.element.querySelector(":scope > .lango-col-resize"));
|
|
723
|
+
this.element.textContent = text;
|
|
724
|
+
if (__requireBoolean(handle !== null)) {
|
|
725
|
+
__normalize(this.element.appendChild(handle));
|
|
220
726
|
}
|
|
727
|
+
} else {
|
|
728
|
+
if (__requireBoolean(value === null)) {
|
|
729
|
+
for (const control of __normalize(this.scope.owned)) {
|
|
730
|
+
clearValue(control);
|
|
731
|
+
}
|
|
732
|
+
} else {
|
|
733
|
+
if (__requireBoolean(__normalize(this.scope.owned.length) === 1)) {
|
|
734
|
+
__normalize(__normalize(this.scope.owned[0]).setValue(value));
|
|
735
|
+
} else {
|
|
736
|
+
__normalize(this.scope.setValue(value));
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return this;
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
prepareValue() {
|
|
744
|
+
return __normalize(this.scope.prepareValue());
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
clearValidation() {
|
|
748
|
+
super.clearValidation();
|
|
749
|
+
if (__requireBoolean(__normalize(this.scope) !== null)) {
|
|
750
|
+
__normalize(this.scope.clearValidation());
|
|
221
751
|
}
|
|
222
|
-
|
|
752
|
+
return null;
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
dispose() {
|
|
756
|
+
if (__requireBoolean(__normalize(this.scope) !== null)) {
|
|
757
|
+
__normalize(this.scope.dispose());
|
|
758
|
+
}
|
|
759
|
+
return super.dispose();
|
|
760
|
+
return null;
|
|
223
761
|
}
|
|
224
762
|
}
|
|
225
763
|
|
|
@@ -234,6 +772,7 @@ export class TableDivider extends Control {
|
|
|
234
772
|
}
|
|
235
773
|
|
|
236
774
|
export class TableCol extends Control {
|
|
775
|
+
name;
|
|
237
776
|
span;
|
|
238
777
|
resize;
|
|
239
778
|
#handle;
|
|
@@ -245,13 +784,10 @@ export class TableCol extends Control {
|
|
|
245
784
|
decorate(this, props);
|
|
246
785
|
this.span = spanValue(__normalize(props.colSpan));
|
|
247
786
|
this.resize = __normalize(props.resize) === true;
|
|
248
|
-
this.element
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
} else {
|
|
253
|
-
this.element.style.width = __normalize(props.width);
|
|
254
|
-
}
|
|
787
|
+
applySpan(__normalize(this.element), "span", __normalize(this.span));
|
|
788
|
+
let width = columnWidth(__normalize(props.width));
|
|
789
|
+
if (__requireBoolean(width !== null)) {
|
|
790
|
+
this.element.style.width = width;
|
|
255
791
|
}
|
|
256
792
|
}
|
|
257
793
|
size(width) {
|
|
@@ -260,7 +796,16 @@ export class TableCol extends Control {
|
|
|
260
796
|
if (__requireBoolean(width < 24)) {
|
|
261
797
|
width = 24;
|
|
262
798
|
}
|
|
263
|
-
|
|
799
|
+
let ruler = __normalize(__hostGlobal(["document"]).createElement("span"));
|
|
800
|
+
ruler.textContent = "0";
|
|
801
|
+
let font = __hostGlobalCall(["getComputedStyle"], __normalize(this.element));
|
|
802
|
+
ruler.style.font = __normalize(font.font);
|
|
803
|
+
ruler.style.position = "absolute";
|
|
804
|
+
ruler.style.visibility = "hidden";
|
|
805
|
+
__normalize(__hostGlobal(["document"]).body.appendChild(ruler));
|
|
806
|
+
let unit = __normalize(__normalize(ruler.getBoundingClientRect()).width);
|
|
807
|
+
__remove(ruler);
|
|
808
|
+
this.element.style.width = `${__finite(width / unit)}ch`;
|
|
264
809
|
__normalize(this.#handle.setAttribute("aria-valuenow", `${width}`));
|
|
265
810
|
return null;
|
|
266
811
|
return null;
|
|
@@ -281,7 +826,7 @@ export class TableCol extends Control {
|
|
|
281
826
|
__add(cell.classList, "lango-resizable-cell");
|
|
282
827
|
__normalize(cell.appendChild(handle));
|
|
283
828
|
let drag = { active: false, x: 0, width: 0 };
|
|
284
|
-
let down = __withArity((event) => {
|
|
829
|
+
let down = __withArity(__bindContexts((event) => {
|
|
285
830
|
event = __boundary(event);
|
|
286
831
|
if (__requireBoolean(__requireBoolean(__normalize(event.button) !== 0) || __requireBoolean(__normalize(drag.active)))) {
|
|
287
832
|
return null;
|
|
@@ -294,22 +839,22 @@ export class TableCol extends Control {
|
|
|
294
839
|
style.tableLayout = "fixed";
|
|
295
840
|
__normalize(handle.setPointerCapture(__normalize(event.pointerId)));
|
|
296
841
|
return null;
|
|
297
|
-
}, [0], "closure");
|
|
298
|
-
let move = __withArity((event) => {
|
|
842
|
+
}), [0], "closure");
|
|
843
|
+
let move = __withArity(__bindContexts((event) => {
|
|
299
844
|
event = __boundary(event);
|
|
300
845
|
if (__requireBoolean(__normalize(drag.active))) {
|
|
301
846
|
this.size(__numericAdd(__normalize(drag.width), __finite(__finite(__normalize(event.clientX) - __normalize(drag.x)) / __normalize(this.span))));
|
|
302
847
|
}
|
|
303
848
|
return null;
|
|
304
|
-
}, [0], "closure");
|
|
305
|
-
let up = __withArity((event) => {
|
|
849
|
+
}), [0], "closure");
|
|
850
|
+
let up = __withArity(__bindContexts((event) => {
|
|
306
851
|
event = __boundary(event);
|
|
307
852
|
if (__requireBoolean(__normalize(drag.active))) {
|
|
308
853
|
drag.active = false;
|
|
309
854
|
}
|
|
310
855
|
return null;
|
|
311
|
-
}, [0], "closure");
|
|
312
|
-
let key = __withArity((event) => {
|
|
856
|
+
}), [0], "closure");
|
|
857
|
+
let key = __withArity(__bindContexts((event) => {
|
|
313
858
|
event = __boundary(event);
|
|
314
859
|
if (__requireBoolean(__requireBoolean(__normalize(event.key) !== "ArrowLeft") && __requireBoolean(__normalize(event.key) !== "ArrowRight"))) {
|
|
315
860
|
return null;
|
|
@@ -323,14 +868,14 @@ export class TableCol extends Control {
|
|
|
323
868
|
}
|
|
324
869
|
this.size(__numericAdd(__finite(__normalize(__normalize(this.element.getBoundingClientRect()).width) / __normalize(this.span)), step));
|
|
325
870
|
return null;
|
|
326
|
-
}, [0], "closure");
|
|
871
|
+
}), [0], "closure");
|
|
327
872
|
__normalize(handle.addEventListener("pointerdown", down));
|
|
328
873
|
__normalize(handle.addEventListener("pointermove", move));
|
|
329
874
|
__normalize(handle.addEventListener("lostpointercapture", up));
|
|
330
875
|
__normalize(handle.addEventListener("pointerup", up));
|
|
331
876
|
__normalize(handle.addEventListener("pointercancel", up));
|
|
332
877
|
__normalize(handle.addEventListener("keydown", key));
|
|
333
|
-
let release = () => {
|
|
878
|
+
let release = __bindContexts(() => {
|
|
334
879
|
__normalize(handle.removeEventListener("pointerdown", down));
|
|
335
880
|
__normalize(handle.removeEventListener("pointermove", move));
|
|
336
881
|
__normalize(handle.removeEventListener("lostpointercapture", up));
|
|
@@ -339,10 +884,18 @@ export class TableCol extends Control {
|
|
|
339
884
|
__normalize(handle.removeEventListener("keydown", key));
|
|
340
885
|
__remove(handle);
|
|
341
886
|
return null;
|
|
342
|
-
};
|
|
887
|
+
});
|
|
343
888
|
__add(this.release, release);
|
|
344
889
|
return null;
|
|
345
890
|
}
|
|
891
|
+
detach() {
|
|
892
|
+
for (const release of __normalize(this.release)) {
|
|
893
|
+
__call(release, );
|
|
894
|
+
}
|
|
895
|
+
this.release = [];
|
|
896
|
+
return null;
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
346
899
|
}
|
|
347
900
|
export function spanValue(value) {
|
|
348
901
|
__requireArity(arguments.length, [0], "spanValue");
|
|
@@ -357,6 +910,42 @@ export function spanValue(value) {
|
|
|
357
910
|
return null;
|
|
358
911
|
}
|
|
359
912
|
|
|
913
|
+
function applySpan(element, name, value) {
|
|
914
|
+
__requireArity(arguments.length, [0, 1, 2], "applySpan");
|
|
915
|
+
element = __boundary(element);
|
|
916
|
+
name = __boundary(name);
|
|
917
|
+
value = __boundary(value);
|
|
918
|
+
let span = spanValue(value);
|
|
919
|
+
if (__requireBoolean(span === 1)) {
|
|
920
|
+
__normalize(element.removeAttribute(name));
|
|
921
|
+
} else {
|
|
922
|
+
__normalize(element.setAttribute(name, `${span}`));
|
|
923
|
+
}
|
|
924
|
+
return null;
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export function columnWidth(value) {
|
|
929
|
+
__requireArity(arguments.length, [0], "columnWidth");
|
|
930
|
+
value = __boundary(value);
|
|
931
|
+
return measure(value, "ch");
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
function clearValue(control) {
|
|
936
|
+
__requireArity(arguments.length, [0], "clearValue");
|
|
937
|
+
control = __boundary(control);
|
|
938
|
+
if (__requireBoolean(__isKindof(control, Form))) {
|
|
939
|
+
for (const child of __normalize(control.owned)) {
|
|
940
|
+
clearValue(child);
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
__normalize(control.setValue(null));
|
|
944
|
+
}
|
|
945
|
+
return null;
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
|
|
360
949
|
function cellElement(heading) {
|
|
361
950
|
__requireArity(arguments.length, [0], "cellElement");
|
|
362
951
|
heading = __boundary(heading);
|
|
@@ -366,4 +955,99 @@ function cellElement(heading) {
|
|
|
366
955
|
return cloneMarkup("table-cell", ["<td></td>"].join(""));
|
|
367
956
|
return null;
|
|
368
957
|
}
|
|
958
|
+
|
|
959
|
+
function addName(names, name, control) {
|
|
960
|
+
__requireArity(arguments.length, [0, 1, 2], "addName");
|
|
961
|
+
names = __boundary(names);
|
|
962
|
+
name = __boundary(name);
|
|
963
|
+
control = __boundary(control);
|
|
964
|
+
if (__requireBoolean(name === null)) {
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(name))) || __requireBoolean(name === "")) || __requireBoolean(__normalize(name.includes("/")))) || __requireBoolean(__includes(name, names)))) {
|
|
968
|
+
throw `Invalid or duplicate control name: ${name}`;
|
|
969
|
+
}
|
|
970
|
+
names[name] = control;
|
|
971
|
+
return null;
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function rowValue(value) {
|
|
976
|
+
__requireArity(arguments.length, [0], "rowValue");
|
|
977
|
+
value = __boundary(value);
|
|
978
|
+
if (__requireBoolean(__requireBoolean(value !== null) && __requireBoolean(__requireBoolean(!__requireBoolean(__isObject(value))) || __requireBoolean(__isArray(value))))) {
|
|
979
|
+
throw "Table row value must be a map or null";
|
|
980
|
+
}
|
|
981
|
+
return value;
|
|
982
|
+
return null;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function tableIndex(index, length, insertion = false) {
|
|
986
|
+
__requireArity(arguments.length, [0, 1], "tableIndex");
|
|
987
|
+
index = __boundary(index);
|
|
988
|
+
length = __boundary(length);
|
|
989
|
+
insertion = __boundary(insertion);
|
|
990
|
+
let limit = __finite(length - 1);
|
|
991
|
+
if (__requireBoolean(insertion)) {
|
|
992
|
+
limit = length;
|
|
993
|
+
}
|
|
994
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(index))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(index))))) || __requireBoolean(index < 0)) || __requireBoolean(index > limit))) {
|
|
995
|
+
throw `Table index out of range: ${index}`;
|
|
996
|
+
}
|
|
997
|
+
return index;
|
|
998
|
+
return null;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function columnIndex(column, columns) {
|
|
1002
|
+
__requireArity(arguments.length, [0, 1], "columnIndex");
|
|
1003
|
+
column = __boundary(column);
|
|
1004
|
+
columns = __boundary(columns);
|
|
1005
|
+
if (__requireBoolean(__isString(column))) {
|
|
1006
|
+
for (const [index, col] of __entries(columns)) {
|
|
1007
|
+
if (__requireBoolean(__normalize(col.name) === column)) {
|
|
1008
|
+
return index;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
throw `Unknown table column: ${column}`;
|
|
1012
|
+
}
|
|
1013
|
+
return tableIndex(column, __normalize(columns.length));
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function validateBoundaries(header, rows, columns) {
|
|
1018
|
+
__requireArity(arguments.length, [0, 1, 2], "validateBoundaries");
|
|
1019
|
+
header = __boundary(header);
|
|
1020
|
+
rows = __boundary(rows);
|
|
1021
|
+
columns = __boundary(columns);
|
|
1022
|
+
let offset;
|
|
1023
|
+
let first = null;
|
|
1024
|
+
if (__requireBoolean(__requireBoolean(header !== null) && __requireBoolean(header.rows.length > 0))) {
|
|
1025
|
+
first = header.rows[0];
|
|
1026
|
+
} else {
|
|
1027
|
+
if (__requireBoolean(__normalize(rows.length) > 0)) {
|
|
1028
|
+
first = __normalize(rows[0]);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
if (__requireBoolean(first !== null)) {
|
|
1032
|
+
offset = 0;
|
|
1033
|
+
for (const col of columns) {
|
|
1034
|
+
offset = __numericAdd(offset, __normalize(col.span));
|
|
1035
|
+
if (__requireBoolean(__requireBoolean(__normalize(col.resize)) && __requireBoolean(__normalize(first.boundary(offset)) === null))) {
|
|
1036
|
+
throw "Resizable column must end at a first-row cell boundary";
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
return first;
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function allReady(pending) {
|
|
1045
|
+
__requireArity(arguments.length, [0], "allReady");
|
|
1046
|
+
pending = __boundary(pending);
|
|
1047
|
+
if (__requireBoolean(__normalize(pending.length) === 0)) {
|
|
1048
|
+
return null;
|
|
1049
|
+
}
|
|
1050
|
+
return __normalize(__hostGlobal(["Promise"]).all(pending));
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
369
1053
|
//# sourceMappingURL=tables.mjs.map
|