@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/control.mjs
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { applyDimensions } from "./dimensions.mjs";
|
|
2
|
+
import { controlId } from "./templates.mjs";
|
|
3
|
+
import {
|
|
4
|
+
hostGlobal as __hostGlobal,
|
|
5
|
+
add as __add,
|
|
6
|
+
remove as __remove,
|
|
7
|
+
requireBoolean as __requireBoolean,
|
|
8
|
+
normalize as __normalize,
|
|
9
|
+
call as __call,
|
|
10
|
+
boundary as __boundary,
|
|
11
|
+
requireArity as __requireArity,
|
|
12
|
+
} from "./.lango/runtime.mjs";
|
|
13
|
+
|
|
14
|
+
export class Control {
|
|
15
|
+
form;
|
|
16
|
+
element;
|
|
17
|
+
release;
|
|
18
|
+
#value;
|
|
19
|
+
#feedback;
|
|
20
|
+
#target;
|
|
21
|
+
#describedBy;
|
|
22
|
+
#invalid;
|
|
23
|
+
constructor(form, props, element) {
|
|
24
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
25
|
+
form = __boundary(form);
|
|
26
|
+
props = __boundary(props);
|
|
27
|
+
element = __boundary(element);
|
|
28
|
+
this.form = form;
|
|
29
|
+
this.element = element;
|
|
30
|
+
applyDimensions(element, props);
|
|
31
|
+
this.#value = __normalize(props.value);
|
|
32
|
+
this.release = [];
|
|
33
|
+
this.#feedback = null;
|
|
34
|
+
this.validationTarget(element);
|
|
35
|
+
}
|
|
36
|
+
getValue() {
|
|
37
|
+
return null;
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
setValue(value) {
|
|
41
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
42
|
+
value = __boundary(value);
|
|
43
|
+
this.#value = value;
|
|
44
|
+
return this;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
setDisabled(value) {
|
|
48
|
+
__requireArity(arguments.length, [0], "setDisabled");
|
|
49
|
+
value = __boundary(value);
|
|
50
|
+
this.element.disabled = value;
|
|
51
|
+
return this;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
setCaption(value) {
|
|
55
|
+
__requireArity(arguments.length, [0], "setCaption");
|
|
56
|
+
value = __boundary(value);
|
|
57
|
+
this.element.textContent = value;
|
|
58
|
+
return this;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
validationTarget(element) {
|
|
62
|
+
__requireArity(arguments.length, [0], "validationTarget");
|
|
63
|
+
element = __boundary(element);
|
|
64
|
+
this.#target = element;
|
|
65
|
+
this.#describedBy = __normalize(element.getAttribute("aria-describedby"));
|
|
66
|
+
this.#invalid = __normalize(element.getAttribute("aria-invalid"));
|
|
67
|
+
return null;
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
setInvalid(message) {
|
|
71
|
+
__requireArity(arguments.length, [0], "setInvalid");
|
|
72
|
+
message = __boundary(message);
|
|
73
|
+
this.clearValidation();
|
|
74
|
+
this.#feedback = __normalize(__hostGlobal(["document"]).createElement("div"));
|
|
75
|
+
this.#feedback.id = controlId();
|
|
76
|
+
this.#feedback.className = "invalid-feedback d-block";
|
|
77
|
+
this.#feedback.textContent = message;
|
|
78
|
+
__add(this.#target.classList, "is-invalid");
|
|
79
|
+
__normalize(this.#target.setAttribute("aria-invalid", "true"));
|
|
80
|
+
let description = __normalize(this.#feedback.id);
|
|
81
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.#describedBy) !== null) && __requireBoolean(__normalize(this.#describedBy) !== ""))) {
|
|
82
|
+
description = `${__normalize(this.#describedBy)} ${description}`;
|
|
83
|
+
}
|
|
84
|
+
__normalize(this.#target.setAttribute("aria-describedby", description));
|
|
85
|
+
__normalize(this.element.appendChild(__normalize(this.#feedback)));
|
|
86
|
+
return this;
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
clearValidation() {
|
|
90
|
+
if (__requireBoolean(__normalize(this.#feedback) !== null)) {
|
|
91
|
+
__remove(this.#feedback);
|
|
92
|
+
this.#feedback = null;
|
|
93
|
+
__remove(this.#target.classList, "is-invalid");
|
|
94
|
+
if (__requireBoolean(__normalize(this.#invalid) === null)) {
|
|
95
|
+
__normalize(this.#target.removeAttribute("aria-invalid"));
|
|
96
|
+
} else {
|
|
97
|
+
__normalize(this.#target.setAttribute("aria-invalid", __normalize(this.#invalid)));
|
|
98
|
+
}
|
|
99
|
+
if (__requireBoolean(__normalize(this.#describedBy) === null)) {
|
|
100
|
+
__normalize(this.#target.removeAttribute("aria-describedby"));
|
|
101
|
+
} else {
|
|
102
|
+
__normalize(this.#target.setAttribute("aria-describedby", __normalize(this.#describedBy)));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
dispose() {
|
|
109
|
+
this.clearValidation();
|
|
110
|
+
for (const release of __normalize(this.release)) {
|
|
111
|
+
__call(release, );
|
|
112
|
+
}
|
|
113
|
+
this.release = [];
|
|
114
|
+
return null;
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class Value extends Control {
|
|
120
|
+
#value;
|
|
121
|
+
constructor(form, props, element) {
|
|
122
|
+
super(form, props, element);
|
|
123
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
124
|
+
form = __boundary(form);
|
|
125
|
+
props = __boundary(props);
|
|
126
|
+
element = __boundary(element);
|
|
127
|
+
this.#value = __normalize(props.value);
|
|
128
|
+
}
|
|
129
|
+
getValue() {
|
|
130
|
+
return __normalize(this.#value);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
setValue(value) {
|
|
134
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
135
|
+
value = __boundary(value);
|
|
136
|
+
this.#value = value;
|
|
137
|
+
return this;
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=control.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control.mjs","sources":["control.lango"],"sourcesContent":["import \"./dimensions\"\n applyDimensions(element, props)\nimport js global document\nimport \"./templates\"\n controlId()\n\nexport class Control(form, props, element)\n properties\n form\n element\n release\n methods\n getValue()\n setValue(value)\n setDisabled(value)\n setCaption(value)\n validationTarget(element)\n setInvalid(message)\n clearValidation()\n dispose()\n\nControl(form, props, element)\n @form = form\n @element = element\n applyDimensions(element, props)\n @value = props.value\n @release = []\n @feedback = null\n validationTarget(element)\n\nControl:getValue()\n return null\n\nControl:setValue(value)\n @value = value\n return @this\n\nControl:setDisabled(value)\n @element.disabled = value\n return @this\n\nControl:setCaption(value)\n @element.textContent = value\n return @this\n\nControl:validationTarget(element)\n @target = element\n @describedBy = element.getAttribute(\"aria-describedby\")\n @invalid = element.getAttribute(\"aria-invalid\")\n return null\n\nControl:setInvalid(message)\n clearValidation()\n @feedback = document/createElement(\"div\")\n @feedback.id = controlId()\n @feedback.className = \"invalid-feedback d-block\"\n @feedback.textContent = message\n @target.classList.add(\"is-invalid\")\n @target.setAttribute(\"aria-invalid\", \"true\")\n description = @feedback.id\n if @describedBy != null and @describedBy != \"\"\n description = \"${@describedBy} ${description}\"\n @target.setAttribute(\"aria-describedby\", description)\n @element.appendChild(@feedback)\n return @this\n\nControl:clearValidation()\n if @feedback != null\n @feedback.remove()\n @feedback = null\n @target.classList.remove(\"is-invalid\")\n if @invalid == null\n @target.removeAttribute(\"aria-invalid\")\n else\n @target.setAttribute(\"aria-invalid\", @invalid)\n if @describedBy == null\n @target.removeAttribute(\"aria-describedby\")\n else\n @target.setAttribute(\"aria-describedby\", @describedBy)\n return null\n\nControl:dispose()\n clearValidation()\n for @release as release\n release()\n @release = []\n return null\n\nexport class Value(form, props, element) : Control\n methods\n getValue()\n setValue(value)\n\nValue(form, props, element)\n super(form, props, element)\n @value = props.value\n\nValue:getValue()\n return @value\n\nValue:setValue(value)\n @value = value\n return @this\n"],"names":[],"mappings":";;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { Field } from "./fields.mjs";
|
|
2
|
+
import { cloneMarkup } from "./templates.mjs";
|
|
3
|
+
import { InputChanges } from "./input_changes.mjs";
|
|
4
|
+
import * as picker from "flatpickr";
|
|
5
|
+
import {
|
|
6
|
+
hostGlobal as __hostGlobal,
|
|
7
|
+
xmlEscape as __xmlEscape,
|
|
8
|
+
isNumber as __isNumber,
|
|
9
|
+
isString as __isString,
|
|
10
|
+
isBool as __isBool,
|
|
11
|
+
isObject as __isObject,
|
|
12
|
+
isArray as __isArray,
|
|
13
|
+
requireBoolean as __requireBoolean,
|
|
14
|
+
normalize as __normalize,
|
|
15
|
+
finite as __finite,
|
|
16
|
+
numericAdd as __numericAdd,
|
|
17
|
+
call as __call,
|
|
18
|
+
boundary as __boundary,
|
|
19
|
+
requireArity as __requireArity,
|
|
20
|
+
withArity as __withArity,
|
|
21
|
+
} from "./.lango/runtime.mjs";
|
|
22
|
+
|
|
23
|
+
export class DateInput extends Field {
|
|
24
|
+
#changes;
|
|
25
|
+
#locked;
|
|
26
|
+
#min;
|
|
27
|
+
#max;
|
|
28
|
+
#range;
|
|
29
|
+
#picker;
|
|
30
|
+
constructor(form, props) {
|
|
31
|
+
super(form, props, cloneMarkup("date-input", ["<input type=\"text\" class=\"form-control\" />"].join("")));
|
|
32
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
33
|
+
form = __boundary(form);
|
|
34
|
+
props = __boundary(props);
|
|
35
|
+
this.#changes = new InputChanges(form, __normalize(props.url));
|
|
36
|
+
this.#locked = __normalize(props.readonly) === true;
|
|
37
|
+
this.#min = dateText(__normalize(props.min));
|
|
38
|
+
this.#max = dateText(__normalize(props.max));
|
|
39
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.#min) !== null) && __requireBoolean(__normalize(this.#max) !== null)) && __requireBoolean(__normalize(this.#min.localeCompare(__normalize(this.#max))) > 0))) {
|
|
40
|
+
throw "Date min must not exceed max";
|
|
41
|
+
}
|
|
42
|
+
this.#range = dateRange(__normalize(props.value), __normalize(this.#min), __normalize(this.#max));
|
|
43
|
+
let months = __normalize(props.multiMonth);
|
|
44
|
+
if (__requireBoolean(months === null)) {
|
|
45
|
+
months = 1;
|
|
46
|
+
}
|
|
47
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(months))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(months))))) || __requireBoolean(months < 1)) || __requireBoolean(months > 12))) {
|
|
48
|
+
throw "Date multiMonth must be an integer between 1 and 12";
|
|
49
|
+
}
|
|
50
|
+
let first = __normalize(props.firstWeekDay);
|
|
51
|
+
if (__requireBoolean(first === null)) {
|
|
52
|
+
first = 1;
|
|
53
|
+
}
|
|
54
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(first))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(first))))) || __requireBoolean(first < 0)) || __requireBoolean(first > 6))) {
|
|
55
|
+
throw "Date firstWeekDay must be an integer between 0 and 6";
|
|
56
|
+
}
|
|
57
|
+
let format = { };
|
|
58
|
+
if (__requireBoolean(__isString(__normalize(props.format)))) {
|
|
59
|
+
format.display = __normalize(props.format);
|
|
60
|
+
} else {
|
|
61
|
+
if (__requireBoolean(__normalize(props.format) !== null)) {
|
|
62
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(__normalize(props.format)))) || __requireBoolean(__isArray(__normalize(props.format))))) {
|
|
63
|
+
throw "Date format must be a display format or options map";
|
|
64
|
+
}
|
|
65
|
+
format = __normalize(__hostGlobal(["Object"]).assign({ }, __normalize(props.format)));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let display = __normalize(format.display);
|
|
69
|
+
if (__requireBoolean(display === null)) {
|
|
70
|
+
display = "Y-m-d";
|
|
71
|
+
}
|
|
72
|
+
let locale = calendarLocale(format);
|
|
73
|
+
locale.firstDayOfWeek = first;
|
|
74
|
+
if (__requireBoolean(__normalize(props.label) !== null)) {
|
|
75
|
+
locale.monthAriaLabel = __normalize(props.label);
|
|
76
|
+
locale.yearAriaLabel = __normalize(props.label);
|
|
77
|
+
}
|
|
78
|
+
if (__requireBoolean(__normalize(format.calendar) !== null)) {
|
|
79
|
+
locale = __normalize(__hostGlobal(["Object"]).assign(locale, __normalize(format.calendar)));
|
|
80
|
+
}
|
|
81
|
+
let createPicker = __normalize(picker.default);
|
|
82
|
+
let change = __withArity((dates) => {
|
|
83
|
+
dates = __boundary(dates);
|
|
84
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
85
|
+
this.setValue(__normalize(this.#range));
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
let start = null;
|
|
89
|
+
let end = null;
|
|
90
|
+
if (__requireBoolean(__normalize(dates.length) > 0)) {
|
|
91
|
+
start = __normalize(this.#picker.formatDate(__normalize(dates[0]), "Y-m-d"));
|
|
92
|
+
}
|
|
93
|
+
if (__requireBoolean(__normalize(dates.length) > 1)) {
|
|
94
|
+
end = __normalize(this.#picker.formatDate(__normalize(dates[1]), "Y-m-d"));
|
|
95
|
+
}
|
|
96
|
+
this.#range = dateRange({ start: start, end: end }, __normalize(this.#min), __normalize(this.#max));
|
|
97
|
+
__normalize(this.#changes.changed());
|
|
98
|
+
return null;
|
|
99
|
+
}, [0], "closure");
|
|
100
|
+
let options = { mode: "range", dateFormat: display, showMonths: months, locale: locale, inline: __normalize(props.inline) === true, appendTo: __normalize(this.element), disableMobile: true, allowInput: false, onChange: change };
|
|
101
|
+
if (__requireBoolean(__normalize(this.#min) !== null)) {
|
|
102
|
+
options.minDate = __normalize(createPicker.parseDate(__normalize(this.#min), "Y-m-d"));
|
|
103
|
+
}
|
|
104
|
+
if (__requireBoolean(__normalize(this.#max) !== null)) {
|
|
105
|
+
options.maxDate = __normalize(createPicker.parseDate(__normalize(this.#max), "Y-m-d"));
|
|
106
|
+
}
|
|
107
|
+
this.#picker = __call(createPicker, __normalize(this.input), options);
|
|
108
|
+
if (__requireBoolean(__normalize(props.button) === true)) {
|
|
109
|
+
this.input.className = "btn btn-outline-secondary";
|
|
110
|
+
}
|
|
111
|
+
this.setValue(__normalize(this.#range));
|
|
112
|
+
this.setDisabled(__normalize(props.disabled) === true);
|
|
113
|
+
}
|
|
114
|
+
getValue() {
|
|
115
|
+
return { start: __normalize(this.#range.start), end: __normalize(this.#range.end) };
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
setValue(value) {
|
|
119
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
120
|
+
value = __boundary(value);
|
|
121
|
+
let range = dateRange(value, __normalize(this.#min), __normalize(this.#max));
|
|
122
|
+
let dates = [];
|
|
123
|
+
if (__requireBoolean(__normalize(range.start) !== null)) {
|
|
124
|
+
dates.push(__normalize(range.start));
|
|
125
|
+
}
|
|
126
|
+
if (__requireBoolean(__normalize(range.end) !== null)) {
|
|
127
|
+
dates.push(__normalize(range.end));
|
|
128
|
+
}
|
|
129
|
+
__normalize(this.#picker.setDate(dates, false, "Y-m-d"));
|
|
130
|
+
this.#range = range;
|
|
131
|
+
return this;
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
setDisabled(value) {
|
|
135
|
+
__requireArity(arguments.length, [0], "setDisabled");
|
|
136
|
+
value = __boundary(value);
|
|
137
|
+
this.input.disabled = __requireBoolean(value) || __requireBoolean(__normalize(this.#locked) === true);
|
|
138
|
+
if (__requireBoolean(__normalize(this.#picker) !== null)) {
|
|
139
|
+
let calendar = __normalize(this.#picker.calendarContainer);
|
|
140
|
+
calendar.inert = __normalize(this.input.disabled);
|
|
141
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
142
|
+
__normalize(this.#picker.close());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return this;
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
dispose() {
|
|
149
|
+
__normalize(this.#changes.dispose());
|
|
150
|
+
__normalize(this.#picker.destroy());
|
|
151
|
+
super.dispose();
|
|
152
|
+
return null;
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function dateText(value) {
|
|
157
|
+
__requireArity(arguments.length, [0], "dateText");
|
|
158
|
+
value = __boundary(value);
|
|
159
|
+
if (__requireBoolean(__requireBoolean(value === null) || __requireBoolean(value === ""))) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
let pattern = new (__hostGlobal(["RegExp"]))("^[0-9]{4}-[0-9]{2}-[0-9]{2}$");
|
|
163
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(value))) || __requireBoolean(!__requireBoolean(__normalize(pattern.test(value)))))) {
|
|
164
|
+
throw "Date requires YYYY-MM-DD calendar text";
|
|
165
|
+
}
|
|
166
|
+
let year = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(0, 4)), 10));
|
|
167
|
+
let month = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(5, 7)), 10));
|
|
168
|
+
let day = __normalize(__hostGlobal(["Number"]).parseInt(__normalize(value.slice(8, 10)), 10));
|
|
169
|
+
let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
170
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(year < 1) || __requireBoolean(month < 1)) || __requireBoolean(month > 12))) {
|
|
171
|
+
throw "Invalid calendar date";
|
|
172
|
+
}
|
|
173
|
+
if (__requireBoolean(__requireBoolean(__finite(year % 4) === 0) && __requireBoolean(__requireBoolean(__finite(year % 100) !== 0) || __requireBoolean(__finite(year % 400) === 0)))) {
|
|
174
|
+
days[1] = 29;
|
|
175
|
+
}
|
|
176
|
+
let index = __finite(month - 1);
|
|
177
|
+
if (__requireBoolean(__requireBoolean(day < 1) || __requireBoolean(day > __normalize(days[index])))) {
|
|
178
|
+
throw "Invalid calendar date";
|
|
179
|
+
}
|
|
180
|
+
return value;
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function dateRange(value, min = null, max = null) {
|
|
185
|
+
__requireArity(arguments.length, [0], "dateRange");
|
|
186
|
+
value = __boundary(value);
|
|
187
|
+
min = __boundary(min);
|
|
188
|
+
max = __boundary(max);
|
|
189
|
+
if (__requireBoolean(value === null)) {
|
|
190
|
+
value = { };
|
|
191
|
+
}
|
|
192
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(value))) || __requireBoolean(__isArray(value)))) {
|
|
193
|
+
throw "Date value requires a start/end map";
|
|
194
|
+
}
|
|
195
|
+
let start = dateText(__normalize(value.start));
|
|
196
|
+
let end = dateText(__normalize(value.end));
|
|
197
|
+
if (__requireBoolean(__requireBoolean(end !== null) && __requireBoolean(__requireBoolean(start === null) || __requireBoolean(__normalize(end.localeCompare(start)) < 0)))) {
|
|
198
|
+
throw "Date range end must not precede its start";
|
|
199
|
+
}
|
|
200
|
+
for (const date of [start, end]) {
|
|
201
|
+
if (__requireBoolean(__requireBoolean(date !== null) && __requireBoolean(__requireBoolean(__requireBoolean(min !== null) && __requireBoolean(__normalize(date.localeCompare(min)) < 0)) || __requireBoolean(__requireBoolean(max !== null) && __requireBoolean(__normalize(date.localeCompare(max)) > 0))))) {
|
|
202
|
+
throw "Date is outside its min/max range";
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { start: start, end: end };
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function calendarLocale(options) {
|
|
210
|
+
__requireArity(arguments.length, [0], "calendarLocale");
|
|
211
|
+
options = __boundary(options);
|
|
212
|
+
let locale = __normalize(options.locale);
|
|
213
|
+
if (__requireBoolean(locale === null)) {
|
|
214
|
+
locale = [];
|
|
215
|
+
}
|
|
216
|
+
let months = [];
|
|
217
|
+
let shortMonths = [];
|
|
218
|
+
let weekdays = [];
|
|
219
|
+
let shortWeekdays = [];
|
|
220
|
+
let month = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { month: "long", timeZone: "UTC" });
|
|
221
|
+
let shortMonth = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { month: "short", timeZone: "UTC" });
|
|
222
|
+
let day = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { weekday: "long", timeZone: "UTC" });
|
|
223
|
+
let shortDay = new (__hostGlobal(["Intl"]).DateTimeFormat)(locale, { weekday: "short", timeZone: "UTC" });
|
|
224
|
+
let index = 0;
|
|
225
|
+
let stamp = null;
|
|
226
|
+
__loop1: while (__requireBoolean(index < 12)) {
|
|
227
|
+
stamp = __normalize(__hostGlobal(["Date"]).UTC(2020, index, 1));
|
|
228
|
+
months.push(__normalize(month.format(stamp)));
|
|
229
|
+
shortMonths.push(__normalize(shortMonth.format(stamp)));
|
|
230
|
+
index = __numericAdd(index, 1);
|
|
231
|
+
}
|
|
232
|
+
index = 1;
|
|
233
|
+
__loop2: while (__requireBoolean(index <= 7)) {
|
|
234
|
+
stamp = __normalize(__hostGlobal(["Date"]).UTC(2020, 10, index));
|
|
235
|
+
weekdays.push(__normalize(day.format(stamp)));
|
|
236
|
+
shortWeekdays.push(__normalize(shortDay.format(stamp)));
|
|
237
|
+
index = __numericAdd(index, 1);
|
|
238
|
+
}
|
|
239
|
+
return { weekdays: { longhand: weekdays, shorthand: shortWeekdays }, months: { longhand: months, shorthand: shortMonths }, rangeSeparator: " – ", monthAriaLabel: "", yearAriaLabel: "" };
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=date_input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date_input.mjs","sources":["date_input.lango"],"sourcesContent":["import js \"flatpickr\" as picker\nimport js global Intl\nimport js global Date\nimport js global Number\nimport js global RegExp\nimport js global Object\nimport \"./fields\"\n class Field\nimport \"./templates\"\n cloneMarkup(name, xml)\nimport \"./input_changes\"\n class InputChanges\n\nexport dateText(value)\nexport dateRange(value, min = null, max = null)\n\ndateText(value)\n if value == null or value == \"\"\n return null\n pattern = new RegExp(\"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\")\n if !is_string(value) or !pattern.test(value)\n throw \"Date requires YYYY-MM-DD calendar text\"\n year = Number/parseInt(value.slice(0, 4), 10)\n month = Number/parseInt(value.slice(5, 7), 10)\n day = Number/parseInt(value.slice(8, 10), 10)\n days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n if year < 1 or month < 1 or month > 12\n throw \"Invalid calendar date\"\n if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)\n days[1] = 29\n index = month - 1\n if day < 1 or day > days[index]\n throw \"Invalid calendar date\"\n return value\n\ndateRange(value, min = null, max = null)\n if value == null\n value = {}\n if !is_object(value) or is_array(value)\n throw \"Date value requires a start/end map\"\n start = dateText(value.start)\n end = dateText(value.end)\n if end != null and (start == null or end.localeCompare(start) < 0)\n throw \"Date range end must not precede its start\"\n for [start, end] as date\n if date != null and ((min != null and date.localeCompare(min) < 0) or (max != null and date.localeCompare(max) > 0))\n throw \"Date is outside its min/max range\"\n return {\n start: start\n end: end\n }\n\ncalendarLocale(options)\n locale = options.locale\n if locale == null\n locale = []\n months = []\n shortMonths = []\n weekdays = []\n shortWeekdays = []\n month = new Intl/DateTimeFormat(locale, {\n month: \"long\"\n timeZone: \"UTC\"\n })\n shortMonth = new Intl/DateTimeFormat(locale, {\n month: \"short\"\n timeZone: \"UTC\"\n })\n day = new Intl/DateTimeFormat(locale, {\n weekday: \"long\"\n timeZone: \"UTC\"\n })\n shortDay = new Intl/DateTimeFormat(locale, {\n weekday: \"short\"\n timeZone: \"UTC\"\n })\n index = 0\n stamp = null\n loop while index < 12\n stamp = Date/UTC(2020, index, 1)\n months.add(month.format(stamp))\n shortMonths.add(shortMonth.format(stamp))\n index = index + 1\n index = 1\n loop while index <= 7\n stamp = Date/UTC(2020, 10, index)\n weekdays.add(day.format(stamp))\n shortWeekdays.add(shortDay.format(stamp))\n index = index + 1\n return {\n weekdays: {\n longhand: weekdays\n shorthand: shortWeekdays\n }\n months: {\n longhand: months\n shorthand: shortMonths\n }\n rangeSeparator: \" – \"\n monthAriaLabel: \"\"\n yearAriaLabel: \"\"\n }\n\nexport class DateInput(form, props) : Field\n methods\n getValue()\n setValue(value)\n setDisabled(value)\n dispose()\n\nDateInput(form, props)\n super(form, props, cloneMarkup(\"date-input\", <input type=\"text\" class=\"form-control\" />))\n @changes = new InputChanges(form, props.url)\n @locked = props.readonly == true\n @min = dateText(props.min)\n @max = dateText(props.max)\n if @min != null and @max != null and @min.localeCompare(@max) > 0\n throw \"Date min must not exceed max\"\n @range = dateRange(props.value, @min, @max)\n months = props.multiMonth\n if months == null\n months = 1\n if !is_number(months) or !Number/isInteger(months) or months < 1 or months > 12\n throw \"Date multiMonth must be an integer between 1 and 12\"\n first = props.firstWeekDay\n if first == null\n first = 1\n if !is_number(first) or !Number/isInteger(first) or first < 0 or first > 6\n throw \"Date firstWeekDay must be an integer between 0 and 6\"\n format = {}\n if is_string(props.format)\n format.display = props.format\n else\n if props.format != null\n if !is_object(props.format) or is_array(props.format)\n throw \"Date format must be a display format or options map\"\n format = Object/assign({}, props.format)\n display = format.display\n if display == null\n display = \"Y-m-d\"\n locale = calendarLocale(format)\n locale.firstDayOfWeek = first\n if props.label != null\n locale.monthAriaLabel = props.label\n locale.yearAriaLabel = props.label\n if format.calendar != null\n locale = Object/assign(locale, format.calendar)\n createPicker = picker.default\n change = (dates)\n if @input.disabled\n setValue(@range)\n return null\n start = null\n end = null\n if dates.length > 0\n start = @picker.formatDate(dates[0], \"Y-m-d\")\n if dates.length > 1\n end = @picker.formatDate(dates[1], \"Y-m-d\")\n @range = dateRange({\n start: start\n end: end\n }, @min, @max)\n @changes.changed()\n options = {\n mode: \"range\"\n dateFormat: display\n showMonths: months\n locale: locale\n inline: props.inline == true\n appendTo: @element\n disableMobile: true\n allowInput: false\n onChange: change\n }\n if @min != null\n options.minDate = createPicker.parseDate(@min, \"Y-m-d\")\n if @max != null\n options.maxDate = createPicker.parseDate(@max, \"Y-m-d\")\n @picker = createPicker(@input, options)\n if props.button == true\n @input.className = \"btn btn-outline-secondary\"\n setValue(@range)\n setDisabled(props.disabled == true)\n\nDateInput:getValue()\n return {\n start: @range.start\n end: @range.end\n }\n\nDateInput:setValue(value)\n range = dateRange(value, @min, @max)\n dates = []\n if range.start != null\n dates.add(range.start)\n if range.end != null\n dates.add(range.end)\n @picker.setDate(dates, false, \"Y-m-d\")\n @range = range\n return @this\n\nDateInput:setDisabled(value)\n @input.disabled = value or @locked == true\n if @picker != null\n calendar = @picker.calendarContainer\n calendar.inert = @input.disabled\n if @input.disabled\n @picker.close()\n return @this\n\nDateInput:dispose()\n @changes.dispose()\n @picker.destroy()\n super.dispose()\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hostGlobal as __hostGlobal,
|
|
3
|
+
isNumber as __isNumber,
|
|
4
|
+
isString as __isString,
|
|
5
|
+
isBool as __isBool,
|
|
6
|
+
isObject as __isObject,
|
|
7
|
+
isArray as __isArray,
|
|
8
|
+
add as __add,
|
|
9
|
+
requireBoolean as __requireBoolean,
|
|
10
|
+
normalize as __normalize,
|
|
11
|
+
finite as __finite,
|
|
12
|
+
boundary as __boundary,
|
|
13
|
+
requireArity as __requireArity,
|
|
14
|
+
} from "./.lango/runtime.mjs";
|
|
15
|
+
|
|
16
|
+
export function measure(value, unit) {
|
|
17
|
+
__requireArity(arguments.length, [0, 1], "measure");
|
|
18
|
+
value = __boundary(value);
|
|
19
|
+
unit = __boundary(unit);
|
|
20
|
+
if (__requireBoolean(__requireBoolean(value === null) || __requireBoolean(value === __finite(-1)))) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(value))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isFinite(value))))) || __requireBoolean(value <= 0))) {
|
|
24
|
+
throw "Control dimensions must be positive numbers or -1 for automatic sizing";
|
|
25
|
+
}
|
|
26
|
+
return `${value}${unit}`;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function applyDimensions(element, props) {
|
|
31
|
+
__requireArity(arguments.length, [0, 1], "applyDimensions");
|
|
32
|
+
element = __boundary(element);
|
|
33
|
+
props = __boundary(props);
|
|
34
|
+
let width = measure(__normalize(props.width), "ch");
|
|
35
|
+
let height = measure(__normalize(props.height), "lh");
|
|
36
|
+
if (__requireBoolean(width !== null)) {
|
|
37
|
+
element.style.width = width;
|
|
38
|
+
element.style.maxWidth = "100%";
|
|
39
|
+
element.style.boxSizing = "border-box";
|
|
40
|
+
}
|
|
41
|
+
if (__requireBoolean(height !== null)) {
|
|
42
|
+
element.style.height = height;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function applyLayout(element, props) {
|
|
49
|
+
__requireArity(arguments.length, [0, 1], "applyLayout");
|
|
50
|
+
element = __boundary(element);
|
|
51
|
+
props = __boundary(props);
|
|
52
|
+
if (__normalize(props.type) === "container") {
|
|
53
|
+
let fluid = __normalize(props.fluid);
|
|
54
|
+
if (__requireBoolean(fluid === null)) {
|
|
55
|
+
fluid = false;
|
|
56
|
+
}
|
|
57
|
+
if (__requireBoolean(!__requireBoolean(__isBool(fluid)))) {
|
|
58
|
+
throw "Container fluid must be boolean";
|
|
59
|
+
}
|
|
60
|
+
if (__requireBoolean(fluid)) {
|
|
61
|
+
__add(element.classList, "container-fluid");
|
|
62
|
+
} else {
|
|
63
|
+
__add(element.classList, "container");
|
|
64
|
+
}
|
|
65
|
+
} else if (__normalize(props.type) === "row") {
|
|
66
|
+
__add(element.classList, "lango-row");
|
|
67
|
+
let gap = __normalize(props.gap);
|
|
68
|
+
if (__requireBoolean(gap === null)) {
|
|
69
|
+
gap = "normal";
|
|
70
|
+
}
|
|
71
|
+
if (gap === "small") {
|
|
72
|
+
__normalize(element.style.setProperty("--lango-gap", ".5rem"));
|
|
73
|
+
} else if (gap === "normal") {
|
|
74
|
+
__normalize(element.style.setProperty("--lango-gap", "1rem"));
|
|
75
|
+
} else if (gap === "large") {
|
|
76
|
+
__normalize(element.style.setProperty("--lango-gap", "1.5rem"));
|
|
77
|
+
} else {
|
|
78
|
+
throw "Row gap must be small, normal or large";
|
|
79
|
+
}
|
|
80
|
+
} else if (__normalize(props.type) === "col") {
|
|
81
|
+
__add(element.classList, "lango-col");
|
|
82
|
+
let basis = measure(__normalize(props.width), "ch");
|
|
83
|
+
let grow = __normalize(props.grow);
|
|
84
|
+
if (__requireBoolean(grow === null)) {
|
|
85
|
+
grow = basis === null;
|
|
86
|
+
}
|
|
87
|
+
if (__requireBoolean(!__requireBoolean(__isBool(grow)))) {
|
|
88
|
+
throw "Col grow must be boolean";
|
|
89
|
+
}
|
|
90
|
+
if (__requireBoolean(basis !== null)) {
|
|
91
|
+
__normalize(element.style.setProperty("--lango-basis", basis));
|
|
92
|
+
}
|
|
93
|
+
if (__requireBoolean(grow)) {
|
|
94
|
+
__normalize(element.style.setProperty("--lango-grow", "1"));
|
|
95
|
+
} else {
|
|
96
|
+
__normalize(element.style.setProperty("--lango-grow", "0"));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=dimensions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions.mjs","sources":["dimensions.lango"],"sourcesContent":["import js global Number\n\nexport measure(value, unit)\nexport applyDimensions(element, props)\nexport applyLayout(element, props)\n\nmeasure(value, unit)\n if value == null or value == -1\n return null\n if !is_number(value) or !Number/isFinite(value) or value <= 0\n throw \"Control dimensions must be positive numbers or -1 for automatic sizing\"\n return \"${value}${unit}\"\n\napplyDimensions(element, props)\n width = measure(props.width, \"ch\")\n height = measure(props.height, \"lh\")\n if width != null\n element.style.width = width\n element.style.maxWidth = \"100%\"\n element.style.boxSizing = \"border-box\"\n if height != null\n element.style.height = height\n return null\n\napplyLayout(element, props)\n switch props.type\n case \"container\"\n fluid = props.fluid\n if fluid == null\n fluid = false\n if !is_bool(fluid)\n throw \"Container fluid must be boolean\"\n if fluid\n element.classList.add(\"container-fluid\")\n else\n element.classList.add(\"container\")\n case \"row\"\n element.classList.add(\"lango-row\")\n gap = props.gap\n if gap == null\n gap = \"normal\"\n switch gap\n case \"small\"\n element.style.setProperty(\"--lango-gap\", \".5rem\")\n case \"normal\"\n element.style.setProperty(\"--lango-gap\", \"1rem\")\n case \"large\"\n element.style.setProperty(\"--lango-gap\", \"1.5rem\")\n else\n throw \"Row gap must be small, normal or large\"\n case \"col\"\n element.classList.add(\"lango-col\")\n basis = measure(props.width, \"ch\")\n grow = props.grow\n if grow == null\n grow = basis == null\n if !is_bool(grow)\n throw \"Col grow must be boolean\"\n if basis != null\n element.style.setProperty(\"--lango-basis\", basis)\n if grow\n element.style.setProperty(\"--lango-grow\", \"1\")\n else\n element.style.setProperty(\"--lango-grow\", \"0\")\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hostGlobal as __hostGlobal,
|
|
3
|
+
isNumber as __isNumber,
|
|
4
|
+
isString as __isString,
|
|
5
|
+
isBool as __isBool,
|
|
6
|
+
isObject as __isObject,
|
|
7
|
+
isArray as __isArray,
|
|
8
|
+
add as __add,
|
|
9
|
+
requireBoolean as __requireBoolean,
|
|
10
|
+
normalize as __normalize,
|
|
11
|
+
finite as __finite,
|
|
12
|
+
numericAdd as __numericAdd,
|
|
13
|
+
boundary as __boundary,
|
|
14
|
+
requireArity as __requireArity,
|
|
15
|
+
withArity as __withArity,
|
|
16
|
+
} from "./.lango/runtime.mjs";
|
|
17
|
+
|
|
18
|
+
export class ErrorReporter {
|
|
19
|
+
active;
|
|
20
|
+
#app;
|
|
21
|
+
#url;
|
|
22
|
+
#pending;
|
|
23
|
+
#timer;
|
|
24
|
+
#flight;
|
|
25
|
+
#window;
|
|
26
|
+
#sent;
|
|
27
|
+
constructor(app, url) {
|
|
28
|
+
__requireArity(arguments.length, [0, 1], "constructor");
|
|
29
|
+
app = __boundary(app);
|
|
30
|
+
url = __boundary(url);
|
|
31
|
+
__normalize(app.checkUrl(url));
|
|
32
|
+
this.#app = app;
|
|
33
|
+
this.#url = url;
|
|
34
|
+
this.active = true;
|
|
35
|
+
this.#pending = [];
|
|
36
|
+
this.#timer = null;
|
|
37
|
+
this.#flight = false;
|
|
38
|
+
this.#window = __normalize(app.now());
|
|
39
|
+
this.#sent = 0;
|
|
40
|
+
}
|
|
41
|
+
capture(source, code, name, form) {
|
|
42
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "capture");
|
|
43
|
+
source = __boundary(source);
|
|
44
|
+
code = __boundary(code);
|
|
45
|
+
name = __boundary(name);
|
|
46
|
+
form = __boundary(form);
|
|
47
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(this.active))) || __requireBoolean(form === null)) || __requireBoolean(__normalize(form.disposed)))) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (__requireBoolean(__finite(__normalize(this.#app.now()) - __normalize(this.#window)) >= 60000)) {
|
|
51
|
+
this.#window = __normalize(this.#app.now());
|
|
52
|
+
this.#sent = 0;
|
|
53
|
+
}
|
|
54
|
+
if (__requireBoolean(__normalize(this.#sent) >= 10)) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let sources = ["ui", "window", "promise"];
|
|
58
|
+
let valid = new (__hostGlobal(["RegExp"]))("^[A-Za-z][A-Za-z0-9_]{0,63}$");
|
|
59
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(sources.includes(source)))) || __requireBoolean(!__requireBoolean(__isString(code)))) || __requireBoolean(!__requireBoolean(__normalize(valid.test(code)))))) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(name))) || __requireBoolean(__normalize(name.trim()) === "")) || __requireBoolean(__normalize(name.length) > 256))) {
|
|
63
|
+
name = null;
|
|
64
|
+
}
|
|
65
|
+
for (const entry of __normalize(this.#pending)) {
|
|
66
|
+
let previous = __normalize(entry.report);
|
|
67
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(entry.form) === form) && __requireBoolean(__normalize(previous.source) === source)) && __requireBoolean(__normalize(previous.code) === code)) && __requireBoolean(__normalize(previous.name) === name))) {
|
|
68
|
+
previous.count = __normalize(__hostGlobal(["Math"]).min(100, __numericAdd(__normalize(previous.count), 1)));
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (__requireBoolean(__normalize(this.#pending.length) >= 20)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
let report = { source: source, code: code, count: 1 };
|
|
76
|
+
if (__requireBoolean(name !== null)) {
|
|
77
|
+
report.name = name;
|
|
78
|
+
}
|
|
79
|
+
__add(this.#pending, { form: form, report: report });
|
|
80
|
+
this.schedule();
|
|
81
|
+
return null;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
schedule() {
|
|
85
|
+
if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(__normalize(this.active)) && __requireBoolean(!__requireBoolean(__normalize(this.#flight)))) && __requireBoolean(__normalize(this.#timer) === null)) && __requireBoolean(__normalize(this.#pending.length) > 0))) {
|
|
86
|
+
let action = () => {
|
|
87
|
+
this.#timer = null;
|
|
88
|
+
this.flush();
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
this.#timer = __normalize(this.#app.schedule(action, 0));
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
flush() {
|
|
97
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(this.active))) || __requireBoolean(__normalize(this.#flight)))) {
|
|
98
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
99
|
+
}
|
|
100
|
+
if (__requireBoolean(__normalize(this.#sent) >= 10)) {
|
|
101
|
+
this.#pending = [];
|
|
102
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
103
|
+
}
|
|
104
|
+
let entry = __normalize(this.#pending.shift());
|
|
105
|
+
if (__requireBoolean(entry === null)) {
|
|
106
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
107
|
+
}
|
|
108
|
+
if (__requireBoolean(entry.form.disposed)) {
|
|
109
|
+
this.schedule();
|
|
110
|
+
return __normalize(__hostGlobal(["Promise"]).resolve(null));
|
|
111
|
+
}
|
|
112
|
+
this.#sent = __numericAdd(__normalize(this.#sent), 1);
|
|
113
|
+
this.#flight = true;
|
|
114
|
+
return __normalize(this.#app.report(__normalize(entry.form), __normalize(this.#url), __normalize(entry.report), this)).catch(__withArity((error) => {
|
|
115
|
+
error = __boundary(error);
|
|
116
|
+
return null;
|
|
117
|
+
return null;
|
|
118
|
+
}, [0], "closure")).finally(() => {
|
|
119
|
+
this.#flight = false;
|
|
120
|
+
this.schedule();
|
|
121
|
+
return null;
|
|
122
|
+
});
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
dispose() {
|
|
126
|
+
this.active = false;
|
|
127
|
+
this.#pending = [];
|
|
128
|
+
if (__requireBoolean(__normalize(this.#timer) !== null)) {
|
|
129
|
+
__normalize(this.#app.cancelTimer(__normalize(this.#timer)));
|
|
130
|
+
this.#timer = null;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=error_reporter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error_reporter.mjs","sources":["error_reporter.lango"],"sourcesContent":["import js global Promise\nimport js global Math\nimport js global RegExp\n\nexport class ErrorReporter(app, url)\n properties\n active\n methods\n capture(source, code, name, form)\n schedule()\n flush()\n dispose()\n\nErrorReporter(app, url)\n app.checkUrl(url)\n @app = app\n @url = url\n @active = true\n @pending = []\n @timer = null\n @flight = false\n @window = app.now()\n @sent = 0\n\nErrorReporter:capture(source, code, name, form)\n if !@active or form == null or form.disposed\n return null\n if @app.now() - @window >= 60000\n @window = @app.now()\n @sent = 0\n if @sent >= 10\n return null\n sources = [\"ui\", \"window\", \"promise\"]\n valid = new RegExp(\"^[A-Za-z][A-Za-z0-9_]{0,63}$\")\n if !sources.includes(source) or !is_string(code) or !valid.test(code)\n return null\n if !is_string(name) or name.trim() == \"\" or name.length > 256\n name = null\n for @pending as entry\n previous = entry.report\n if entry.form == form and previous.source == source and previous.code == code and previous.name == name\n previous.count = Math/min(100, previous.count + 1)\n return null\n if @pending.length >= 20\n return null\n report = {\n source: source\n code: code\n count: 1\n }\n if name != null\n report.name = name\n @pending.add({\n form: form\n report: report\n })\n schedule()\n return null\n\nErrorReporter:schedule()\n if @active and !@flight and @timer == null and @pending.length > 0\n action = ()\n @timer = null\n flush()\n @timer = @app.schedule(action, 0)\n return null\n\nErrorReporter:flush()\n if !@active or @flight\n return Promise/resolve(null)\n if @sent >= 10\n @pending = []\n return Promise/resolve(null)\n entry = @pending.shift()\n if entry == null\n return Promise/resolve(null)\n if entry.form.disposed\n schedule()\n return Promise/resolve(null)\n @sent = @sent + 1\n @flight = true\n return chain @app.report(entry.form, @url, entry.report, @this)\n catch(error)\n return null\n finally\n @flight = false\n schedule()\n\nErrorReporter:dispose()\n @active = false\n @pending = []\n if @timer != null\n @app.cancelTimer(@timer)\n @timer = null\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|