@lango-project/lango-client 0.0.0-stage → 0.2.0
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/LICENSE +200 -0
- package/NOTICE +2 -0
- package/README.md +877 -2
- package/dist/.lango/bignumber.mjs +3119 -0
- package/dist/.lango/runtime.mjs +607 -0
- package/dist/.lango/xmldom/conventions.js +429 -0
- package/dist/.lango/xmldom/dom-parser.js +591 -0
- package/dist/.lango/xmldom/dom.js +3759 -0
- package/dist/.lango/xmldom/entities.js +2171 -0
- package/dist/.lango/xmldom/errors.js +205 -0
- package/dist/.lango/xmldom/grammar.js +559 -0
- package/dist/.lango/xmldom/index.js +41 -0
- package/dist/.lango/xmldom/package.json +1 -0
- package/dist/.lango/xmldom/sax.js +983 -0
- package/dist/.lango/xmldom.LICENSE.md +8 -0
- package/dist/application.mjs +429 -0
- package/dist/application.mjs.map +1 -0
- package/dist/coordinator.mjs +91 -0
- package/dist/coordinator.mjs.map +1 -0
- package/dist/demo.mjs +110 -0
- package/dist/demo.mjs.map +1 -0
- package/dist/demo_controls.mjs +59 -0
- package/dist/demo_controls.mjs.map +1 -0
- package/dist/errors.mjs +201 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/form_state.mjs +266 -0
- package/dist/form_state.mjs.map +1 -0
- package/dist/heartbeat.mjs +330 -0
- package/dist/heartbeat.mjs.map +1 -0
- package/dist/inheritance.mjs +240 -0
- package/dist/inheritance.mjs.map +1 -0
- package/dist/input_values.mjs +65 -0
- package/dist/input_values.mjs.map +1 -0
- package/dist/library.mjs +792 -0
- package/dist/library.mjs.map +1 -0
- package/dist/navigation.mjs +466 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/node/.lango/bignumber.mjs +3119 -0
- package/dist/node/.lango/runtime.mjs +609 -0
- package/dist/node/.lango/xmldom/conventions.js +429 -0
- package/dist/node/.lango/xmldom/dom-parser.js +591 -0
- package/dist/node/.lango/xmldom/dom.js +3759 -0
- package/dist/node/.lango/xmldom/entities.js +2171 -0
- package/dist/node/.lango/xmldom/errors.js +205 -0
- package/dist/node/.lango/xmldom/grammar.js +559 -0
- package/dist/node/.lango/xmldom/index.js +41 -0
- package/dist/node/.lango/xmldom/package.json +1 -0
- package/dist/node/.lango/xmldom/sax.js +983 -0
- package/dist/node/.lango/xmldom.LICENSE.md +8 -0
- package/dist/node/browser_host.mjs +351 -0
- package/dist/node/browser_host.mjs.map +1 -0
- package/dist/node/create_app.mjs +118 -0
- package/dist/node/create_app.mjs.map +1 -0
- package/dist/presentation.mjs +89 -0
- package/dist/presentation.mjs.map +1 -0
- package/dist/protocol.mjs +706 -0
- package/dist/protocol.mjs.map +1 -0
- package/dist/session.mjs +431 -0
- package/dist/session.mjs.map +1 -0
- package/dist/tokens.mjs +298 -0
- package/dist/tokens.mjs.map +1 -0
- package/examples/contacts.lango +302 -0
- package/examples/contacts_flow.lango +174 -0
- package/examples/contacts_store.lango +109 -0
- package/examples/contacts_store_test.lango +65 -0
- package/examples/demo.css +72 -0
- package/examples/demo_test.lango +356 -0
- package/examples/index.html +28 -0
- package/examples/pages.lango +180 -0
- package/examples/server.lango +189 -0
- package/examples/worker.lango +142 -0
- package/package.json +64 -4
- package/src/application.lango +327 -0
- package/src/browser_host.lango +276 -0
- package/src/coordinator.lango +57 -0
- package/src/demo.lango +110 -0
- package/src/demo_controls.lango +53 -0
- package/src/errors.lango +149 -0
- package/src/errors_test.lango +157 -0
- package/src/form_state.lango +168 -0
- package/src/heartbeat.lango +230 -0
- package/src/heartbeat_test.lango +479 -0
- package/src/inheritance.lango +167 -0
- package/src/input_values.lango +37 -0
- package/src/library.lango +571 -0
- package/src/logout_test.lango +564 -0
- package/src/navigation.lango +309 -0
- package/src/navigation_test.lango +556 -0
- package/src/presentation.lango +55 -0
- package/src/protocol.lango +787 -0
- package/src/renderer_test.lango +1986 -0
- package/src/session.lango +313 -0
- package/src/session_test.lango +455 -0
- package/src/tabs_test.lango +216 -0
- package/src/tokens.lango +215 -0
- package/template/.vscode/extensions.json +3 -0
- package/template/.vscode/settings.json +9 -0
- package/template/README.md +40 -0
- package/template/gitignore +4 -0
- package/template/package.json +22 -0
- package/template/public/app.css +4 -0
- package/template/public/index.html +24 -0
- package/template/src/client.lango +78 -0
- package/template/src/pages.lango +55 -0
- package/template/src/server.lango +24 -0
- package/template/src/worker.lango +77 -0
- package/template/test/app.lango +9 -0
- package/tools/create_app.lango +88 -0
- package/tools/create_app_test.lango +43 -0
- package/tools/starter_test.lango +227 -0
package/dist/library.mjs
ADDED
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
import { collectValues, applyResponse } from "./protocol.mjs";
|
|
2
|
+
import { normalizeInheritance } from "./inheritance.mjs";
|
|
3
|
+
import { classNames, styleMap, validateProperty } from "./presentation.mjs";
|
|
4
|
+
import { selectItems, selectIndex } from "./input_values.mjs";
|
|
5
|
+
import { rulesFor, validationMessage, sameValue } from "./form_state.mjs";
|
|
6
|
+
import {
|
|
7
|
+
contextGet as __contextGet,
|
|
8
|
+
contextSet as __contextSet,
|
|
9
|
+
contextRestore as __contextRestore,
|
|
10
|
+
fromJson as __fromJson,
|
|
11
|
+
toJson as __toJson,
|
|
12
|
+
getClass as __getClass,
|
|
13
|
+
isKindof as __isKindof,
|
|
14
|
+
isNumber as __isNumber,
|
|
15
|
+
isString as __isString,
|
|
16
|
+
isBool as __isBool,
|
|
17
|
+
isObject as __isObject,
|
|
18
|
+
isArray as __isArray,
|
|
19
|
+
includes as __includes,
|
|
20
|
+
entries as __entries,
|
|
21
|
+
remove as __remove,
|
|
22
|
+
clear as __clear,
|
|
23
|
+
requireBoolean as __requireBoolean,
|
|
24
|
+
normalize as __normalize,
|
|
25
|
+
boundary as __boundary,
|
|
26
|
+
requireArity as __requireArity,
|
|
27
|
+
withArity as __withArity,
|
|
28
|
+
} from "./.lango/runtime.mjs";
|
|
29
|
+
|
|
30
|
+
export class Types {
|
|
31
|
+
#types;
|
|
32
|
+
#classes;
|
|
33
|
+
#sealed;
|
|
34
|
+
constructor(options = null) {
|
|
35
|
+
options = __boundary(options);
|
|
36
|
+
if (__requireBoolean(__requireBoolean(options !== null) && __requireBoolean(__requireBoolean(!__requireBoolean(__isObject(options))) || __requireBoolean(__isArray(options))))) {
|
|
37
|
+
throw "UiControlRegistryOptionsMustBeMap";
|
|
38
|
+
}
|
|
39
|
+
this.#types = { };
|
|
40
|
+
this.#classes = { };
|
|
41
|
+
this.#sealed = false;
|
|
42
|
+
if (__requireBoolean(__requireBoolean(options !== null) && __requireBoolean(__normalize(options.classes) !== null))) {
|
|
43
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(__normalize(options.classes)))) || __requireBoolean(__isArray(__normalize(options.classes))))) {
|
|
44
|
+
throw "UiThemeClassesMustBeMap";
|
|
45
|
+
}
|
|
46
|
+
for (const [name, classes] of __entries(__normalize(options.classes))) {
|
|
47
|
+
this.#classes[name] = classNames(classes);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
registerType(name, type) {
|
|
52
|
+
__requireArity(arguments.length, [0, 1], "registerType");
|
|
53
|
+
name = __boundary(name);
|
|
54
|
+
type = __boundary(type);
|
|
55
|
+
if (__requireBoolean(__normalize(this.#sealed))) {
|
|
56
|
+
throw "UiControlRegistrySealed";
|
|
57
|
+
}
|
|
58
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(name))) || __requireBoolean(name === "")) || __requireBoolean(name === "__proto__")) || __requireBoolean(name === "prototype")) || __requireBoolean(name === "constructor")) || __requireBoolean(!__requireBoolean(__isKindof(type, Function))))) {
|
|
59
|
+
throw "UiControlTypeRequiresNameAndConstructor";
|
|
60
|
+
}
|
|
61
|
+
if (__requireBoolean(__includes(name, __normalize(this.#types)))) {
|
|
62
|
+
throw `UiDuplicateControlType: ${name}`;
|
|
63
|
+
}
|
|
64
|
+
this.#types[name] = type;
|
|
65
|
+
return this;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
create(document, definition) {
|
|
69
|
+
__requireArity(arguments.length, [0, 1], "create");
|
|
70
|
+
document = __boundary(document);
|
|
71
|
+
definition = __boundary(definition);
|
|
72
|
+
this.#sealed = true;
|
|
73
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(definition))) || __requireBoolean(!__requireBoolean(__isString(__normalize(definition.type)))))) {
|
|
74
|
+
throw "UiControlRequiresDefinition";
|
|
75
|
+
}
|
|
76
|
+
let prepared = { };
|
|
77
|
+
for (const [name, value] of __entries(definition)) {
|
|
78
|
+
prepared[name] = value;
|
|
79
|
+
}
|
|
80
|
+
let defaults = __normalize(this.#classes[__normalize(definition.type)]);
|
|
81
|
+
if (__requireBoolean(defaults !== null)) {
|
|
82
|
+
prepared.classes = classNames(__normalize(defaults.concat(classNames(__normalize(definition.classes)))));
|
|
83
|
+
}
|
|
84
|
+
let type = Control;
|
|
85
|
+
if (__requireBoolean(__includes(__normalize(definition.type), __normalize(this.#types)))) {
|
|
86
|
+
type = __normalize(this.#types[__normalize(definition.type)]);
|
|
87
|
+
}
|
|
88
|
+
let control = new type(document, prepared, this);
|
|
89
|
+
if (__requireBoolean(!__requireBoolean(__isKindof(control, Control)))) {
|
|
90
|
+
throw "UiCustomControlMustExtendControl";
|
|
91
|
+
}
|
|
92
|
+
return control;
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export class Binding {
|
|
98
|
+
#form;
|
|
99
|
+
#session;
|
|
100
|
+
#errors;
|
|
101
|
+
#disposed;
|
|
102
|
+
#listener;
|
|
103
|
+
constructor(form, session, errors = null) {
|
|
104
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
105
|
+
form = __boundary(form);
|
|
106
|
+
session = __boundary(session);
|
|
107
|
+
errors = __boundary(errors);
|
|
108
|
+
this.#form = form;
|
|
109
|
+
this.#session = session;
|
|
110
|
+
this.#errors = errors;
|
|
111
|
+
this.#disposed = false;
|
|
112
|
+
let root = __normalize(form.element);
|
|
113
|
+
if (__requireBoolean(__normalize(root.langoBinding) !== null)) {
|
|
114
|
+
throw "UiFormAlreadyBound";
|
|
115
|
+
}
|
|
116
|
+
let listener = __withArity((event) => {
|
|
117
|
+
event = __boundary(event);
|
|
118
|
+
this.handle(event);
|
|
119
|
+
return null;
|
|
120
|
+
}, [0], "closure");
|
|
121
|
+
this.#listener = listener;
|
|
122
|
+
for (const type of ["click", "change", "input"]) {
|
|
123
|
+
__normalize(root.addEventListener(type, listener));
|
|
124
|
+
}
|
|
125
|
+
root.langoBinding = this;
|
|
126
|
+
}
|
|
127
|
+
handle(event) {
|
|
128
|
+
__requireArity(arguments.length, [0], "handle");
|
|
129
|
+
event = __boundary(event);
|
|
130
|
+
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
let root = __normalize(this.#form.element);
|
|
134
|
+
let element = __normalize(event.target);
|
|
135
|
+
let target = null;
|
|
136
|
+
let current = element;
|
|
137
|
+
__loop1: while (__requireBoolean(current !== null)) {
|
|
138
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(current.inert) === true) || __requireBoolean(__normalize(current.disabled) === true)) || __requireBoolean(__normalize(current.hidden) === true))) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
if (__requireBoolean(current === root)) {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
if (__requireBoolean(__normalize(current.langoFormRoot) === true)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (__requireBoolean(target === null)) {
|
|
148
|
+
target = eventTarget(__normalize(this.#form.controls), current, [], __normalize(event.type));
|
|
149
|
+
}
|
|
150
|
+
current = __normalize(current.parentNode);
|
|
151
|
+
}
|
|
152
|
+
if (__requireBoolean(current !== root)) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
if (__requireBoolean(__requireBoolean(__normalize(event.type) === "input") || __requireBoolean(__normalize(event.type) === "change"))) {
|
|
156
|
+
validateEvent(__normalize(this.#form.controls), __normalize(event.target), root);
|
|
157
|
+
}
|
|
158
|
+
if (__requireBoolean(target === null)) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
__normalize(event.preventDefault());
|
|
163
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#errors) !== null) && __requireBoolean(__normalize(this.#errors.clear) !== null))) {
|
|
164
|
+
__clear(this.#errors);
|
|
165
|
+
}
|
|
166
|
+
let session = __normalize(this.#session);
|
|
167
|
+
return __normalize(session.send(__normalize(target.url), __normalize(event.type), __normalize(target.name))).catch(__withArity((error) => {
|
|
168
|
+
error = __boundary(error);
|
|
169
|
+
this.report(error);
|
|
170
|
+
return null;
|
|
171
|
+
}, [0], "closure"));
|
|
172
|
+
} catch (error) {
|
|
173
|
+
this.report(error);
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
report(error) {
|
|
179
|
+
const __contextScope = [];
|
|
180
|
+
try {
|
|
181
|
+
__requireArity(arguments.length, [0], "report");
|
|
182
|
+
error = __boundary(error);
|
|
183
|
+
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
if (__requireBoolean(__normalize(this.#errors) !== null)) {
|
|
187
|
+
__normalize(this.#errors.error(error));
|
|
188
|
+
} else {
|
|
189
|
+
__normalize(__contextGet("log").err(error));
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
return null;
|
|
193
|
+
} finally {
|
|
194
|
+
__contextRestore(__contextScope);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
dispose() {
|
|
198
|
+
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
this.#disposed = true;
|
|
202
|
+
let root = __normalize(this.#form.element);
|
|
203
|
+
for (const type of ["click", "change", "input"]) {
|
|
204
|
+
__normalize(root.removeEventListener(type, __normalize(this.#listener)));
|
|
205
|
+
}
|
|
206
|
+
root.langoBinding = null;
|
|
207
|
+
return null;
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export class Renderer {
|
|
213
|
+
#document;
|
|
214
|
+
#types;
|
|
215
|
+
constructor(document, types = null) {
|
|
216
|
+
__requireArity(arguments.length, [0], "constructor");
|
|
217
|
+
document = __boundary(document);
|
|
218
|
+
types = __boundary(types);
|
|
219
|
+
this.#document = document;
|
|
220
|
+
this.#types = types;
|
|
221
|
+
if (__requireBoolean(__normalize(this.#types) === null)) {
|
|
222
|
+
this.#types = new Types();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
create(definition) {
|
|
226
|
+
__requireArity(arguments.length, [0], "create");
|
|
227
|
+
definition = __boundary(definition);
|
|
228
|
+
return __normalize(this.#types.create(__normalize(this.#document), definition));
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
release(control) {
|
|
232
|
+
__requireArity(arguments.length, [0], "release");
|
|
233
|
+
control = __boundary(control);
|
|
234
|
+
releaseControl(control);
|
|
235
|
+
return null;
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
replace(old, replacement) {
|
|
239
|
+
__requireArity(arguments.length, [0, 1], "replace");
|
|
240
|
+
old = __boundary(old);
|
|
241
|
+
replacement = __boundary(replacement);
|
|
242
|
+
let element = __normalize(old.element);
|
|
243
|
+
__normalize(element.parentNode.replaceChild(__normalize(replacement.element), element));
|
|
244
|
+
return null;
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
remove(control) {
|
|
248
|
+
__requireArity(arguments.length, [0], "remove");
|
|
249
|
+
control = __boundary(control);
|
|
250
|
+
__remove(control.element);
|
|
251
|
+
return null;
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
capture(control) {
|
|
255
|
+
__requireArity(arguments.length, [0], "capture");
|
|
256
|
+
control = __boundary(control);
|
|
257
|
+
let element = __normalize(control.element);
|
|
258
|
+
return { element: element, parent: __normalize(element.parentNode), next: __normalize(element.nextSibling) };
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
restore(snapshot, operation) {
|
|
262
|
+
__requireArity(arguments.length, [0, 1], "restore");
|
|
263
|
+
snapshot = __boundary(snapshot);
|
|
264
|
+
operation = __boundary(operation);
|
|
265
|
+
if (__requireBoolean(__normalize(operation.type) === "replace")) {
|
|
266
|
+
let replacement = __normalize(operation.new);
|
|
267
|
+
__remove(replacement.element);
|
|
268
|
+
}
|
|
269
|
+
if (__requireBoolean(__normalize(snapshot.parent) !== null)) {
|
|
270
|
+
__normalize(snapshot.parent.insertBefore(__normalize(snapshot.element), __normalize(snapshot.next)));
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
focus(control) {
|
|
276
|
+
__requireArity(arguments.length, [0], "focus");
|
|
277
|
+
control = __boundary(control);
|
|
278
|
+
__normalize(control.element.focus());
|
|
279
|
+
return null;
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
toast(level, text) {
|
|
283
|
+
__requireArity(arguments.length, [0, 1], "toast");
|
|
284
|
+
level = __boundary(level);
|
|
285
|
+
text = __boundary(text);
|
|
286
|
+
let element = __normalize(this.#document.createElement("div"));
|
|
287
|
+
__normalize(element.setAttribute("role", "status"));
|
|
288
|
+
element.textContent = text;
|
|
289
|
+
__normalize(this.#document.body.appendChild(element));
|
|
290
|
+
return null;
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export class Control {
|
|
296
|
+
name;
|
|
297
|
+
element;
|
|
298
|
+
controls;
|
|
299
|
+
events;
|
|
300
|
+
inherit;
|
|
301
|
+
validates;
|
|
302
|
+
confirms;
|
|
303
|
+
#type;
|
|
304
|
+
#value;
|
|
305
|
+
#clean;
|
|
306
|
+
#error;
|
|
307
|
+
#pendingError;
|
|
308
|
+
#rules;
|
|
309
|
+
#tracked;
|
|
310
|
+
#items;
|
|
311
|
+
#classes;
|
|
312
|
+
#style;
|
|
313
|
+
constructor(document, definition, types = null, options = null) {
|
|
314
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
315
|
+
document = __boundary(document);
|
|
316
|
+
definition = __boundary(definition);
|
|
317
|
+
types = __boundary(types);
|
|
318
|
+
options = __boundary(options);
|
|
319
|
+
this.name = __normalize(definition.name);
|
|
320
|
+
this.#type = __normalize(definition.type);
|
|
321
|
+
this.controls = null;
|
|
322
|
+
this.#value = __normalize(definition.value);
|
|
323
|
+
this.#clean = null;
|
|
324
|
+
this.#error = null;
|
|
325
|
+
this.#pendingError = false;
|
|
326
|
+
this.#rules = rulesFor(__normalize(definition.validation));
|
|
327
|
+
this.#tracked = __normalize(definition.trackChanges);
|
|
328
|
+
if (__requireBoolean(__normalize(this.#tracked) === null)) {
|
|
329
|
+
this.#tracked = __requireBoolean(__requireBoolean(__normalize(this.#type) === "Text") || __requireBoolean(__normalize(this.#type) === "Select")) || __requireBoolean(__normalize(this.#type) === "Checkbox");
|
|
330
|
+
}
|
|
331
|
+
if (__requireBoolean(!__requireBoolean(__isBool(__normalize(this.#tracked))))) {
|
|
332
|
+
throw "UiTrackChangesMustBeBoolean";
|
|
333
|
+
}
|
|
334
|
+
this.validates = __normalize(definition.validate);
|
|
335
|
+
if (__requireBoolean(__normalize(this.validates) === null)) {
|
|
336
|
+
this.validates = false;
|
|
337
|
+
}
|
|
338
|
+
if (__requireBoolean(!__requireBoolean(__isBool(__normalize(this.validates))))) {
|
|
339
|
+
throw "UiValidateEventMustBeBoolean";
|
|
340
|
+
}
|
|
341
|
+
this.confirms = __normalize(definition.confirmDirty);
|
|
342
|
+
if (__requireBoolean(__normalize(this.confirms) === null)) {
|
|
343
|
+
this.confirms = false;
|
|
344
|
+
}
|
|
345
|
+
if (__requireBoolean(!__requireBoolean(__isBool(__normalize(this.confirms))))) {
|
|
346
|
+
throw "UiConfirmDirtyMustBeBoolean";
|
|
347
|
+
}
|
|
348
|
+
this.#items = [];
|
|
349
|
+
if (__requireBoolean(__normalize(this.#type) === "Select")) {
|
|
350
|
+
this.#items = selectItems(__normalize(definition.options));
|
|
351
|
+
}
|
|
352
|
+
this.events = controlEvents(definition);
|
|
353
|
+
this.inherit = normalizeInheritance(__normalize(definition.inherit));
|
|
354
|
+
this.#classes = classNames(__normalize(definition.classes));
|
|
355
|
+
this.#style = styleMap(__normalize(definition.style));
|
|
356
|
+
let registry = types;
|
|
357
|
+
if (__requireBoolean(registry === null)) {
|
|
358
|
+
registry = new Types();
|
|
359
|
+
}
|
|
360
|
+
if (__requireBoolean(__requireBoolean(__normalize(definition.inherit) !== null) && __requireBoolean(__normalize(this.#type) !== "Form"))) {
|
|
361
|
+
throw "UiInheritanceRequiresForm";
|
|
362
|
+
}
|
|
363
|
+
let tag = "div";
|
|
364
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#type) === "Text") || __requireBoolean(__normalize(this.#type) === "Checkbox"))) {
|
|
365
|
+
tag = "input";
|
|
366
|
+
}
|
|
367
|
+
if (__requireBoolean(__normalize(this.#type) === "Select")) {
|
|
368
|
+
tag = "select";
|
|
369
|
+
}
|
|
370
|
+
if (__requireBoolean(__normalize(this.#type) === "Button")) {
|
|
371
|
+
tag = "button";
|
|
372
|
+
}
|
|
373
|
+
if (__requireBoolean(options !== null)) {
|
|
374
|
+
tag = __normalize(options.tag);
|
|
375
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(tag))) || __requireBoolean(tag === ""))) {
|
|
376
|
+
throw "UiCustomControlRequiresTag";
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(options === null) && __requireBoolean(__normalize(this.#type) !== "Text")) && __requireBoolean(__normalize(this.#type) !== "Button")) && __requireBoolean(__normalize(this.#type) !== "Value")) && __requireBoolean(__normalize(this.#type) !== "Panel")) && __requireBoolean(__normalize(this.#type) !== "Container")) && __requireBoolean(__normalize(this.#type) !== "Form")) && __requireBoolean(__normalize(this.#type) !== "Select")) && __requireBoolean(__normalize(this.#type) !== "Checkbox"))) {
|
|
380
|
+
throw "UiClientUnknownControlType";
|
|
381
|
+
}
|
|
382
|
+
this.element = __normalize(document.createElement(tag));
|
|
383
|
+
let element = __normalize(this.element);
|
|
384
|
+
if (__requireBoolean(__normalize(this.#type) === "Form")) {
|
|
385
|
+
element.langoFormRoot = true;
|
|
386
|
+
}
|
|
387
|
+
if (__requireBoolean(__normalize(this.#type) === "Button")) {
|
|
388
|
+
element.type = "button";
|
|
389
|
+
element.textContent = __normalize(definition.text);
|
|
390
|
+
}
|
|
391
|
+
if (__requireBoolean(__normalize(this.#type) === "Value")) {
|
|
392
|
+
element.hidden = true;
|
|
393
|
+
}
|
|
394
|
+
if (__requireBoolean(__normalize(this.#type) === "Checkbox")) {
|
|
395
|
+
element.type = "checkbox";
|
|
396
|
+
}
|
|
397
|
+
if (__requireBoolean(__normalize(definition.label) !== null)) {
|
|
398
|
+
if (__requireBoolean(!__requireBoolean(__isString(__normalize(definition.label))))) {
|
|
399
|
+
throw "UiControlLabelMustBeString";
|
|
400
|
+
}
|
|
401
|
+
__normalize(element.setAttribute("aria-label", __normalize(definition.label)));
|
|
402
|
+
}
|
|
403
|
+
let container = __requireBoolean(__requireBoolean(__normalize(this.#type) === "Panel") || __requireBoolean(__normalize(this.#type) === "Container")) || __requireBoolean(__normalize(this.#type) === "Form");
|
|
404
|
+
if (__requireBoolean(__requireBoolean(options !== null) && __requireBoolean(__normalize(options.container) === true))) {
|
|
405
|
+
container = true;
|
|
406
|
+
}
|
|
407
|
+
if (__requireBoolean(container)) {
|
|
408
|
+
this.controls = [];
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
if (__requireBoolean(__normalize(this.#type) === "Select")) {
|
|
412
|
+
for (const item of __normalize(this.#items)) {
|
|
413
|
+
let option = __normalize(document.createElement("option"));
|
|
414
|
+
option.value = __normalize(item.value);
|
|
415
|
+
option.textContent = __normalize(item.text);
|
|
416
|
+
option.disabled = __normalize(item.disabled);
|
|
417
|
+
__normalize(element.appendChild(option));
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (__requireBoolean(__requireBoolean(container) && __requireBoolean(__isArray(__normalize(definition.controls))))) {
|
|
421
|
+
for (const childDefinition of __normalize(definition.controls)) {
|
|
422
|
+
let child = __normalize(registry.create(document, childDefinition));
|
|
423
|
+
this.controls.push(child);
|
|
424
|
+
__normalize(element.appendChild(__normalize(child.element)));
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (__requireBoolean(__normalize(definition.classes) !== null)) {
|
|
428
|
+
this.applyProperty("classes", __normalize(definition.classes));
|
|
429
|
+
}
|
|
430
|
+
if (__requireBoolean(__normalize(definition.style) !== null)) {
|
|
431
|
+
this.applyProperty("style", __normalize(definition.style));
|
|
432
|
+
}
|
|
433
|
+
if (__requireBoolean(__normalize(definition.enabled) !== null)) {
|
|
434
|
+
this.applyProperty("enabled", __normalize(definition.enabled));
|
|
435
|
+
}
|
|
436
|
+
if (__requireBoolean(__normalize(definition.visible) !== null)) {
|
|
437
|
+
this.applyProperty("visible", __normalize(definition.visible));
|
|
438
|
+
}
|
|
439
|
+
let initial = __normalize(definition.value);
|
|
440
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#type) === "Checkbox") && __requireBoolean(initial === null))) {
|
|
441
|
+
initial = false;
|
|
442
|
+
}
|
|
443
|
+
this.setValue(initial);
|
|
444
|
+
this.markClean();
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (__requireBoolean(__isArray(__normalize(this.controls)))) {
|
|
447
|
+
for (const child of __normalize(this.controls)) {
|
|
448
|
+
releaseControl(child);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
getValue() {
|
|
455
|
+
if (__requireBoolean(__isArray(__normalize(this.controls)))) {
|
|
456
|
+
return collectValues(__normalize(this.controls));
|
|
457
|
+
}
|
|
458
|
+
if (__normalize(this.#type) === "Text") {
|
|
459
|
+
return __normalize(this.element.value);
|
|
460
|
+
} else if (__normalize(this.#type) === "Checkbox") {
|
|
461
|
+
return __normalize(this.element.checked);
|
|
462
|
+
} else if (__normalize(this.#type) === "Select") {
|
|
463
|
+
let index = __normalize(this.element.selectedIndex);
|
|
464
|
+
if (__requireBoolean(__requireBoolean(index < 0) || __requireBoolean(index >= __normalize(this.#items.length)))) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
return __normalize(__normalize(this.#items[index]).value);
|
|
468
|
+
} else {
|
|
469
|
+
return __normalize(this.#value);
|
|
470
|
+
}
|
|
471
|
+
return null;
|
|
472
|
+
}
|
|
473
|
+
setValue(value) {
|
|
474
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
475
|
+
value = __boundary(value);
|
|
476
|
+
if (__normalize(this.#type) === "Text") {
|
|
477
|
+
let text = value;
|
|
478
|
+
if (__requireBoolean(value === null)) {
|
|
479
|
+
text = "";
|
|
480
|
+
}
|
|
481
|
+
this.element.value = text;
|
|
482
|
+
} else if (__normalize(this.#type) === "Checkbox") {
|
|
483
|
+
if (__requireBoolean(!__requireBoolean(__isBool(value)))) {
|
|
484
|
+
throw "UiCheckboxValueMustBeBoolean";
|
|
485
|
+
}
|
|
486
|
+
this.element.checked = value;
|
|
487
|
+
} else if (__normalize(this.#type) === "Select") {
|
|
488
|
+
this.element.selectedIndex = selectIndex(__normalize(this.#items), value);
|
|
489
|
+
}
|
|
490
|
+
this.#value = value;
|
|
491
|
+
if (__requireBoolean(__normalize(this.#error) !== null)) {
|
|
492
|
+
this.validate();
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
isDirty() {
|
|
498
|
+
if (__requireBoolean(__isArray(__normalize(this.controls)))) {
|
|
499
|
+
for (const child of __normalize(this.controls)) {
|
|
500
|
+
if (__requireBoolean(__normalize(child.isDirty) !== null)) {
|
|
501
|
+
if (__requireBoolean(__normalize(child.isDirty()))) {
|
|
502
|
+
return true;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
if (__requireBoolean(!__requireBoolean(__normalize(this.#tracked)))) {
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
let current = __fromJson(__toJson(this.getValue()));
|
|
512
|
+
return !__requireBoolean(sameValue(current, __normalize(this.#clean)));
|
|
513
|
+
return null;
|
|
514
|
+
}
|
|
515
|
+
markClean() {
|
|
516
|
+
if (__requireBoolean(__isArray(__normalize(this.controls)))) {
|
|
517
|
+
for (const child of __normalize(this.controls)) {
|
|
518
|
+
if (__requireBoolean(__normalize(child.markClean) !== null)) {
|
|
519
|
+
__normalize(child.markClean());
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
this.acceptSaved(this.getValue());
|
|
524
|
+
}
|
|
525
|
+
return null;
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
acceptSaved(value) {
|
|
529
|
+
__requireArity(arguments.length, [0], "acceptSaved");
|
|
530
|
+
value = __boundary(value);
|
|
531
|
+
this.#clean = __fromJson(__toJson(value));
|
|
532
|
+
return null;
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
validate() {
|
|
536
|
+
this.#pendingError = false;
|
|
537
|
+
this.#error = validationMessage(__normalize(this.#rules), this.getValue());
|
|
538
|
+
this.#renderError();
|
|
539
|
+
return __normalize(this.#error);
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
#renderError() {
|
|
543
|
+
let text = __normalize(this.#error);
|
|
544
|
+
if (__requireBoolean(text === null)) {
|
|
545
|
+
text = "";
|
|
546
|
+
}
|
|
547
|
+
__normalize(this.element.setAttribute("aria-invalid", `${__normalize(this.#error) !== null}`));
|
|
548
|
+
__normalize(this.element.setAttribute("data-lango-error", text));
|
|
549
|
+
if (__requireBoolean(__normalize(this.element.setCustomValidity) !== null)) {
|
|
550
|
+
__normalize(this.element.setCustomValidity(text));
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
reportValidity() {
|
|
556
|
+
if (__requireBoolean(__normalize(this.element.reportValidity) !== null)) {
|
|
557
|
+
return __normalize(this.element.reportValidity());
|
|
558
|
+
}
|
|
559
|
+
return __normalize(this.#error) === null;
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
reportPendingError() {
|
|
563
|
+
if (__requireBoolean(!__requireBoolean(__normalize(this.#pendingError)))) {
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
let current = __normalize(this.element);
|
|
567
|
+
__loop2: while (__requireBoolean(current !== null)) {
|
|
568
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(current.disabled) === true) || __requireBoolean(__normalize(current.hidden) === true)) || __requireBoolean(__normalize(current.inert) === true))) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
current = __normalize(current.parentNode);
|
|
572
|
+
}
|
|
573
|
+
this.#pendingError = false;
|
|
574
|
+
this.reportValidity();
|
|
575
|
+
return true;
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
applyProperty(name, value) {
|
|
579
|
+
__requireArity(arguments.length, [0, 1], "applyProperty");
|
|
580
|
+
name = __boundary(name);
|
|
581
|
+
value = __boundary(value);
|
|
582
|
+
validateProperty(name, value);
|
|
583
|
+
if (name === "enabled") {
|
|
584
|
+
this.element.disabled = !__requireBoolean(value);
|
|
585
|
+
this.element.inert = !__requireBoolean(value);
|
|
586
|
+
} else if (name === "visible") {
|
|
587
|
+
this.element.hidden = __requireBoolean(!__requireBoolean(value)) || __requireBoolean(__normalize(this.#type) === "Value");
|
|
588
|
+
} else if (name === "classes") {
|
|
589
|
+
this.#classes = classNames(value);
|
|
590
|
+
this.element.className = __normalize(this.#classes.join(" "));
|
|
591
|
+
} else if (name === "style") {
|
|
592
|
+
let styles = styleMap(value);
|
|
593
|
+
for (const [property, text] of __entries(__normalize(this.#style))) {
|
|
594
|
+
__normalize(this.element.style.removeProperty(property));
|
|
595
|
+
}
|
|
596
|
+
for (const [property, text] of __entries(styles)) {
|
|
597
|
+
__normalize(this.element.style.setProperty(property, text));
|
|
598
|
+
}
|
|
599
|
+
this.#style = styles;
|
|
600
|
+
} else if (name === "savedValue") {
|
|
601
|
+
this.acceptSaved(value);
|
|
602
|
+
} else if (name === "error") {
|
|
603
|
+
this.#error = value;
|
|
604
|
+
this.#pendingError = value !== null;
|
|
605
|
+
this.#renderError();
|
|
606
|
+
this.reportPendingError();
|
|
607
|
+
}
|
|
608
|
+
return null;
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
snapshotState() {
|
|
612
|
+
return { value: __normalize(this.#value), text: __normalize(this.element.value), checked: __normalize(this.element.checked), selectedIndex: __normalize(this.element.selectedIndex), disabled: __normalize(this.element.disabled), hidden: __normalize(this.element.hidden), inert: __normalize(this.element.inert), classes: __normalize(this.element.className), style: __normalize(this.element.style.cssText), managedStyle: __normalize(this.#style), managedClasses: __normalize(this.#classes), clean: __normalize(this.#clean), error: __normalize(this.#error), pendingError: __normalize(this.#pendingError) };
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
restoreState(snapshot) {
|
|
616
|
+
__requireArity(arguments.length, [0], "restoreState");
|
|
617
|
+
snapshot = __boundary(snapshot);
|
|
618
|
+
this.setValue(__normalize(snapshot.value));
|
|
619
|
+
if (__requireBoolean(__normalize(this.#type) === "Text")) {
|
|
620
|
+
this.element.value = __normalize(snapshot.text);
|
|
621
|
+
}
|
|
622
|
+
if (__requireBoolean(__normalize(this.#type) === "Checkbox")) {
|
|
623
|
+
this.element.checked = __normalize(snapshot.checked);
|
|
624
|
+
}
|
|
625
|
+
if (__requireBoolean(__normalize(this.#type) === "Select")) {
|
|
626
|
+
this.element.selectedIndex = __normalize(snapshot.selectedIndex);
|
|
627
|
+
}
|
|
628
|
+
this.element.disabled = __normalize(snapshot.disabled);
|
|
629
|
+
this.element.hidden = __normalize(snapshot.hidden);
|
|
630
|
+
this.element.inert = __normalize(snapshot.inert);
|
|
631
|
+
this.element.className = __normalize(snapshot.classes);
|
|
632
|
+
this.element.style.cssText = __normalize(snapshot.style);
|
|
633
|
+
this.#style = __normalize(snapshot.managedStyle);
|
|
634
|
+
this.#classes = __normalize(snapshot.managedClasses);
|
|
635
|
+
this.#clean = __normalize(snapshot.clean);
|
|
636
|
+
this.#error = __normalize(snapshot.error);
|
|
637
|
+
this.#pendingError = __normalize(snapshot.pendingError);
|
|
638
|
+
this.#renderError();
|
|
639
|
+
return null;
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
dispose() {
|
|
643
|
+
return null;
|
|
644
|
+
return null;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function validateEvent(controls, element, root) {
|
|
648
|
+
__requireArity(arguments.length, [0, 1, 2], "validateEvent");
|
|
649
|
+
controls = __boundary(controls);
|
|
650
|
+
element = __boundary(element);
|
|
651
|
+
root = __boundary(root);
|
|
652
|
+
let current = element;
|
|
653
|
+
__loop3: while (__requireBoolean(__requireBoolean(current !== null) && __requireBoolean(current !== root))) {
|
|
654
|
+
let control = elementControl(controls, current);
|
|
655
|
+
if (__requireBoolean(__requireBoolean(control !== null) && __requireBoolean(__normalize(control.validate) !== null))) {
|
|
656
|
+
__normalize(control.validate());
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
current = __normalize(current.parentNode);
|
|
660
|
+
}
|
|
661
|
+
return null;
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function elementControl(controls, element) {
|
|
666
|
+
__requireArity(arguments.length, [0, 1], "elementControl");
|
|
667
|
+
controls = __boundary(controls);
|
|
668
|
+
element = __boundary(element);
|
|
669
|
+
for (const control of controls) {
|
|
670
|
+
if (__requireBoolean(control.element.langoFormRoot === true)) {
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
if (__requireBoolean(__normalize(control.element) === element)) {
|
|
674
|
+
return control;
|
|
675
|
+
}
|
|
676
|
+
if (__requireBoolean(__isArray(__normalize(control.controls)))) {
|
|
677
|
+
let found = elementControl(__normalize(control.controls), element);
|
|
678
|
+
if (__requireBoolean(found !== null)) {
|
|
679
|
+
return found;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return null;
|
|
684
|
+
return null;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function eventTarget(controls, element, parentPath, type) {
|
|
688
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "eventTarget");
|
|
689
|
+
controls = __boundary(controls);
|
|
690
|
+
element = __boundary(element);
|
|
691
|
+
parentPath = __boundary(parentPath);
|
|
692
|
+
type = __boundary(type);
|
|
693
|
+
for (const control of controls) {
|
|
694
|
+
let path = __normalize(parentPath.slice());
|
|
695
|
+
if (__requireBoolean(__requireBoolean(__normalize(control.name) !== null) && __requireBoolean(__normalize(control.name) !== ""))) {
|
|
696
|
+
path[__normalize(path.length)] = __normalize(control.name);
|
|
697
|
+
}
|
|
698
|
+
if (__requireBoolean(__normalize(control.element) === element)) {
|
|
699
|
+
let events = __normalize(control.events);
|
|
700
|
+
if (__requireBoolean(__includes(type, events))) {
|
|
701
|
+
let name = path;
|
|
702
|
+
if (__requireBoolean(__normalize(path.length) === 1)) {
|
|
703
|
+
name = __normalize(path[0]);
|
|
704
|
+
}
|
|
705
|
+
if (__requireBoolean(__normalize(path.length) === 0)) {
|
|
706
|
+
name = null;
|
|
707
|
+
}
|
|
708
|
+
return { url: __normalize(events[type]), name: name };
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (__requireBoolean(__isArray(__normalize(control.controls)))) {
|
|
712
|
+
let target = eventTarget(__normalize(control.controls), element, path, type);
|
|
713
|
+
if (__requireBoolean(target !== null)) {
|
|
714
|
+
return target;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return null;
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function controlEvents(definition) {
|
|
723
|
+
__requireArity(arguments.length, [0], "controlEvents");
|
|
724
|
+
definition = __boundary(definition);
|
|
725
|
+
let type;
|
|
726
|
+
let events = { };
|
|
727
|
+
if (__requireBoolean(__normalize(definition.event) !== null)) {
|
|
728
|
+
type = "change";
|
|
729
|
+
if (__requireBoolean(__normalize(definition.type) === "Button")) {
|
|
730
|
+
type = "click";
|
|
731
|
+
}
|
|
732
|
+
events[type] = __normalize(definition.event);
|
|
733
|
+
}
|
|
734
|
+
if (__requireBoolean(__normalize(definition.events) !== null)) {
|
|
735
|
+
if (__requireBoolean(!__requireBoolean(__isObject(__normalize(definition.events))))) {
|
|
736
|
+
throw "UiClientEventsMustBeMap";
|
|
737
|
+
}
|
|
738
|
+
for (const [type, url] of __entries(__normalize(definition.events))) {
|
|
739
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(type !== "click") && __requireBoolean(type !== "change")) && __requireBoolean(type !== "input"))) {
|
|
740
|
+
throw "UiClientUnsupportedEventType";
|
|
741
|
+
}
|
|
742
|
+
events[type] = url;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
for (const [type, url] of __entries(events)) {
|
|
746
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(url))) || __requireBoolean(!__requireBoolean(__normalize(url.startsWith("/"))))) || __requireBoolean(__normalize(url.startsWith("//")))) || __requireBoolean(__normalize(url.includes("\\"))))) {
|
|
747
|
+
throw "UiClientEventRequiresSameOriginPath";
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
return events;
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function releaseControl(control) {
|
|
755
|
+
const __contextScope = [];
|
|
756
|
+
try {
|
|
757
|
+
__requireArity(arguments.length, [0], "releaseControl");
|
|
758
|
+
control = __boundary(control);
|
|
759
|
+
if (__requireBoolean(__isArray(__normalize(control.controls)))) {
|
|
760
|
+
for (const child of __normalize(control.controls)) {
|
|
761
|
+
releaseControl(child);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
try {
|
|
765
|
+
if (__requireBoolean(__normalize(control.dispose) !== null)) {
|
|
766
|
+
__normalize(control.dispose());
|
|
767
|
+
}
|
|
768
|
+
} catch (error) {
|
|
769
|
+
__normalize(__contextGet("log").err(`Control disposal failed: ${error}`));
|
|
770
|
+
}
|
|
771
|
+
return null;
|
|
772
|
+
return null;
|
|
773
|
+
} finally {
|
|
774
|
+
__contextRestore(__contextScope);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
export function mount(document, root, definition, types = null) {
|
|
779
|
+
__requireArity(arguments.length, [0, 1, 2], "mount");
|
|
780
|
+
document = __boundary(document);
|
|
781
|
+
root = __boundary(root);
|
|
782
|
+
definition = __boundary(definition);
|
|
783
|
+
types = __boundary(types);
|
|
784
|
+
if (__requireBoolean(types === null)) {
|
|
785
|
+
types = new Types();
|
|
786
|
+
}
|
|
787
|
+
let control = __normalize(types.create(document, definition));
|
|
788
|
+
__normalize(root.appendChild(__normalize(control.element)));
|
|
789
|
+
return control;
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
//# sourceMappingURL=library.mjs.map
|