@lango-project/lango-client 0.2.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/NOTICE +5 -1
- package/README.md +603 -906
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +120 -20
- package/cli/.lango/vendor/i18next.LICENSE +21 -0
- package/cli/.lango/vendor/i18next.mjs +2434 -0
- package/cli/create.mjs +62 -0
- package/cli/create.mjs.map +1 -0
- package/dist/.lango/localization.mjs +108 -0
- package/dist/.lango/runtime.mjs +120 -20
- package/dist/.lango/vendor/i18next.LICENSE +21 -0
- package/dist/.lango/vendor/i18next.mjs +2434 -0
- package/dist/accordion.mjs +277 -0
- package/dist/accordion.mjs.map +1 -0
- package/dist/activities.mjs +185 -0
- package/dist/activities.mjs.map +1 -0
- package/dist/app.mjs +671 -0
- package/dist/app.mjs.map +1 -0
- package/dist/boot.mjs +24 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/bootstrap-LICENSE +21 -0
- package/dist/bootstrap.min.css +6 -0
- package/dist/bootstrap.min.css.map +1 -0
- package/dist/button.mjs +77 -0
- package/dist/button.mjs.map +1 -0
- package/dist/chip.mjs +134 -0
- package/dist/chip.mjs.map +1 -0
- package/dist/client.css +102 -0
- package/dist/collections.mjs +77 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/combo_box.mjs +408 -0
- package/dist/combo_box.mjs.map +1 -0
- package/dist/content.mjs +123 -0
- package/dist/content.mjs.map +1 -0
- package/dist/control.mjs +141 -0
- package/dist/control.mjs.map +1 -0
- package/dist/date_input.mjs +242 -0
- package/dist/date_input.mjs.map +1 -0
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/error_reporter.mjs +136 -0
- package/dist/error_reporter.mjs.map +1 -0
- package/dist/fields.mjs +454 -0
- package/dist/fields.mjs.map +1 -0
- package/dist/file_input.mjs +227 -0
- package/dist/file_input.mjs.map +1 -0
- package/dist/form.mjs +272 -0
- package/dist/form.mjs.map +1 -0
- package/dist/heartbeat.mjs +167 -254
- package/dist/heartbeat.mjs.map +1 -1
- package/dist/index.html +18 -0
- package/dist/indicators.mjs +127 -0
- package/dist/indicators.mjs.map +1 -0
- package/dist/input_changes.mjs +58 -0
- package/dist/input_changes.mjs.map +1 -0
- package/dist/input_group.mjs +38 -0
- package/dist/input_group.mjs.map +1 -0
- package/dist/layouts.mjs +195 -0
- package/dist/layouts.mjs.map +1 -0
- package/dist/library.mjs +130 -807
- package/dist/library.mjs.map +1 -1
- package/dist/longpoll.mjs +254 -0
- package/dist/longpoll.mjs.map +1 -0
- package/dist/main.mjs +147 -0
- package/dist/main.mjs.map +1 -0
- package/dist/markdown.mjs +61 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/menus.mjs +468 -0
- package/dist/menus.mjs.map +1 -0
- package/dist/navigation.mjs +260 -410
- package/dist/navigation.mjs.map +1 -1
- package/dist/numeric_input.mjs +181 -0
- package/dist/numeric_input.mjs.map +1 -0
- package/dist/otp_input.mjs +113 -0
- package/dist/otp_input.mjs.map +1 -0
- package/dist/presentations.mjs +852 -0
- package/dist/presentations.mjs.map +1 -0
- package/dist/renderer.mjs +295 -0
- package/dist/renderer.mjs.map +1 -0
- package/dist/rich_content.mjs +99 -0
- package/dist/rich_content.mjs.map +1 -0
- package/dist/table_scope.mjs +166 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +1052 -0
- package/dist/tables.mjs.map +1 -0
- package/dist/tabs.mjs +205 -0
- package/dist/tabs.mjs.map +1 -0
- package/dist/templates.mjs +46 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/vendor/DOMPurify-LICENSE +202 -0
- package/dist/vendor/dompurify.mjs +2454 -0
- package/dist/vendor/flatpickr-LICENSE.md +21 -0
- package/dist/vendor/flatpickr.min.css +13 -0
- package/dist/vendor/flatpickr.mjs +2340 -0
- package/dist/vendor/flatpickr.mjs.map +7 -0
- package/dist/vendor/marked-LICENSE.md +44 -0
- package/dist/vendor/marked.esm.js.map +7 -0
- package/dist/vendor/marked.mjs +85 -0
- package/dist/vendor/purify.es.mjs.map +1 -0
- package/dist/widgets.mjs +197 -0
- package/dist/widgets.mjs.map +1 -0
- package/docs/implementation.md +93 -0
- package/package.json +25 -43
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +540 -0
- package/src/boot.lango +12 -0
- package/src/button.lango +49 -0
- package/src/chip.lango +94 -0
- package/src/collections.lango +46 -0
- package/src/combo_box.lango +298 -0
- package/src/content.lango +75 -0
- package/src/control.lango +103 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -0
- package/src/dimensions.lango +65 -0
- package/src/error_reporter.lango +95 -0
- package/src/fields.lango +327 -0
- package/src/file_input.lango +175 -0
- package/src/form.lango +195 -0
- package/src/heartbeat.lango +136 -199
- package/src/indicators.lango +94 -0
- package/src/input_changes.lango +33 -0
- package/src/input_group.lango +22 -0
- package/src/layouts.lango +137 -0
- package/src/library.lango +194 -599
- package/src/longpoll.lango +187 -0
- package/src/main.lango +118 -0
- package/src/markdown.lango +48 -0
- package/src/menus.lango +336 -0
- package/src/navigation.lango +209 -299
- package/src/numeric_input.lango +131 -0
- package/src/otp_input.lango +83 -0
- package/src/presentations.lango +617 -0
- package/src/renderer.lango +296 -0
- package/src/rich_content.lango +66 -0
- package/src/table_scope.lango +119 -0
- package/src/tables.lango +786 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +102 -0
- package/web/index.html +18 -0
- package/dist/application.mjs +0 -429
- package/dist/application.mjs.map +0 -1
- package/dist/coordinator.mjs +0 -91
- package/dist/coordinator.mjs.map +0 -1
- package/dist/demo.mjs +0 -110
- package/dist/demo.mjs.map +0 -1
- package/dist/demo_controls.mjs +0 -59
- package/dist/demo_controls.mjs.map +0 -1
- package/dist/errors.mjs +0 -201
- package/dist/errors.mjs.map +0 -1
- package/dist/form_state.mjs +0 -266
- package/dist/form_state.mjs.map +0 -1
- package/dist/inheritance.mjs +0 -240
- package/dist/inheritance.mjs.map +0 -1
- package/dist/input_values.mjs +0 -65
- package/dist/input_values.mjs.map +0 -1
- package/dist/node/.lango/xmldom/conventions.js +0 -429
- package/dist/node/.lango/xmldom/dom-parser.js +0 -591
- package/dist/node/.lango/xmldom/dom.js +0 -3759
- package/dist/node/.lango/xmldom/entities.js +0 -2171
- package/dist/node/.lango/xmldom/errors.js +0 -205
- package/dist/node/.lango/xmldom/grammar.js +0 -559
- package/dist/node/.lango/xmldom/index.js +0 -41
- package/dist/node/.lango/xmldom/package.json +0 -1
- package/dist/node/.lango/xmldom/sax.js +0 -983
- package/dist/node/.lango/xmldom.LICENSE.md +0 -8
- package/dist/node/browser_host.mjs +0 -351
- package/dist/node/browser_host.mjs.map +0 -1
- package/dist/node/create_app.mjs +0 -118
- package/dist/node/create_app.mjs.map +0 -1
- package/dist/presentation.mjs +0 -89
- package/dist/presentation.mjs.map +0 -1
- package/dist/protocol.mjs +0 -706
- package/dist/protocol.mjs.map +0 -1
- package/dist/session.mjs +0 -471
- package/dist/session.mjs.map +0 -1
- package/dist/tokens.mjs +0 -298
- package/dist/tokens.mjs.map +0 -1
- package/examples/contacts.lango +0 -293
- package/examples/contacts_flow.lango +0 -174
- package/examples/contacts_store.lango +0 -109
- package/examples/contacts_store_test.lango +0 -65
- package/examples/demo.css +0 -87
- package/examples/demo_test.lango +0 -356
- package/examples/index.html +0 -32
- package/examples/pages.lango +0 -174
- package/examples/server.lango +0 -189
- package/examples/worker.lango +0 -142
- package/src/application.lango +0 -327
- package/src/browser_host.lango +0 -276
- package/src/coordinator.lango +0 -57
- package/src/demo.lango +0 -110
- package/src/demo_controls.lango +0 -53
- package/src/errors.lango +0 -149
- package/src/errors_test.lango +0 -157
- package/src/form_state.lango +0 -168
- package/src/heartbeat_test.lango +0 -479
- package/src/inheritance.lango +0 -167
- package/src/input_values.lango +0 -37
- package/src/logout_test.lango +0 -564
- package/src/navigation_test.lango +0 -556
- package/src/presentation.lango +0 -55
- package/src/protocol.lango +0 -787
- package/src/renderer_test.lango +0 -2047
- package/src/session.lango +0 -343
- package/src/session_test.lango +0 -455
- package/src/tabs_test.lango +0 -216
- package/src/tokens.lango +0 -215
- package/template/.vscode/extensions.json +0 -3
- package/template/.vscode/settings.json +0 -9
- package/template/README.md +0 -44
- package/template/gitignore +0 -4
- package/template/package.json +0 -22
- package/template/public/app.css +0 -10
- package/template/public/index.html +0 -24
- package/template/src/client.lango +0 -78
- package/template/src/pages.lango +0 -55
- package/template/src/server.lango +0 -24
- package/template/src/worker.lango +0 -77
- package/template/test/app.lango +0 -9
- package/tools/browser_runner.lango +0 -32
- package/tools/browser_test.lango +0 -343
- package/tools/create_app.lango +0 -88
- package/tools/create_app_test.lango +0 -43
- package/tools/starter_test.lango +0 -227
- /package/{dist/node → cli}/.lango/bignumber.mjs +0 -0
- /package/{dist → cli}/.lango/xmldom/conventions.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom-parser.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom.js +0 -0
- /package/{dist → cli}/.lango/xmldom/entities.js +0 -0
- /package/{dist → cli}/.lango/xmldom/errors.js +0 -0
- /package/{dist → cli}/.lango/xmldom/grammar.js +0 -0
- /package/{dist → cli}/.lango/xmldom/index.js +0 -0
- /package/{dist → cli}/.lango/xmldom/package.json +0 -0
- /package/{dist → cli}/.lango/xmldom/sax.js +0 -0
- /package/{dist → cli}/.lango/xmldom.LICENSE.md +0 -0
package/dist/demo_controls.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Control, Types } from "./library.mjs";
|
|
2
|
-
import {
|
|
3
|
-
requireBoolean as __requireBoolean,
|
|
4
|
-
normalize as __normalize,
|
|
5
|
-
boundary as __boundary,
|
|
6
|
-
requireArity as __requireArity,
|
|
7
|
-
} from "./.lango/runtime.mjs";
|
|
8
|
-
|
|
9
|
-
export class DemoErrors {
|
|
10
|
-
#element;
|
|
11
|
-
constructor(element) {
|
|
12
|
-
__requireArity(arguments.length, [0], "constructor");
|
|
13
|
-
element = __boundary(element);
|
|
14
|
-
this.#element = element;
|
|
15
|
-
}
|
|
16
|
-
clear() {
|
|
17
|
-
this.#element.textContent = "";
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
error(error) {
|
|
21
|
-
__requireArity(arguments.length, [0], "error");
|
|
22
|
-
error = __boundary(error);
|
|
23
|
-
let text = "The request failed. Please try again.";
|
|
24
|
-
if (__requireBoolean(error === "UiValidationFailed")) {
|
|
25
|
-
text = "Please correct the highlighted fields before saving.";
|
|
26
|
-
}
|
|
27
|
-
this.#element.textContent = text;
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
class Label extends Control {
|
|
33
|
-
constructor(document, definition, types) {
|
|
34
|
-
super(document, definition, types, { tag: "p" });
|
|
35
|
-
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
36
|
-
document = __boundary(document);
|
|
37
|
-
definition = __boundary(definition);
|
|
38
|
-
types = __boundary(types);
|
|
39
|
-
}
|
|
40
|
-
setValue(value) {
|
|
41
|
-
__requireArity(arguments.length, [0], "setValue");
|
|
42
|
-
value = __boundary(value);
|
|
43
|
-
super.setValue(value);
|
|
44
|
-
let text = value;
|
|
45
|
-
if (__requireBoolean(text === null)) {
|
|
46
|
-
text = "";
|
|
47
|
-
}
|
|
48
|
-
this.element.textContent = text;
|
|
49
|
-
return null;
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function demoTypes() {
|
|
54
|
-
let types = new Types({ classes: { Form: ["demo-form"], Text: ["demo-input"], Select: ["demo-input"], Checkbox: ["demo-checkbox"], Button: ["demo-button"], Label: ["demo-label"] } });
|
|
55
|
-
__normalize(types.registerType("Label", Label));
|
|
56
|
-
return types;
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=demo_controls.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"demo_controls.mjs","sources":["demo_controls.lango"],"sourcesContent":["import \"./library\"\n class Control\n class Types\n\nexport demoTypes()\n\nexport class DemoErrors\n methods\n clear()\n error(error)\n\nDemoErrors(element)\n @element = element\n\nDemoErrors:clear()\n @element.textContent = \"\"\n\nDemoErrors:error(error)\n text = \"The request failed. Please try again.\"\n if error == \"UiValidationFailed\"\n text = \"Please correct the highlighted fields before saving.\"\n @element.textContent = text\n\ndemoTypes()\n types = new Types({\n classes: {\n Form: [\"demo-form\"]\n Text: [\"demo-input\"]\n Select: [\"demo-input\"]\n Checkbox: [\"demo-checkbox\"]\n Button: [\"demo-button\"]\n Label: [\"demo-label\"]\n }\n })\n types.registerType(\"Label\", Label)\n return types\n\nclass Label : Control\n methods\n setValue(value)\n\nLabel(document, definition, types)\n super(document, definition, types, {\n tag: \"p\"\n })\n\nLabel:setValue(value)\n super.setValue(value)\n text = value\n if text == null\n text = \"\"\n @element.textContent = text\n return null\n"],"names":[],"mappings":";;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;AA+BA;;;;;;;;;;;;;;;;;;;;;AAdA;;;;;;;"}
|
package/dist/errors.mjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hostGlobal as __hostGlobal,
|
|
3
|
-
hostGlobalCall as __hostGlobalCall,
|
|
4
|
-
fromJson as __fromJson,
|
|
5
|
-
toJson as __toJson,
|
|
6
|
-
isNumber as __isNumber,
|
|
7
|
-
isString as __isString,
|
|
8
|
-
isBool as __isBool,
|
|
9
|
-
isObject as __isObject,
|
|
10
|
-
isArray as __isArray,
|
|
11
|
-
add as __add,
|
|
12
|
-
requireBoolean as __requireBoolean,
|
|
13
|
-
normalize as __normalize,
|
|
14
|
-
numericAdd as __numericAdd,
|
|
15
|
-
boundary as __boundary,
|
|
16
|
-
requireArity as __requireArity,
|
|
17
|
-
withArity as __withArity,
|
|
18
|
-
} from "./.lango/runtime.mjs";
|
|
19
|
-
|
|
20
|
-
export class ErrorReporter {
|
|
21
|
-
#window;
|
|
22
|
-
#transport;
|
|
23
|
-
#pending;
|
|
24
|
-
#timer;
|
|
25
|
-
#running;
|
|
26
|
-
#disposed;
|
|
27
|
-
#until;
|
|
28
|
-
#sent;
|
|
29
|
-
#onError;
|
|
30
|
-
#onRejection;
|
|
31
|
-
constructor(options) {
|
|
32
|
-
__requireArity(arguments.length, [0], "constructor");
|
|
33
|
-
options = __boundary(options);
|
|
34
|
-
this.#window = __normalize(options.window);
|
|
35
|
-
this.#transport = __normalize(options.transport);
|
|
36
|
-
if (__requireBoolean(__normalize(this.#transport) === null)) {
|
|
37
|
-
this.#transport = new ReportTransport();
|
|
38
|
-
}
|
|
39
|
-
this.#pending = [];
|
|
40
|
-
this.#timer = null;
|
|
41
|
-
this.#running = null;
|
|
42
|
-
this.#disposed = false;
|
|
43
|
-
this.#until = 0;
|
|
44
|
-
this.#sent = 0;
|
|
45
|
-
let onError = __withArity((event) => {
|
|
46
|
-
event = __boundary(event);
|
|
47
|
-
this.report("window");
|
|
48
|
-
return null;
|
|
49
|
-
}, [0], "closure");
|
|
50
|
-
let onRejection = __withArity((event) => {
|
|
51
|
-
event = __boundary(event);
|
|
52
|
-
this.report("promise");
|
|
53
|
-
return null;
|
|
54
|
-
}, [0], "closure");
|
|
55
|
-
this.#onError = onError;
|
|
56
|
-
this.#onRejection = onRejection;
|
|
57
|
-
if (__requireBoolean(__normalize(this.#window) !== null)) {
|
|
58
|
-
__normalize(this.#window.addEventListener("error", __normalize(this.#onError)));
|
|
59
|
-
__normalize(this.#window.addEventListener("unhandledrejection", __normalize(this.#onRejection)));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
error(error) {
|
|
63
|
-
__requireArity(arguments.length, [0], "error");
|
|
64
|
-
error = __boundary(error);
|
|
65
|
-
let code = "UnexpectedError";
|
|
66
|
-
if (__requireBoolean(__isString(error))) {
|
|
67
|
-
if (__requireBoolean(__requireBoolean(error === "UiValidationFailed") || __requireBoolean(error === "UiSessionDisposed"))) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
if (__requireBoolean(error === "UiProtocolUnsupported")) {
|
|
71
|
-
code = "UiProtocolUnsupported";
|
|
72
|
-
}
|
|
73
|
-
if (__requireBoolean(__normalize(error.startsWith("UiHttpError:")))) {
|
|
74
|
-
code = "UiHttpError";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return this.report("ui", code);
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
clear() {
|
|
81
|
-
return null;
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
report(source, code = "UnexpectedError") {
|
|
85
|
-
__requireArity(arguments.length, [0], "report");
|
|
86
|
-
source = __boundary(source);
|
|
87
|
-
code = __boundary(code);
|
|
88
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
let sources = ["window", "promise", "ui"];
|
|
92
|
-
let codes = ["UnexpectedError", "UiProtocolUnsupported", "UiHttpError"];
|
|
93
|
-
let origin = source;
|
|
94
|
-
let category = code;
|
|
95
|
-
if (__requireBoolean(!__requireBoolean(__normalize(sources.includes(origin))))) {
|
|
96
|
-
origin = "ui";
|
|
97
|
-
}
|
|
98
|
-
if (__requireBoolean(!__requireBoolean(__normalize(codes.includes(category))))) {
|
|
99
|
-
category = "UnexpectedError";
|
|
100
|
-
}
|
|
101
|
-
for (const entry of __normalize(this.#pending)) {
|
|
102
|
-
if (__requireBoolean(__requireBoolean(__normalize(entry.source) === origin) && __requireBoolean(__normalize(entry.code) === category))) {
|
|
103
|
-
if (__requireBoolean(__normalize(entry.count) < 100)) {
|
|
104
|
-
entry.count = __numericAdd(__normalize(entry.count), 1);
|
|
105
|
-
}
|
|
106
|
-
this.#schedule();
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
__add(this.#pending, { version: 1, source: origin, code: category, count: 1 });
|
|
111
|
-
this.#schedule();
|
|
112
|
-
return null;
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
#schedule() {
|
|
116
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#disposed)) || __requireBoolean(__normalize(this.#timer) !== null)) || __requireBoolean(__normalize(this.#running) !== null)) || __requireBoolean(__normalize(this.#pending.length) === 0))) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
let send = () => {
|
|
120
|
-
this.flush();
|
|
121
|
-
return null;
|
|
122
|
-
};
|
|
123
|
-
this.#timer = __hostGlobalCall(["setTimeout"], send, 1000);
|
|
124
|
-
return null;
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
flush() {
|
|
128
|
-
__hostGlobalCall(["clearTimeout"], __normalize(this.#timer));
|
|
129
|
-
this.#timer = null;
|
|
130
|
-
if (__requireBoolean(__normalize(this.#disposed))) {
|
|
131
|
-
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
132
|
-
}
|
|
133
|
-
if (__requireBoolean(__normalize(this.#running) !== null)) {
|
|
134
|
-
return __normalize(this.#running);
|
|
135
|
-
}
|
|
136
|
-
let now = __normalize(__hostGlobal(["performance"]).now());
|
|
137
|
-
if (__requireBoolean(now >= __normalize(this.#until))) {
|
|
138
|
-
this.#until = __numericAdd(now, 60000);
|
|
139
|
-
this.#sent = 0;
|
|
140
|
-
}
|
|
141
|
-
let reports = __normalize(this.#pending);
|
|
142
|
-
this.#pending = [];
|
|
143
|
-
let pending = [];
|
|
144
|
-
for (const entry of reports) {
|
|
145
|
-
if (__requireBoolean(__normalize(this.#sent) < 10)) {
|
|
146
|
-
this.#sent = __numericAdd(__normalize(this.#sent), 1);
|
|
147
|
-
pending.push(sendReport(__normalize(this.#transport), entry));
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
let joined = __normalize(__hostGlobal(["Promise"]).all(pending));
|
|
151
|
-
let running = __normalize(joined.finally(() => {
|
|
152
|
-
this.#running = null;
|
|
153
|
-
this.#schedule();
|
|
154
|
-
return null;
|
|
155
|
-
}));
|
|
156
|
-
this.#running = running;
|
|
157
|
-
return __normalize(this.#running);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
dispose() {
|
|
161
|
-
this.#disposed = true;
|
|
162
|
-
__hostGlobalCall(["clearTimeout"], __normalize(this.#timer));
|
|
163
|
-
this.#timer = null;
|
|
164
|
-
this.#pending = [];
|
|
165
|
-
if (__requireBoolean(__normalize(this.#window) !== null)) {
|
|
166
|
-
__normalize(this.#window.removeEventListener("error", __normalize(this.#onError)));
|
|
167
|
-
__normalize(this.#window.removeEventListener("unhandledrejection", __normalize(this.#onRejection)));
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
class ReportTransport {
|
|
175
|
-
send(report) {
|
|
176
|
-
__requireArity(arguments.length, [0], "send");
|
|
177
|
-
report = __boundary(report);
|
|
178
|
-
let signal = __normalize(__hostGlobal(["AbortSignal"]).timeout(5000));
|
|
179
|
-
return __hostGlobalCall(["fetch"], "/_lango/client-error", { method: "POST", headers: { "Content-Type": "application/json" }, credentials: "omit", cache: "no-store", referrerPolicy: "no-referrer", redirect: "error", signal: signal, body: __toJson(report) }).then(__withArity((response) => {
|
|
180
|
-
response = __boundary(response);
|
|
181
|
-
return null;
|
|
182
|
-
return null;
|
|
183
|
-
}, [0], "closure"));
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function sendReport(transport, entry) {
|
|
188
|
-
__requireArity(arguments.length, [0, 1], "sendReport");
|
|
189
|
-
transport = __boundary(transport);
|
|
190
|
-
entry = __boundary(entry);
|
|
191
|
-
return __normalize(__hostGlobal(["Promise"]).resolve()).then(() => {
|
|
192
|
-
return __normalize(transport.send(entry));
|
|
193
|
-
return null;
|
|
194
|
-
}).catch(__withArity((error) => {
|
|
195
|
-
error = __boundary(error);
|
|
196
|
-
return null;
|
|
197
|
-
return null;
|
|
198
|
-
}, [0], "closure"));
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","sources":["errors.lango"],"sourcesContent":["import js global Promise\nimport js global performance\nimport js global setTimeout\nimport js global clearTimeout\nimport js global fetch\nimport js global AbortSignal\n\nexport class ErrorReporter\n methods\n error(error)\n clear()\n report(source, code = \"UnexpectedError\")\n flush()\n dispose()\n\nErrorReporter(options)\n @window = options.window\n @transport = options.transport\n if @transport == null\n @transport = new ReportTransport()\n @pending = []\n @timer = null\n @running = null\n @disposed = false\n @until = 0\n @sent = 0\n onError = (event)\n report(\"window\")\n onRejection = (event)\n report(\"promise\")\n @onError = onError\n @onRejection = onRejection\n if @window != null\n @window.addEventListener(\"error\", @onError)\n @window.addEventListener(\"unhandledrejection\", @onRejection)\n\nErrorReporter:error(error)\n code = \"UnexpectedError\"\n if is_string(error)\n if error == \"UiValidationFailed\" or error == \"UiSessionDisposed\"\n return null\n if error == \"UiProtocolUnsupported\"\n code = \"UiProtocolUnsupported\"\n if error.startsWith(\"UiHttpError:\")\n code = \"UiHttpError\"\n return report(\"ui\", code)\n\nErrorReporter:clear()\n return null\n\nErrorReporter:report(source, code = \"UnexpectedError\")\n if @disposed\n return null\n sources = [\"window\", \"promise\", \"ui\"]\n codes = [\"UnexpectedError\", \"UiProtocolUnsupported\", \"UiHttpError\"]\n origin = source\n category = code\n if !sources.includes(origin)\n origin = \"ui\"\n if !codes.includes(category)\n category = \"UnexpectedError\"\n for @pending as entry\n if entry.source == origin and entry.code == category\n if entry.count < 100\n entry.count = entry.count + 1\n schedule()\n return null\n @pending.add({\n version: 1\n source: origin\n code: category\n count: 1\n })\n schedule()\n return null\n\nErrorReporter:schedule()\n if @disposed or @timer != null or @running != null or @pending.length == 0\n return null\n send = ()\n flush()\n @timer = setTimeout(send, 1000)\n return null\n\nErrorReporter:flush()\n clearTimeout(@timer)\n @timer = null\n if @disposed\n return Promise/resolve(null)\n if @running != null\n return @running\n now = performance.now()\n if now >= @until\n @until = now + 60000\n @sent = 0\n reports = @pending\n @pending = []\n pending = []\n for reports as entry\n if @sent < 10\n @sent = @sent + 1\n pending.add(sendReport(@transport, entry))\n joined = Promise/all(pending)\n running = joined.finally(()\n @running = null\n schedule()\n )\n @running = running\n return @running\n\nsendReport(transport, entry)\n return Promise/resolve().then(()\n capture transport\n capture entry\n return transport.send(entry)\n ).catch((error)\n return null\n )\n\nErrorReporter:dispose()\n @disposed = true\n clearTimeout(@timer)\n @timer = null\n @pending = []\n if @window != null\n @window.removeEventListener(\"error\", @onError)\n @window.removeEventListener(\"unhandledrejection\", @onRejection)\n return null\n\nclass ReportTransport\n methods\n send(report)\n\nReportTransport:send(report)\n signal = AbortSignal/timeout(5000)\n return fetch(\"/_lango/client-error\", {\n method: \"POST\"\n headers: {\n \"Content-Type\": \"application/json\"\n }\n credentials: \"omit\"\n cache: \"no-store\"\n referrerPolicy: \"no-referrer\"\n redirect: \"error\"\n signal: signal\n body: to_json(report)\n }).then((response)\n return null\n )\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0HA;;;;;;;;;;;;;AAnBA;;;;;;;;;;;;;;;"}
|
package/dist/form_state.mjs
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hostGlobal as __hostGlobal,
|
|
3
|
-
getClass as __getClass,
|
|
4
|
-
isKindof as __isKindof,
|
|
5
|
-
isNumber as __isNumber,
|
|
6
|
-
isString as __isString,
|
|
7
|
-
isBool as __isBool,
|
|
8
|
-
isObject as __isObject,
|
|
9
|
-
isArray as __isArray,
|
|
10
|
-
includes as __includes,
|
|
11
|
-
entries as __entries,
|
|
12
|
-
add as __add,
|
|
13
|
-
requireBoolean as __requireBoolean,
|
|
14
|
-
normalize as __normalize,
|
|
15
|
-
finite as __finite,
|
|
16
|
-
numericAdd as __numericAdd,
|
|
17
|
-
boundary as __boundary,
|
|
18
|
-
requireArity as __requireArity,
|
|
19
|
-
} from "./.lango/runtime.mjs";
|
|
20
|
-
|
|
21
|
-
export function rulesFor(value) {
|
|
22
|
-
__requireArity(arguments.length, [0], "rulesFor");
|
|
23
|
-
value = __boundary(value);
|
|
24
|
-
if (__requireBoolean(value === null)) {
|
|
25
|
-
return { };
|
|
26
|
-
}
|
|
27
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(value))) || __requireBoolean(__isArray(value)))) {
|
|
28
|
-
throw "UiValidationRequiresMap";
|
|
29
|
-
}
|
|
30
|
-
let rules = { };
|
|
31
|
-
for (const [name, item] of __entries(value)) {
|
|
32
|
-
if (name === "required") {
|
|
33
|
-
if (__requireBoolean(!__requireBoolean(__isBool(item)))) {
|
|
34
|
-
throw "UiValidationRequiredMustBeBoolean";
|
|
35
|
-
}
|
|
36
|
-
} else if (name === "minLength") {
|
|
37
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(item))) || __requireBoolean(item < 0)) || __requireBoolean(__finite(item % 1) !== 0))) {
|
|
38
|
-
throw "UiValidationLengthMustBeNonnegativeInteger";
|
|
39
|
-
}
|
|
40
|
-
} else if (name === "maxLength") {
|
|
41
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(item))) || __requireBoolean(item < 0)) || __requireBoolean(__finite(item % 1) !== 0))) {
|
|
42
|
-
throw "UiValidationLengthMustBeNonnegativeInteger";
|
|
43
|
-
}
|
|
44
|
-
} else if (name === "pattern") {
|
|
45
|
-
if (__requireBoolean(!__requireBoolean(__isString(item)))) {
|
|
46
|
-
throw "UiValidationPatternMustBeString";
|
|
47
|
-
}
|
|
48
|
-
let expression = new (__hostGlobal(["RegExp"]))(`^(?:${item})$`);
|
|
49
|
-
} else if (name === "message") {
|
|
50
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(item))) || __requireBoolean(item === ""))) {
|
|
51
|
-
throw "UiValidationMessageMustBeString";
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
throw `UiUnknownValidationRule: ${name}`;
|
|
55
|
-
}
|
|
56
|
-
rules[name] = item;
|
|
57
|
-
}
|
|
58
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(rules.minLength) !== null) && __requireBoolean(__normalize(rules.maxLength) !== null)) && __requireBoolean(__normalize(rules.minLength) > __normalize(rules.maxLength)))) {
|
|
59
|
-
throw "UiValidationLengthRangeInvalid";
|
|
60
|
-
}
|
|
61
|
-
return rules;
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function validationMessage(rules, value) {
|
|
66
|
-
__requireArity(arguments.length, [0, 1], "validationMessage");
|
|
67
|
-
rules = __boundary(rules);
|
|
68
|
-
value = __boundary(value);
|
|
69
|
-
let pattern;
|
|
70
|
-
let empty = __requireBoolean(value === null) || __requireBoolean(value === false);
|
|
71
|
-
if (__requireBoolean(__isString(value))) {
|
|
72
|
-
empty = __normalize(value.trim()) === "";
|
|
73
|
-
}
|
|
74
|
-
let message = null;
|
|
75
|
-
if (__requireBoolean(__requireBoolean(__normalize(rules.required) === true) && __requireBoolean(empty))) {
|
|
76
|
-
message = "This field is required.";
|
|
77
|
-
}
|
|
78
|
-
if (__requireBoolean(!__requireBoolean(empty))) {
|
|
79
|
-
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(rules.minLength) !== null) || __requireBoolean(__normalize(rules.maxLength) !== null)) || __requireBoolean(__normalize(rules.pattern) !== null))) {
|
|
80
|
-
if (__requireBoolean(!__requireBoolean(__isString(value)))) {
|
|
81
|
-
message = "This value must be text.";
|
|
82
|
-
} else {
|
|
83
|
-
if (__requireBoolean(__requireBoolean(__normalize(rules.minLength) !== null) && __requireBoolean(__normalize(value.length) < __normalize(rules.minLength)))) {
|
|
84
|
-
message = `Enter at least ${__normalize(rules.minLength)} characters.`;
|
|
85
|
-
}
|
|
86
|
-
if (__requireBoolean(__requireBoolean(__normalize(rules.maxLength) !== null) && __requireBoolean(__normalize(value.length) > __normalize(rules.maxLength)))) {
|
|
87
|
-
message = `Enter at most ${__normalize(rules.maxLength)} characters.`;
|
|
88
|
-
}
|
|
89
|
-
if (__requireBoolean(__normalize(rules.pattern) !== null)) {
|
|
90
|
-
pattern = new (__hostGlobal(["RegExp"]))(`^(?:${__normalize(rules.pattern)})$`);
|
|
91
|
-
if (__requireBoolean(!__requireBoolean(__normalize(pattern.test(value))))) {
|
|
92
|
-
message = "Enter a value in the required format.";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (__requireBoolean(__requireBoolean(message !== null) && __requireBoolean(__normalize(rules.message) !== null))) {
|
|
99
|
-
return __normalize(rules.message);
|
|
100
|
-
}
|
|
101
|
-
return message;
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function sameValue(left, right) {
|
|
106
|
-
__requireArity(arguments.length, [0, 1], "sameValue");
|
|
107
|
-
left = __boundary(left);
|
|
108
|
-
right = __boundary(right);
|
|
109
|
-
let count;
|
|
110
|
-
let other;
|
|
111
|
-
if (__requireBoolean(__isArray(left))) {
|
|
112
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isArray(right))) || __requireBoolean(__normalize(left.length) !== __normalize(right.length)))) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
for (const [index, value] of __entries(left)) {
|
|
116
|
-
if (__requireBoolean(!__requireBoolean(sameValue(value, __normalize(right[index]))))) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
if (__requireBoolean(__isObject(left))) {
|
|
123
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(right))) || __requireBoolean(__isArray(right)))) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
count = 0;
|
|
127
|
-
other = 0;
|
|
128
|
-
for (const [name, value] of __entries(left)) {
|
|
129
|
-
count = __numericAdd(count, 1);
|
|
130
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__includes(name, right))) || __requireBoolean(!__requireBoolean(sameValue(value, __normalize(right[name])))))) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
for (const [name, value] of __entries(right)) {
|
|
135
|
-
other = __numericAdd(other, 1);
|
|
136
|
-
}
|
|
137
|
-
return count === other;
|
|
138
|
-
}
|
|
139
|
-
return left === right;
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function ownedFields(controls) {
|
|
144
|
-
__requireArity(arguments.length, [0], "ownedFields");
|
|
145
|
-
controls = __boundary(controls);
|
|
146
|
-
let result = [];
|
|
147
|
-
collectFields(controls, [], result, false);
|
|
148
|
-
return result;
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function collectFields(controls, parent, result, blocked) {
|
|
153
|
-
__requireArity(arguments.length, [0, 1, 2, 3], "collectFields");
|
|
154
|
-
controls = __boundary(controls);
|
|
155
|
-
parent = __boundary(parent);
|
|
156
|
-
result = __boundary(result);
|
|
157
|
-
blocked = __boundary(blocked);
|
|
158
|
-
for (const control of controls) {
|
|
159
|
-
if (__requireBoolean(__requireBoolean(__normalize(control.element) !== null) && __requireBoolean(control.element.langoFormRoot === true))) {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
let path = __normalize(parent.slice());
|
|
163
|
-
let unavailable = blocked;
|
|
164
|
-
if (__requireBoolean(__normalize(control.element) !== null)) {
|
|
165
|
-
unavailable = __requireBoolean(__requireBoolean(__requireBoolean(unavailable) || __requireBoolean(control.element.disabled === true)) || __requireBoolean(control.element.hidden === true)) || __requireBoolean(control.element.inert === true);
|
|
166
|
-
}
|
|
167
|
-
if (__requireBoolean(__requireBoolean(__normalize(control.name) !== null) && __requireBoolean(__normalize(control.name) !== ""))) {
|
|
168
|
-
__add(path, __normalize(control.name));
|
|
169
|
-
}
|
|
170
|
-
if (__requireBoolean(__isArray(__normalize(control.controls)))) {
|
|
171
|
-
collectFields(__normalize(control.controls), path, result, unavailable);
|
|
172
|
-
} else {
|
|
173
|
-
__add(result, { control: control, path: path, blocked: unavailable });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function dirtyFields(controls) {
|
|
180
|
-
__requireArity(arguments.length, [0], "dirtyFields");
|
|
181
|
-
controls = __boundary(controls);
|
|
182
|
-
let fields = ownedFields(controls);
|
|
183
|
-
for (const field of fields) {
|
|
184
|
-
let control = __normalize(field.control);
|
|
185
|
-
if (__requireBoolean(__isKindof(__normalize(control.isDirty), Function))) {
|
|
186
|
-
if (__requireBoolean(__normalize(control.isDirty()))) {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return false;
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function validateFields(controls) {
|
|
196
|
-
__requireArity(arguments.length, [0], "validateFields");
|
|
197
|
-
controls = __boundary(controls);
|
|
198
|
-
let issues = [];
|
|
199
|
-
let fields = ownedFields(controls);
|
|
200
|
-
for (const field of fields) {
|
|
201
|
-
if (__requireBoolean(__normalize(field.blocked))) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
let control = __normalize(field.control);
|
|
205
|
-
if (__requireBoolean(__isKindof(__normalize(control.validate), Function))) {
|
|
206
|
-
let message = __normalize(control.validate());
|
|
207
|
-
if (__requireBoolean(message !== null)) {
|
|
208
|
-
issues.push({ path: __normalize(field.path), message: message, control: __normalize(field.control) });
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return issues;
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function validatesRequest(controls, name) {
|
|
217
|
-
__requireArity(arguments.length, [0, 1], "validatesRequest");
|
|
218
|
-
controls = __boundary(controls);
|
|
219
|
-
name = __boundary(name);
|
|
220
|
-
let target = requestSource(controls, name);
|
|
221
|
-
return __requireBoolean(target !== null) && __requireBoolean(__normalize(target.validates) === true);
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export function confirmsRequest(controls, name) {
|
|
226
|
-
__requireArity(arguments.length, [0, 1], "confirmsRequest");
|
|
227
|
-
controls = __boundary(controls);
|
|
228
|
-
name = __boundary(name);
|
|
229
|
-
let target = requestSource(controls, name);
|
|
230
|
-
return __requireBoolean(target !== null) && __requireBoolean(__normalize(target.confirms) === true);
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function requestSource(controls, name) {
|
|
235
|
-
__requireArity(arguments.length, [0, 1], "requestSource");
|
|
236
|
-
controls = __boundary(controls);
|
|
237
|
-
name = __boundary(name);
|
|
238
|
-
let path = name;
|
|
239
|
-
if (__requireBoolean(__isString(path))) {
|
|
240
|
-
path = [path];
|
|
241
|
-
}
|
|
242
|
-
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isArray(path))) || __requireBoolean(__normalize(path.length) === 0))) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
let current = controls;
|
|
246
|
-
let target = null;
|
|
247
|
-
for (const part of path) {
|
|
248
|
-
if (__requireBoolean(!__requireBoolean(__isArray(current)))) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
target = null;
|
|
252
|
-
for (const control of current) {
|
|
253
|
-
if (__requireBoolean(__normalize(control.name) === part)) {
|
|
254
|
-
target = control;
|
|
255
|
-
break;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (__requireBoolean(target === null)) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
current = __normalize(target.controls);
|
|
262
|
-
}
|
|
263
|
-
return target;
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
//# sourceMappingURL=form_state.mjs.map
|
package/dist/form_state.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"form_state.mjs","sources":["form_state.lango"],"sourcesContent":["import js global RegExp\n\nexport rulesFor(value)\nexport validationMessage(rules, value)\nexport sameValue(left, right)\nexport ownedFields(controls)\nexport dirtyFields(controls)\nexport validateFields(controls)\nexport validatesRequest(controls, name)\nexport confirmsRequest(controls, name)\n\nrulesFor(value)\n if value == null\n return {\n }\n if !is_object(value) or is_array(value)\n throw \"UiValidationRequiresMap\"\n rules = {\n }\n for value as name: item\n switch name\n case \"required\"\n if !is_bool(item)\n throw \"UiValidationRequiredMustBeBoolean\"\n case \"minLength\"\n if !is_number(item) or item < 0 or item % 1 != 0\n throw \"UiValidationLengthMustBeNonnegativeInteger\"\n case \"maxLength\"\n if !is_number(item) or item < 0 or item % 1 != 0\n throw \"UiValidationLengthMustBeNonnegativeInteger\"\n case \"pattern\"\n if !is_string(item)\n throw \"UiValidationPatternMustBeString\"\n expression = new RegExp(\"^(?:${item})$\")\n case \"message\"\n if !is_string(item) or item == \"\"\n throw \"UiValidationMessageMustBeString\"\n else\n throw \"UiUnknownValidationRule: ${name}\"\n rules[name] = item\n if rules.minLength != null and rules.maxLength != null and rules.minLength > rules.maxLength\n throw \"UiValidationLengthRangeInvalid\"\n return rules\n\nvalidationMessage(rules, value)\n empty = value == null or value == false\n if is_string(value)\n empty = value.trim() == \"\"\n message = null\n if rules.required == true and empty\n message = \"This field is required.\"\n if !empty\n if rules.minLength != null or rules.maxLength != null or rules.pattern != null\n if !is_string(value)\n message = \"This value must be text.\"\n else\n if rules.minLength != null and value.length < rules.minLength\n message = \"Enter at least ${rules.minLength} characters.\"\n if rules.maxLength != null and value.length > rules.maxLength\n message = \"Enter at most ${rules.maxLength} characters.\"\n if rules.pattern != null\n pattern = new RegExp(\"^(?:${rules.pattern})$\")\n if !pattern.test(value)\n message = \"Enter a value in the required format.\"\n if message != null and rules.message != null\n return rules.message\n return message\n\nsameValue(left, right)\n if is_array(left)\n if !is_array(right) or left.length != right.length\n return false\n for left as index: value\n if !sameValue(value, right[index])\n return false\n return true\n if is_object(left)\n if !is_object(right) or is_array(right)\n return false\n count = 0\n other = 0\n for left as name: value\n count++\n if !(name in right) or !sameValue(value, right[name])\n return false\n for right as name: value\n other++\n return count == other\n return left == right\n\nownedFields(controls)\n result = []\n collectFields(controls, [], result, false)\n return result\n\ncollectFields(controls, parent, result, blocked)\n for controls as control\n if control.element != null and control.element.langoFormRoot == true\n continue\n path = parent.slice()\n unavailable = blocked\n if control.element != null\n unavailable = unavailable or control.element.disabled == true or control.element.hidden == true or control.element.inert == true\n if control.name != null and control.name != \"\"\n path.add(control.name)\n if is_array(control.controls)\n collectFields(control.controls, path, result, unavailable)\n else\n result.add({\n control: control\n path: path\n blocked: unavailable\n })\n\ndirtyFields(controls)\n fields = ownedFields(controls)\n for fields as field\n control = field.control\n if is_kindof(control.isDirty, Function)\n if control.isDirty()\n return true\n return false\n\nvalidateFields(controls)\n issues = []\n fields = ownedFields(controls)\n for fields as field\n if field.blocked\n continue\n control = field.control\n if is_kindof(control.validate, Function)\n message = control.validate()\n if message != null\n issues.add({\n path: field.path\n message: message\n control: field.control\n })\n return issues\n\nvalidatesRequest(controls, name)\n target = requestSource(controls, name)\n return target != null and target.validates == true\n\nconfirmsRequest(controls, name)\n target = requestSource(controls, name)\n return target != null and target.confirms == true\n\nrequestSource(controls, name)\n path = name\n if is_string(path)\n path = [path]\n if !is_array(path) or path.length == 0\n return null\n current = controls\n target = null\n for path as part\n if !is_array(current)\n return null\n target = null\n for current as control\n if control.name == part\n target = control\n break\n if target == null\n return null\n current = target.controls\n return target\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;AASA;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;AAIA;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|