@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
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { Field, sameValue } from "./fields.mjs";
|
|
2
|
+
import { cloneMarkup, controlId } from "./templates.mjs";
|
|
3
|
+
import { RichContent } from "./rich_content.mjs";
|
|
4
|
+
import {
|
|
5
|
+
hostGlobal as __hostGlobal,
|
|
6
|
+
xmlEscape as __xmlEscape,
|
|
7
|
+
isNumber as __isNumber,
|
|
8
|
+
isString as __isString,
|
|
9
|
+
isBool as __isBool,
|
|
10
|
+
isObject as __isObject,
|
|
11
|
+
isArray as __isArray,
|
|
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
|
+
withArity as __withArity,
|
|
20
|
+
} from "./.lango/runtime.mjs";
|
|
21
|
+
|
|
22
|
+
export class ComboBox extends Field {
|
|
23
|
+
#locked;
|
|
24
|
+
#multi;
|
|
25
|
+
#options;
|
|
26
|
+
#selected;
|
|
27
|
+
#elements;
|
|
28
|
+
#slots;
|
|
29
|
+
#cursor;
|
|
30
|
+
#panel;
|
|
31
|
+
constructor(form, props, renderer) {
|
|
32
|
+
super(form, props, cloneMarkup("combo-button", ["<button type=\"button\" class=\"form-select text-start\" role=\"combobox\" aria-haspopup=\"listbox\" aria-expanded=\"false\"></button>"].join("")));
|
|
33
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
34
|
+
form = __boundary(form);
|
|
35
|
+
props = __boundary(props);
|
|
36
|
+
renderer = __boundary(renderer);
|
|
37
|
+
this.#locked = __normalize(props.readonly) === true;
|
|
38
|
+
this.#multi = __normalize(props.multi) === true;
|
|
39
|
+
this.#options = __normalize(props.options);
|
|
40
|
+
if (__requireBoolean(__normalize(this.#options) === null)) {
|
|
41
|
+
this.#options = [];
|
|
42
|
+
}
|
|
43
|
+
this.#selected = [];
|
|
44
|
+
this.#elements = [];
|
|
45
|
+
this.#slots = [];
|
|
46
|
+
this.#cursor = __finite(-1);
|
|
47
|
+
__add(this.element.classList, "lango-combo");
|
|
48
|
+
this.#panel = cloneMarkup("combo-panel", ["<div class=\"lango-combo-panel\" hidden=\"hidden\"><ul class=\"list-group\" role=\"listbox\"></ul></div>"].join(""));
|
|
49
|
+
let list = __normalize(this.#panel.firstElementChild);
|
|
50
|
+
list.id = controlId();
|
|
51
|
+
if (__requireBoolean(__requireBoolean(__normalize(props.aria) !== null) && __requireBoolean(props.aria.label !== null))) {
|
|
52
|
+
__normalize(list.setAttribute("aria-label", props.aria.label));
|
|
53
|
+
} else {
|
|
54
|
+
if (__requireBoolean(__normalize(props.label) !== null)) {
|
|
55
|
+
__normalize(list.setAttribute("aria-label", __normalize(props.label)));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (__requireBoolean(__normalize(this.#multi))) {
|
|
59
|
+
__normalize(list.setAttribute("aria-multiselectable", "true"));
|
|
60
|
+
}
|
|
61
|
+
__normalize(this.input.setAttribute("aria-controls", __normalize(list.id)));
|
|
62
|
+
__normalize(this.element.insertBefore(__normalize(this.#panel), __normalize(this.input.nextSibling)));
|
|
63
|
+
let group = list;
|
|
64
|
+
let index = 0;
|
|
65
|
+
for (const option of __normalize(this.#options)) {
|
|
66
|
+
if (__requireBoolean(!__requireBoolean(__isObject(option)))) {
|
|
67
|
+
throw "ComboBox options require value/control maps";
|
|
68
|
+
}
|
|
69
|
+
if (__requireBoolean(__normalize(option.url) !== null)) {
|
|
70
|
+
if (__requireBoolean(__normalize(option.value) === null)) {
|
|
71
|
+
throw "ComboBox group cannot have a URL";
|
|
72
|
+
}
|
|
73
|
+
__normalize(form.app.checkUrl(__normalize(option.url)));
|
|
74
|
+
}
|
|
75
|
+
let item = __normalize(__hostGlobal(["document"]).createElement("li"));
|
|
76
|
+
let slot = null;
|
|
77
|
+
if (__requireBoolean(__normalize(option.value) === null)) {
|
|
78
|
+
__normalize(item.setAttribute("role", "presentation"));
|
|
79
|
+
let heading = __normalize(__hostGlobal(["document"]).createElement("div"));
|
|
80
|
+
heading.id = controlId();
|
|
81
|
+
heading.className = "lango-combo-heading";
|
|
82
|
+
slot = new RichContent(form, heading, renderer, false, "ComboBox group");
|
|
83
|
+
__normalize(slot.replace(__normalize(option.control)));
|
|
84
|
+
this.#slots.push(slot);
|
|
85
|
+
__normalize(item.appendChild(heading));
|
|
86
|
+
group = cloneMarkup("combo-group", ["<ul class=\"list-group\" role=\"group\"></ul>"].join(""));
|
|
87
|
+
__normalize(group.setAttribute("aria-labelledby", __normalize(heading.id)));
|
|
88
|
+
__normalize(item.appendChild(group));
|
|
89
|
+
__normalize(list.appendChild(item));
|
|
90
|
+
this.#elements.push(null);
|
|
91
|
+
} else {
|
|
92
|
+
item.className = "list-group-item list-group-item-action";
|
|
93
|
+
__normalize(item.setAttribute("role", "option"));
|
|
94
|
+
item.tabIndex = __finite(-1);
|
|
95
|
+
item.id = controlId();
|
|
96
|
+
slot = new RichContent(form, item, renderer, false, "ComboBox option");
|
|
97
|
+
__normalize(slot.replace(__normalize(option.control)));
|
|
98
|
+
let label = __normalize(item.textContent.trim());
|
|
99
|
+
let content = __normalize(item.firstElementChild);
|
|
100
|
+
if (__requireBoolean(__requireBoolean(content !== null) && __requireBoolean(__normalize(content.hasAttribute("aria-label"))))) {
|
|
101
|
+
label = __normalize(content.getAttribute("aria-label"));
|
|
102
|
+
}
|
|
103
|
+
if (__requireBoolean(label === "")) {
|
|
104
|
+
let labels = [];
|
|
105
|
+
for (const image of __normalize(item.querySelectorAll("img[alt]"))) {
|
|
106
|
+
labels.push(__normalize(image.alt));
|
|
107
|
+
}
|
|
108
|
+
label = __normalize(__normalize(labels.join(" ")).trim());
|
|
109
|
+
}
|
|
110
|
+
if (__requireBoolean(label === "")) {
|
|
111
|
+
throw "ComboBox option requires text or an accessible label";
|
|
112
|
+
}
|
|
113
|
+
__normalize(item.setAttribute("aria-label", label));
|
|
114
|
+
this.#slots.push(slot);
|
|
115
|
+
__normalize(group.appendChild(item));
|
|
116
|
+
this.#elements.push(item);
|
|
117
|
+
let choice = index;
|
|
118
|
+
let click = __withArity((event) => {
|
|
119
|
+
event = __boundary(event);
|
|
120
|
+
__normalize(event.preventDefault());
|
|
121
|
+
__normalize(event.stopPropagation());
|
|
122
|
+
this.choose(choice);
|
|
123
|
+
return null;
|
|
124
|
+
}, [0], "closure");
|
|
125
|
+
let key = __withArity((event) => {
|
|
126
|
+
event = __boundary(event);
|
|
127
|
+
this.#handleKey(event, choice);
|
|
128
|
+
return null;
|
|
129
|
+
}, [0], "closure");
|
|
130
|
+
this.#listen(item, "click", click);
|
|
131
|
+
this.#listen(item, "keydown", key);
|
|
132
|
+
}
|
|
133
|
+
index = __numericAdd(index, 1);
|
|
134
|
+
}
|
|
135
|
+
this.setValue(__normalize(props.value));
|
|
136
|
+
this.setDisabled(__normalize(props.disabled) === true);
|
|
137
|
+
let toggle = () => {
|
|
138
|
+
if (__requireBoolean(__normalize(this.#panel.hidden))) {
|
|
139
|
+
this.open();
|
|
140
|
+
} else {
|
|
141
|
+
this.close();
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
let key = __withArity((event) => {
|
|
146
|
+
event = __boundary(event);
|
|
147
|
+
this.#handleKey(event, __finite(-1));
|
|
148
|
+
return null;
|
|
149
|
+
}, [0], "closure");
|
|
150
|
+
let outside = __withArity((event) => {
|
|
151
|
+
event = __boundary(event);
|
|
152
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__normalize(this.#panel.hidden))) && __requireBoolean(!__requireBoolean(__normalize(this.element.contains(__normalize(event.target))))))) {
|
|
153
|
+
this.close();
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}, [0], "closure");
|
|
157
|
+
this.#listen(__normalize(this.input), "click", toggle);
|
|
158
|
+
this.#listen(__normalize(this.input), "keydown", key);
|
|
159
|
+
this.#listen(__normalize(__hostGlobal(["document"])), "pointerdown", outside);
|
|
160
|
+
this.#listen(__normalize(__hostGlobal(["document"])), "focusin", outside);
|
|
161
|
+
}
|
|
162
|
+
#listen(element, type, listener) {
|
|
163
|
+
__requireArity(arguments.length, [0, 1, 2], "listen");
|
|
164
|
+
element = __boundary(element);
|
|
165
|
+
type = __boundary(type);
|
|
166
|
+
listener = __boundary(listener);
|
|
167
|
+
__normalize(element.addEventListener(type, listener));
|
|
168
|
+
let release = () => {
|
|
169
|
+
__normalize(element.removeEventListener(type, listener));
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
__add(this.release, release);
|
|
173
|
+
return null;
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
getValue() {
|
|
177
|
+
let values = [];
|
|
178
|
+
for (const index of __normalize(this.#selected)) {
|
|
179
|
+
let option = __normalize(this.#options[index]);
|
|
180
|
+
values.push(__normalize(option.value));
|
|
181
|
+
}
|
|
182
|
+
if (__requireBoolean(__normalize(this.#multi))) {
|
|
183
|
+
return values;
|
|
184
|
+
}
|
|
185
|
+
if (__requireBoolean(__normalize(values.length) > 0)) {
|
|
186
|
+
return __normalize(values[0]);
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
setValue(value) {
|
|
192
|
+
__requireArity(arguments.length, [0], "setValue");
|
|
193
|
+
value = __boundary(value);
|
|
194
|
+
let selected = comboSelection(__normalize(this.#options), value, __normalize(this.#multi));
|
|
195
|
+
this.#selected = selected;
|
|
196
|
+
this.#paint();
|
|
197
|
+
return this;
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
#paint() {
|
|
201
|
+
let labels = [];
|
|
202
|
+
let index = 0;
|
|
203
|
+
for (const item of __normalize(this.#elements)) {
|
|
204
|
+
if (__requireBoolean(item !== null)) {
|
|
205
|
+
let selected = __normalize(this.#selected.includes(index));
|
|
206
|
+
__normalize(item.setAttribute("aria-selected", `${selected}`));
|
|
207
|
+
__normalize(item.classList.toggle("active", selected));
|
|
208
|
+
}
|
|
209
|
+
index = __numericAdd(index, 1);
|
|
210
|
+
}
|
|
211
|
+
for (const choice of __normalize(this.#selected)) {
|
|
212
|
+
let selectedItem = __normalize(this.#elements[choice]);
|
|
213
|
+
labels.push(__normalize(selectedItem.getAttribute("aria-label")));
|
|
214
|
+
}
|
|
215
|
+
this.input.textContent = __normalize(labels.join(", "));
|
|
216
|
+
return null;
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
setDisabled(value) {
|
|
220
|
+
__requireArity(arguments.length, [0], "setDisabled");
|
|
221
|
+
value = __boundary(value);
|
|
222
|
+
this.input.disabled = __requireBoolean(value) || __requireBoolean(__normalize(this.#locked) === true);
|
|
223
|
+
if (__requireBoolean(__requireBoolean(__normalize(this.input.disabled)) && __requireBoolean(__normalize(this.#panel) !== null))) {
|
|
224
|
+
this.close();
|
|
225
|
+
}
|
|
226
|
+
return this;
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
open(last = false) {
|
|
230
|
+
last = __boundary(last);
|
|
231
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
this.#panel.hidden = false;
|
|
235
|
+
__normalize(this.input.setAttribute("aria-expanded", "true"));
|
|
236
|
+
let candidates = [];
|
|
237
|
+
let index = 0;
|
|
238
|
+
for (const item of __normalize(this.#elements)) {
|
|
239
|
+
if (__requireBoolean(item !== null)) {
|
|
240
|
+
candidates.push(index);
|
|
241
|
+
}
|
|
242
|
+
index = __numericAdd(index, 1);
|
|
243
|
+
}
|
|
244
|
+
if (__requireBoolean(__normalize(candidates.length) > 0)) {
|
|
245
|
+
let position = 0;
|
|
246
|
+
if (__requireBoolean(last)) {
|
|
247
|
+
position = __finite(__normalize(candidates.length) - 1);
|
|
248
|
+
}
|
|
249
|
+
this.#cursor = __normalize(candidates[position]);
|
|
250
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(last)) && __requireBoolean(__normalize(this.#selected.length) > 0))) {
|
|
251
|
+
this.#cursor = __normalize(this.#selected[0]);
|
|
252
|
+
}
|
|
253
|
+
this.#focusChoice(__normalize(this.#cursor));
|
|
254
|
+
}
|
|
255
|
+
return this;
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
close(focus = false) {
|
|
259
|
+
focus = __boundary(focus);
|
|
260
|
+
this.#panel.hidden = true;
|
|
261
|
+
__normalize(this.input.setAttribute("aria-expanded", "false"));
|
|
262
|
+
if (__requireBoolean(focus)) {
|
|
263
|
+
__normalize(this.input.focus());
|
|
264
|
+
}
|
|
265
|
+
return this;
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
#focusChoice(index) {
|
|
269
|
+
__requireArity(arguments.length, [0], "focusChoice");
|
|
270
|
+
index = __boundary(index);
|
|
271
|
+
let item = __normalize(this.#elements[index]);
|
|
272
|
+
__normalize(item.focus());
|
|
273
|
+
return null;
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
choose(index) {
|
|
277
|
+
__requireArity(arguments.length, [0], "choose");
|
|
278
|
+
index = __boundary(index);
|
|
279
|
+
if (__requireBoolean(__normalize(this.input.disabled))) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
let option = __normalize(this.#options[index]);
|
|
283
|
+
if (__requireBoolean(__normalize(option.value) === null)) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
if (__requireBoolean(__normalize(this.#multi))) {
|
|
287
|
+
let position = __normalize(this.#selected.indexOf(index));
|
|
288
|
+
if (__requireBoolean(position < 0)) {
|
|
289
|
+
__add(this.#selected, index);
|
|
290
|
+
} else {
|
|
291
|
+
__normalize(this.#selected.splice(position, 1));
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
this.#selected = [index];
|
|
295
|
+
}
|
|
296
|
+
this.#paint();
|
|
297
|
+
if (__requireBoolean(!__requireBoolean(__normalize(this.#multi)))) {
|
|
298
|
+
this.close(true);
|
|
299
|
+
}
|
|
300
|
+
if (__requireBoolean(__normalize(option.url) !== null)) {
|
|
301
|
+
return __normalize(this.form.send(__normalize(option.url))).catch(__withArity((error) => {
|
|
302
|
+
error = __boundary(error);
|
|
303
|
+
__normalize(this.form.app.error(__normalize(this.form), error));
|
|
304
|
+
return null;
|
|
305
|
+
}, [0], "closure"));
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
#handleKey(event, index) {
|
|
311
|
+
__requireArity(arguments.length, [0, 1], "handleKey");
|
|
312
|
+
event = __boundary(event);
|
|
313
|
+
index = __boundary(index);
|
|
314
|
+
if (__requireBoolean(__normalize(event.key) === "Escape")) {
|
|
315
|
+
__normalize(event.preventDefault());
|
|
316
|
+
__normalize(event.stopPropagation());
|
|
317
|
+
this.close(true);
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
if (__requireBoolean(index < 0)) {
|
|
321
|
+
if (__normalize(event.key) === "ArrowDown") {
|
|
322
|
+
__normalize(event.preventDefault());
|
|
323
|
+
this.open();
|
|
324
|
+
} else if (__normalize(event.key) === "ArrowUp") {
|
|
325
|
+
__normalize(event.preventDefault());
|
|
326
|
+
this.open(true);
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
if (__requireBoolean(__requireBoolean(__normalize(event.key) === "Enter") || __requireBoolean(__normalize(event.key) === " "))) {
|
|
331
|
+
__normalize(event.preventDefault());
|
|
332
|
+
this.choose(index);
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
let candidates = [];
|
|
336
|
+
let position = 0;
|
|
337
|
+
for (const item of __normalize(this.#elements)) {
|
|
338
|
+
if (__requireBoolean(item !== null)) {
|
|
339
|
+
candidates.push(position);
|
|
340
|
+
}
|
|
341
|
+
position = __numericAdd(position, 1);
|
|
342
|
+
}
|
|
343
|
+
let target = __normalize(candidates.indexOf(index));
|
|
344
|
+
if (__normalize(event.key) === "ArrowDown") {
|
|
345
|
+
target = __finite(__numericAdd(target, 1) % __normalize(candidates.length));
|
|
346
|
+
} else if (__normalize(event.key) === "ArrowUp") {
|
|
347
|
+
target = __finite(__finite(__numericAdd(target, __normalize(candidates.length)) - 1) % __normalize(candidates.length));
|
|
348
|
+
} else if (__normalize(event.key) === "Home") {
|
|
349
|
+
target = 0;
|
|
350
|
+
} else if (__normalize(event.key) === "End") {
|
|
351
|
+
target = __finite(__normalize(candidates.length) - 1);
|
|
352
|
+
} else {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
__normalize(event.preventDefault());
|
|
356
|
+
this.#cursor = __normalize(candidates[target]);
|
|
357
|
+
this.#focusChoice(__normalize(this.#cursor));
|
|
358
|
+
return null;
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
dispose() {
|
|
362
|
+
for (const slot of __normalize(this.#slots)) {
|
|
363
|
+
__normalize(slot.dispose());
|
|
364
|
+
}
|
|
365
|
+
this.#slots = [];
|
|
366
|
+
super.dispose();
|
|
367
|
+
return null;
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
export function comboSelection(options, value, multi) {
|
|
372
|
+
__requireArity(arguments.length, [0, 1, 2], "comboSelection");
|
|
373
|
+
options = __boundary(options);
|
|
374
|
+
value = __boundary(value);
|
|
375
|
+
multi = __boundary(multi);
|
|
376
|
+
let requested = [];
|
|
377
|
+
if (__requireBoolean(value !== null)) {
|
|
378
|
+
if (__requireBoolean(multi)) {
|
|
379
|
+
if (__requireBoolean(!__requireBoolean(__isArray(value)))) {
|
|
380
|
+
throw "Multi ComboBox value must be an array";
|
|
381
|
+
}
|
|
382
|
+
requested = value;
|
|
383
|
+
} else {
|
|
384
|
+
requested.push(value);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
let selected = [];
|
|
388
|
+
for (const candidate of requested) {
|
|
389
|
+
let found = __finite(-1);
|
|
390
|
+
let index = 0;
|
|
391
|
+
for (const option of options) {
|
|
392
|
+
if (__requireBoolean(__requireBoolean(__normalize(option.value) !== null) && __requireBoolean(sameValue(__normalize(option.value), candidate)))) {
|
|
393
|
+
found = index;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
index = __numericAdd(index, 1);
|
|
397
|
+
}
|
|
398
|
+
if (__requireBoolean(found < 0)) {
|
|
399
|
+
throw "ComboBox value does not identify an option";
|
|
400
|
+
}
|
|
401
|
+
if (__requireBoolean(!__requireBoolean(__normalize(selected.includes(found))))) {
|
|
402
|
+
selected.push(found);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return selected;
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
//# sourceMappingURL=combo_box.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combo_box.mjs","sources":["combo_box.lango"],"sourcesContent":["import js global document\nimport \"./fields\"\n class Field\n sameValue(first, second)\nimport \"./templates\"\n cloneMarkup(name, xml)\n controlId()\nimport \"./rich_content\"\n class RichContent\n\nexport comboSelection(options, value, multi)\n\ncomboSelection(options, value, multi)\n requested = []\n if value != null\n if multi\n if !is_array(value)\n throw \"Multi ComboBox value must be an array\"\n requested = value\n else\n requested.add(value)\n selected = []\n for requested as candidate\n found = -1\n index = 0\n for options as option\n if option.value != null and sameValue(option.value, candidate)\n found = index\n break\n index = index + 1\n if found < 0\n throw \"ComboBox value does not identify an option\"\n if !selected.includes(found)\n selected.add(found)\n return selected\n\nexport class ComboBox(form, props, renderer) : Field\n methods\n getValue()\n setValue(value)\n setDisabled(value)\n open(last = false)\n close(focus = false)\n choose(index)\n dispose()\n\nComboBox(form, props, renderer)\n super(form, props, cloneMarkup(\"combo-button\", <button type=\"button\" class=\"form-select text-start\" role=\"combobox\" aria-haspopup=\"listbox\" aria-expanded=\"false\"></button>))\n @locked = props.readonly == true\n @multi = props.multi == true\n @options = props.options\n if @options == null\n @options = []\n @selected = []\n @elements = []\n @slots = []\n @cursor = -1\n @element.classList.add(\"lango-combo\")\n @panel = cloneMarkup(\"combo-panel\", <div class=\"lango-combo-panel\" hidden=\"hidden\"><ul class=\"list-group\" role=\"listbox\"></ul></div>)\n list = @panel.firstElementChild\n list.id = controlId()\n if props.aria != null and props.aria.label != null\n list.setAttribute(\"aria-label\", props.aria.label)\n else\n if props.label != null\n list.setAttribute(\"aria-label\", props.label)\n if @multi\n list.setAttribute(\"aria-multiselectable\", \"true\")\n @input.setAttribute(\"aria-controls\", list.id)\n @element.insertBefore(@panel, @input.nextSibling)\n group = list\n index = 0\n for @options as option\n if !is_object(option)\n throw \"ComboBox options require value/control maps\"\n if option.url != null\n if option.value == null\n throw \"ComboBox group cannot have a URL\"\n form.app.checkUrl(option.url)\n item = document/createElement(\"li\")\n slot = null\n if option.value == null\n item.setAttribute(\"role\", \"presentation\")\n heading = document/createElement(\"div\")\n heading.id = controlId()\n heading.className = \"lango-combo-heading\"\n slot = new RichContent(form, heading, renderer, false, \"ComboBox group\")\n slot.replace(option.control)\n @slots.add(slot)\n item.appendChild(heading)\n group = cloneMarkup(\"combo-group\", <ul class=\"list-group\" role=\"group\"></ul>)\n group.setAttribute(\"aria-labelledby\", heading.id)\n item.appendChild(group)\n list.appendChild(item)\n @elements.add(null)\n else\n item.className = \"list-group-item list-group-item-action\"\n item.setAttribute(\"role\", \"option\")\n item.tabIndex = -1\n item.id = controlId()\n slot = new RichContent(form, item, renderer, false, \"ComboBox option\")\n slot.replace(option.control)\n label = item.textContent.trim()\n content = item.firstElementChild\n if content != null and content.hasAttribute(\"aria-label\")\n label = content.getAttribute(\"aria-label\")\n if label == \"\"\n labels = []\n for item.querySelectorAll(\"img[alt]\") as image\n labels.add(image.alt)\n label = labels.join(\" \").trim()\n if label == \"\"\n throw \"ComboBox option requires text or an accessible label\"\n item.setAttribute(\"aria-label\", label)\n @slots.add(slot)\n group.appendChild(item)\n @elements.add(item)\n choice = index\n click = (event)\n capture choice\n event.preventDefault()\n event.stopPropagation()\n choose(choice)\n key = (event)\n capture choice\n handleKey(event, choice)\n listen(item, \"click\", click)\n listen(item, \"keydown\", key)\n index = index + 1\n setValue(props.value)\n setDisabled(props.disabled == true)\n toggle = ()\n if @panel.hidden\n open()\n else\n close()\n key = (event)\n handleKey(event, -1)\n outside = (event)\n if !@panel.hidden and !@element.contains(event.target)\n close()\n listen(@input, \"click\", toggle)\n listen(@input, \"keydown\", key)\n listen(document, \"pointerdown\", outside)\n listen(document, \"focusin\", outside)\n\nComboBox:listen(element, type, listener)\n element.addEventListener(type, listener)\n release = ()\n capture element\n capture type\n capture listener\n element.removeEventListener(type, listener)\n @release.add(release)\n return null\n\nComboBox:getValue()\n values = []\n for @selected as index\n option = @options[index]\n values.add(option.value)\n if @multi\n return values\n if values.length > 0\n return values[0]\n return null\n\nComboBox:setValue(value)\n selected = comboSelection(@options, value, @multi)\n @selected = selected\n paint()\n return @this\n\nComboBox:paint()\n labels = []\n index = 0\n for @elements as item\n if item != null\n selected = @selected.includes(index)\n item.setAttribute(\"aria-selected\", \"${selected}\")\n item.classList.toggle(\"active\", selected)\n index = index + 1\n for @selected as choice\n selectedItem = @elements[choice]\n labels.add(selectedItem.getAttribute(\"aria-label\"))\n @input.textContent = labels.join(\", \")\n return null\n\nComboBox:setDisabled(value)\n @input.disabled = value or @locked == true\n if @input.disabled and @panel != null\n close()\n return @this\n\nComboBox:open(last = false)\n if @input.disabled\n return @this\n @panel.hidden = false\n @input.setAttribute(\"aria-expanded\", \"true\")\n candidates = []\n index = 0\n for @elements as item\n if item != null\n candidates.add(index)\n index = index + 1\n if candidates.length > 0\n position = 0\n if last\n position = candidates.length - 1\n @cursor = candidates[position]\n if !last and @selected.length > 0\n @cursor = @selected[0]\n focusChoice(@cursor)\n return @this\n\nComboBox:close(focus = false)\n @panel.hidden = true\n @input.setAttribute(\"aria-expanded\", \"false\")\n if focus\n @input.focus()\n return @this\n\nComboBox:focusChoice(index)\n item = @elements[index]\n item.focus()\n return null\n\nComboBox:choose(index)\n if @input.disabled\n return null\n option = @options[index]\n if option.value == null\n return null\n if @multi\n position = @selected.indexOf(index)\n if position < 0\n @selected.add(index)\n else\n @selected.splice(position, 1)\n else\n @selected = [index]\n paint()\n if !@multi\n close(true)\n if option.url != null\n return chain @form.send(option.url)\n catch(error)\n @form.app.error(@form, error)\n return null\n\nComboBox:handleKey(event, index)\n if event.key == \"Escape\"\n event.preventDefault()\n event.stopPropagation()\n close(true)\n return null\n if index < 0\n switch event.key\n case \"ArrowDown\"\n event.preventDefault()\n open()\n case \"ArrowUp\"\n event.preventDefault()\n open(true)\n return null\n if event.key == \"Enter\" or event.key == \" \"\n event.preventDefault()\n choose(index)\n return null\n candidates = []\n position = 0\n for @elements as item\n if item != null\n candidates.add(position)\n position = position + 1\n target = candidates.indexOf(index)\n switch event.key\n case \"ArrowDown\"\n target = (target + 1) % candidates.length\n case \"ArrowUp\"\n target = (target + candidates.length - 1) % candidates.length\n case \"Home\"\n target = 0\n case \"End\"\n target = candidates.length - 1\n else\n return null\n event.preventDefault()\n @cursor = candidates[target]\n focusChoice(@cursor)\n return null\n\nComboBox:dispose()\n for @slots as slot\n slot.dispose()\n @slots = []\n super.dispose()\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAxBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/content.mjs
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
entries as __entries,
|
|
9
|
+
add as __add,
|
|
10
|
+
requireBoolean as __requireBoolean,
|
|
11
|
+
normalize as __normalize,
|
|
12
|
+
boundary as __boundary,
|
|
13
|
+
requireArity as __requireArity,
|
|
14
|
+
withArity as __withArity,
|
|
15
|
+
} from "./.lango/runtime.mjs";
|
|
16
|
+
|
|
17
|
+
export function decorate(control, props) {
|
|
18
|
+
__requireArity(arguments.length, [0, 1], "decorate");
|
|
19
|
+
control = __boundary(control);
|
|
20
|
+
props = __boundary(props);
|
|
21
|
+
if (__requireBoolean(__normalize(props.style) !== null)) {
|
|
22
|
+
for (const [name, value] of __entries(__normalize(props.style))) {
|
|
23
|
+
__normalize(control.element.style.setProperty(name, value));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (__requireBoolean(__normalize(props.aria) !== null)) {
|
|
27
|
+
for (const [name, value] of __entries(__normalize(props.aria))) {
|
|
28
|
+
__normalize(control.element.setAttribute(`aria-${name}`, value));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function appendContent(form, element, content, renderer) {
|
|
36
|
+
__requireArity(arguments.length, [0, 1, 2, 3], "appendContent");
|
|
37
|
+
form = __boundary(form);
|
|
38
|
+
element = __boundary(element);
|
|
39
|
+
content = __boundary(content);
|
|
40
|
+
renderer = __boundary(renderer);
|
|
41
|
+
if (__requireBoolean(content === null)) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (__requireBoolean(__isArray(content))) {
|
|
45
|
+
for (const value of content) {
|
|
46
|
+
appendContent(form, element, value, renderer);
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
if (__requireBoolean(__requireBoolean(__isObject(content)) && __requireBoolean(__isString(__normalize(content.type))))) {
|
|
50
|
+
if (__requireBoolean(renderer === null)) {
|
|
51
|
+
throw "Control content requires a renderer";
|
|
52
|
+
}
|
|
53
|
+
__normalize(element.appendChild(__normalize(renderer.build(form, content))));
|
|
54
|
+
} else {
|
|
55
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isString(content))) && __requireBoolean(!__requireBoolean(__isNumber(content))))) {
|
|
56
|
+
throw "Content must be text or a control";
|
|
57
|
+
}
|
|
58
|
+
__normalize(element.appendChild(__normalize(__hostGlobal(["document"]).createTextNode(`${content}`))));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function bindAction(control, element, url) {
|
|
66
|
+
__requireArity(arguments.length, [0, 1, 2], "bindAction");
|
|
67
|
+
control = __boundary(control);
|
|
68
|
+
element = __boundary(element);
|
|
69
|
+
url = __boundary(url);
|
|
70
|
+
if (__requireBoolean(url === null)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
__normalize(control.form.app.checkUrl(url));
|
|
74
|
+
element.tabIndex = 0;
|
|
75
|
+
let click = __withArity((event) => {
|
|
76
|
+
event = __boundary(event);
|
|
77
|
+
if (__requireBoolean(__normalize(event.defaultPrevented))) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
let interactive = __normalize(event.target.closest("button, a, input, select, textarea, label, [role=button], [role=tab], [contenteditable=true]"));
|
|
81
|
+
if (__requireBoolean(__requireBoolean(interactive !== null) && __requireBoolean(interactive !== element))) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
__normalize(event.preventDefault());
|
|
85
|
+
__normalize(event.stopPropagation());
|
|
86
|
+
sendAction(control, url);
|
|
87
|
+
return null;
|
|
88
|
+
}, [0], "closure");
|
|
89
|
+
let key = __withArity((event) => {
|
|
90
|
+
event = __boundary(event);
|
|
91
|
+
if (__requireBoolean(__requireBoolean(__normalize(event.target) !== element) || __requireBoolean(__requireBoolean(__normalize(event.key) !== "Enter") && __requireBoolean(__normalize(event.key) !== " ")))) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
__normalize(event.preventDefault());
|
|
95
|
+
__normalize(event.stopPropagation());
|
|
96
|
+
sendAction(control, url);
|
|
97
|
+
return null;
|
|
98
|
+
}, [0], "closure");
|
|
99
|
+
__normalize(element.addEventListener("click", click));
|
|
100
|
+
__normalize(element.addEventListener("keydown", key));
|
|
101
|
+
let release = () => {
|
|
102
|
+
__normalize(element.removeEventListener("click", click));
|
|
103
|
+
__normalize(element.removeEventListener("keydown", key));
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
let releases = __normalize(control.release);
|
|
107
|
+
__add(releases, release);
|
|
108
|
+
return null;
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function sendAction(control, url) {
|
|
113
|
+
__requireArity(arguments.length, [0, 1], "sendAction");
|
|
114
|
+
control = __boundary(control);
|
|
115
|
+
url = __boundary(url);
|
|
116
|
+
return __normalize(control.form.send(url)).catch(__withArity((error) => {
|
|
117
|
+
error = __boundary(error);
|
|
118
|
+
__normalize(control.form.app.error(__normalize(control.form), error));
|
|
119
|
+
return null;
|
|
120
|
+
}, [0], "closure"));
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=content.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.mjs","sources":["content.lango"],"sourcesContent":["import js global document\n\nexport appendContent(form, element, content, renderer)\nexport bindAction(control, element, url)\nexport decorate(control, props)\n\ndecorate(control, props)\n if props.style != null\n for props.style as name: value\n control.element.style.setProperty(name, value)\n if props.aria != null\n for props.aria as name: value\n control.element.setAttribute(\"aria-${name}\", value)\n return null\n\nappendContent(form, element, content, renderer)\n if content == null\n return null\n if is_array(content)\n for content as value\n appendContent(form, element, value, renderer)\n else\n if is_object(content) and is_string(content.type)\n if renderer == null\n throw \"Control content requires a renderer\"\n element.appendChild(renderer.build(form, content))\n else\n if !is_string(content) and !is_number(content)\n throw \"Content must be text or a control\"\n element.appendChild(document/createTextNode(\"${content}\"))\n return null\n\nbindAction(control, element, url)\n if url == null\n return null\n control.form.app.checkUrl(url)\n element.tabIndex = 0\n click = (event)\n capture control\n capture element\n capture url\n if event.defaultPrevented\n return null\n interactive = event.target.closest(\"button, a, input, select, textarea, label, [role=button], [role=tab], [contenteditable=true]\")\n if interactive != null and interactive != element\n return null\n event.preventDefault()\n event.stopPropagation()\n sendAction(control, url)\n key = (event)\n capture control\n capture element\n capture url\n if event.target != element or (event.key != \"Enter\" and event.key != \" \")\n return null\n event.preventDefault()\n event.stopPropagation()\n sendAction(control, url)\n element.addEventListener(\"click\", click)\n element.addEventListener(\"keydown\", key)\n release = ()\n capture element\n capture click\n capture key\n element.removeEventListener(\"click\", click)\n element.removeEventListener(\"keydown\", key)\n releases = control.release\n releases.add(release)\n return null\n\nsendAction(control, url)\n return chain control.form.send(url)\n catch(error)\n capture control\n control.form.app.error(control.form, error)\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;;;;;;;;;;;;"}
|