@lango-project/lango-client 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/NOTICE +5 -1
- package/README.md +571 -855
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +112 -19
- 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 +112 -19
- 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 +636 -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 +95 -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 +139 -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/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 -775
- package/dist/library.mjs.map +1 -1
- package/dist/longpoll.mjs +254 -0
- package/dist/longpoll.mjs.map +1 -0
- package/dist/main.mjs +138 -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 +293 -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/tables.mjs +369 -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 +2540 -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 +42 -0
- package/package.json +26 -40
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +508 -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 +100 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -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 -571
- package/src/longpoll.lango +187 -0
- package/src/main.lango +109 -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 +288 -0
- package/src/rich_content.lango +66 -0
- package/src/tables.lango +271 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +95 -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 -431
- 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 -302
- 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 -72
- package/examples/demo_test.lango +0 -356
- package/examples/index.html +0 -28
- package/examples/pages.lango +0 -180
- 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 -1986
- package/src/session.lango +0 -313
- 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 -40
- package/template/gitignore +0 -4
- package/template/package.json +0 -22
- package/template/public/app.css +0 -4
- 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/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/src/library.lango
CHANGED
|
@@ -1,571 +1,194 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import "./
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
type = "click"
|
|
196
|
-
events[type] = definition.event
|
|
197
|
-
if definition.events != null
|
|
198
|
-
if not is_object(definition.events)
|
|
199
|
-
throw "UiClientEventsMustBeMap"
|
|
200
|
-
for definition.events as type: url
|
|
201
|
-
if type != "click" and type != "change" and type != "input"
|
|
202
|
-
throw "UiClientUnsupportedEventType"
|
|
203
|
-
events[type] = url
|
|
204
|
-
for events as type: url
|
|
205
|
-
if !is_string(url) or !url.startsWith("/") or url.startsWith("//") or url.includes("\\")
|
|
206
|
-
throw "UiClientEventRequiresSameOriginPath"
|
|
207
|
-
return events
|
|
208
|
-
|
|
209
|
-
export class Renderer
|
|
210
|
-
methods
|
|
211
|
-
create(definition)
|
|
212
|
-
replace(old, replacement)
|
|
213
|
-
remove(control)
|
|
214
|
-
capture(control)
|
|
215
|
-
restore(snapshot, operation)
|
|
216
|
-
focus(control)
|
|
217
|
-
toast(level, text)
|
|
218
|
-
release(control)
|
|
219
|
-
|
|
220
|
-
Renderer(document, types = null)
|
|
221
|
-
@document = document
|
|
222
|
-
@types = types
|
|
223
|
-
if @types == null
|
|
224
|
-
@types = new Types()
|
|
225
|
-
|
|
226
|
-
Renderer:create(definition)
|
|
227
|
-
return @types.create(@document, definition)
|
|
228
|
-
|
|
229
|
-
Renderer:release(control)
|
|
230
|
-
releaseControl(control)
|
|
231
|
-
return null
|
|
232
|
-
|
|
233
|
-
releaseControl(control)
|
|
234
|
-
if is_array(control.controls)
|
|
235
|
-
for control.controls as child
|
|
236
|
-
releaseControl(child)
|
|
237
|
-
try
|
|
238
|
-
if control.dispose != null
|
|
239
|
-
control.dispose()
|
|
240
|
-
catch error
|
|
241
|
-
context log
|
|
242
|
-
log.err("Control disposal failed: ${error}")
|
|
243
|
-
return null
|
|
244
|
-
|
|
245
|
-
Renderer:replace(old, replacement)
|
|
246
|
-
element = old.element
|
|
247
|
-
element.parentNode.replaceChild(replacement.element, element)
|
|
248
|
-
return null
|
|
249
|
-
|
|
250
|
-
Renderer:remove(control)
|
|
251
|
-
control.element.remove()
|
|
252
|
-
return null
|
|
253
|
-
|
|
254
|
-
Renderer:capture(control)
|
|
255
|
-
element = control.element
|
|
256
|
-
return {
|
|
257
|
-
element: element
|
|
258
|
-
parent: element.parentNode
|
|
259
|
-
next: element.nextSibling
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
Renderer:restore(snapshot, operation)
|
|
263
|
-
if operation.type == "replace"
|
|
264
|
-
replacement = operation.new
|
|
265
|
-
replacement.element.remove()
|
|
266
|
-
if snapshot.parent != null
|
|
267
|
-
snapshot.parent.insertBefore(snapshot.element, snapshot.next)
|
|
268
|
-
return null
|
|
269
|
-
|
|
270
|
-
Renderer:focus(control)
|
|
271
|
-
control.element.focus()
|
|
272
|
-
return null
|
|
273
|
-
|
|
274
|
-
Renderer:toast(level, text)
|
|
275
|
-
element = @document.createElement("div")
|
|
276
|
-
element.setAttribute("role", "status")
|
|
277
|
-
element.textContent = text
|
|
278
|
-
@document.body.appendChild(element)
|
|
279
|
-
return null
|
|
280
|
-
|
|
281
|
-
export class Control
|
|
282
|
-
properties
|
|
283
|
-
name
|
|
284
|
-
element
|
|
285
|
-
controls
|
|
286
|
-
events
|
|
287
|
-
inherit
|
|
288
|
-
validates
|
|
289
|
-
confirms
|
|
290
|
-
methods
|
|
291
|
-
getValue()
|
|
292
|
-
setValue(value)
|
|
293
|
-
applyProperty(name, value)
|
|
294
|
-
snapshotState()
|
|
295
|
-
restoreState(snapshot)
|
|
296
|
-
dispose()
|
|
297
|
-
isDirty()
|
|
298
|
-
markClean()
|
|
299
|
-
acceptSaved(value)
|
|
300
|
-
validate()
|
|
301
|
-
reportValidity()
|
|
302
|
-
reportPendingError()
|
|
303
|
-
|
|
304
|
-
Control(document, definition, types = null, options = null)
|
|
305
|
-
@name = definition.name
|
|
306
|
-
@type = definition.type
|
|
307
|
-
@controls = null
|
|
308
|
-
@value = definition.value
|
|
309
|
-
@clean = null
|
|
310
|
-
@error = null
|
|
311
|
-
@pendingError = false
|
|
312
|
-
@rules = rulesFor(definition.validation)
|
|
313
|
-
@tracked = definition.trackChanges
|
|
314
|
-
if @tracked == null
|
|
315
|
-
@tracked = @type == "Text" or @type == "Select" or @type == "Checkbox"
|
|
316
|
-
if !is_bool(@tracked)
|
|
317
|
-
throw "UiTrackChangesMustBeBoolean"
|
|
318
|
-
@validates = definition.validate
|
|
319
|
-
if @validates == null
|
|
320
|
-
@validates = false
|
|
321
|
-
if !is_bool(@validates)
|
|
322
|
-
throw "UiValidateEventMustBeBoolean"
|
|
323
|
-
@confirms = definition.confirmDirty
|
|
324
|
-
if @confirms == null
|
|
325
|
-
@confirms = false
|
|
326
|
-
if !is_bool(@confirms)
|
|
327
|
-
throw "UiConfirmDirtyMustBeBoolean"
|
|
328
|
-
@items = []
|
|
329
|
-
if @type == "Select"
|
|
330
|
-
@items = selectItems(definition.options)
|
|
331
|
-
@events = controlEvents(definition)
|
|
332
|
-
@inherit = normalizeInheritance(definition.inherit)
|
|
333
|
-
@classes = classNames(definition.classes)
|
|
334
|
-
@style = styleMap(definition.style)
|
|
335
|
-
registry = types
|
|
336
|
-
if registry == null
|
|
337
|
-
registry = new Types()
|
|
338
|
-
if definition.inherit != null and @type != "Form"
|
|
339
|
-
throw "UiInheritanceRequiresForm"
|
|
340
|
-
tag = "div"
|
|
341
|
-
if @type == "Text" or @type == "Checkbox"
|
|
342
|
-
tag = "input"
|
|
343
|
-
if @type == "Select"
|
|
344
|
-
tag = "select"
|
|
345
|
-
if @type == "Button"
|
|
346
|
-
tag = "button"
|
|
347
|
-
if options != null
|
|
348
|
-
tag = options.tag
|
|
349
|
-
if !is_string(tag) or tag == ""
|
|
350
|
-
throw "UiCustomControlRequiresTag"
|
|
351
|
-
if options == null and @type != "Text" and @type != "Button" and @type != "Value" and @type != "Panel" and @type != "Container" and @type != "Form" and @type != "Select" and @type != "Checkbox"
|
|
352
|
-
throw "UiClientUnknownControlType"
|
|
353
|
-
@element = document.createElement(tag)
|
|
354
|
-
element = @element
|
|
355
|
-
if @type == "Form"
|
|
356
|
-
element.langoFormRoot = true
|
|
357
|
-
if @type == "Button"
|
|
358
|
-
element.type = "button"
|
|
359
|
-
element.textContent = definition.text
|
|
360
|
-
if @type == "Value"
|
|
361
|
-
element.hidden = true
|
|
362
|
-
if @type == "Checkbox"
|
|
363
|
-
element.type = "checkbox"
|
|
364
|
-
if definition.label != null
|
|
365
|
-
if !is_string(definition.label)
|
|
366
|
-
throw "UiControlLabelMustBeString"
|
|
367
|
-
element.setAttribute("aria-label", definition.label)
|
|
368
|
-
container = @type == "Panel" or @type == "Container" or @type == "Form"
|
|
369
|
-
if options != null and options.container == true
|
|
370
|
-
container = true
|
|
371
|
-
if container
|
|
372
|
-
@controls = []
|
|
373
|
-
try
|
|
374
|
-
if @type == "Select"
|
|
375
|
-
for @items as item
|
|
376
|
-
option = document.createElement("option")
|
|
377
|
-
option.value = item.value
|
|
378
|
-
option.textContent = item.text
|
|
379
|
-
option.disabled = item.disabled
|
|
380
|
-
element.appendChild(option)
|
|
381
|
-
if container and is_array(definition.controls)
|
|
382
|
-
for definition.controls as childDefinition
|
|
383
|
-
child = registry.create(document, childDefinition)
|
|
384
|
-
@controls.add(child)
|
|
385
|
-
element.appendChild(child.element)
|
|
386
|
-
if definition.classes != null
|
|
387
|
-
applyProperty("classes", definition.classes)
|
|
388
|
-
if definition.style != null
|
|
389
|
-
applyProperty("style", definition.style)
|
|
390
|
-
if definition.enabled != null
|
|
391
|
-
applyProperty("enabled", definition.enabled)
|
|
392
|
-
if definition.visible != null
|
|
393
|
-
applyProperty("visible", definition.visible)
|
|
394
|
-
initial = definition.value
|
|
395
|
-
if @type == "Checkbox" and initial == null
|
|
396
|
-
initial = false
|
|
397
|
-
setValue(initial)
|
|
398
|
-
markClean()
|
|
399
|
-
catch error
|
|
400
|
-
if is_array(@controls)
|
|
401
|
-
for @controls as child
|
|
402
|
-
releaseControl(child)
|
|
403
|
-
throw error
|
|
404
|
-
|
|
405
|
-
Control:getValue()
|
|
406
|
-
if is_array(@controls)
|
|
407
|
-
return collectValues(@controls)
|
|
408
|
-
switch @type
|
|
409
|
-
case "Text"
|
|
410
|
-
return @element.value
|
|
411
|
-
case "Checkbox"
|
|
412
|
-
return @element.checked
|
|
413
|
-
case "Select"
|
|
414
|
-
index = @element.selectedIndex
|
|
415
|
-
if index < 0 or index >= @items.length
|
|
416
|
-
return null
|
|
417
|
-
return @items[index].value
|
|
418
|
-
else
|
|
419
|
-
return @value
|
|
420
|
-
|
|
421
|
-
Control:setValue(value)
|
|
422
|
-
switch @type
|
|
423
|
-
case "Text"
|
|
424
|
-
text = value
|
|
425
|
-
if value == null
|
|
426
|
-
text = ""
|
|
427
|
-
@element.value = text
|
|
428
|
-
case "Checkbox"
|
|
429
|
-
if !is_bool(value)
|
|
430
|
-
throw "UiCheckboxValueMustBeBoolean"
|
|
431
|
-
@element.checked = value
|
|
432
|
-
case "Select"
|
|
433
|
-
@element.selectedIndex = selectIndex(@items, value)
|
|
434
|
-
@value = value
|
|
435
|
-
if @error != null
|
|
436
|
-
validate()
|
|
437
|
-
return null
|
|
438
|
-
|
|
439
|
-
Control:isDirty()
|
|
440
|
-
if is_array(@controls)
|
|
441
|
-
for @controls as child
|
|
442
|
-
if child.isDirty != null
|
|
443
|
-
if child.isDirty()
|
|
444
|
-
return true
|
|
445
|
-
return false
|
|
446
|
-
if !@tracked
|
|
447
|
-
return false
|
|
448
|
-
current = from_json(to_json(getValue()))
|
|
449
|
-
return !sameValue(current, @clean)
|
|
450
|
-
|
|
451
|
-
Control:markClean()
|
|
452
|
-
if is_array(@controls)
|
|
453
|
-
for @controls as child
|
|
454
|
-
if child.markClean != null
|
|
455
|
-
child.markClean()
|
|
456
|
-
else
|
|
457
|
-
acceptSaved(getValue())
|
|
458
|
-
return null
|
|
459
|
-
|
|
460
|
-
Control:acceptSaved(value)
|
|
461
|
-
@clean = from_json(to_json(value))
|
|
462
|
-
return null
|
|
463
|
-
|
|
464
|
-
Control:validate()
|
|
465
|
-
@pendingError = false
|
|
466
|
-
@error = validationMessage(@rules, getValue())
|
|
467
|
-
renderError()
|
|
468
|
-
return @error
|
|
469
|
-
|
|
470
|
-
Control:renderError()
|
|
471
|
-
text = @error
|
|
472
|
-
if text == null
|
|
473
|
-
text = ""
|
|
474
|
-
@element.setAttribute("aria-invalid", "${@error != null}")
|
|
475
|
-
@element.setAttribute("data-lango-error", text)
|
|
476
|
-
if @element.setCustomValidity != null
|
|
477
|
-
@element.setCustomValidity(text)
|
|
478
|
-
return null
|
|
479
|
-
|
|
480
|
-
Control:reportValidity()
|
|
481
|
-
if @element.reportValidity != null
|
|
482
|
-
return @element.reportValidity()
|
|
483
|
-
return @error == null
|
|
484
|
-
|
|
485
|
-
Control:reportPendingError()
|
|
486
|
-
if !@pendingError
|
|
487
|
-
return false
|
|
488
|
-
current = @element
|
|
489
|
-
loop while current != null
|
|
490
|
-
if current.disabled == true or current.hidden == true or current.inert == true
|
|
491
|
-
return false
|
|
492
|
-
current = current.parentNode
|
|
493
|
-
@pendingError = false
|
|
494
|
-
reportValidity()
|
|
495
|
-
return true
|
|
496
|
-
|
|
497
|
-
Control:applyProperty(name, value)
|
|
498
|
-
validateProperty(name, value)
|
|
499
|
-
switch name
|
|
500
|
-
case "enabled"
|
|
501
|
-
@element.disabled = !value
|
|
502
|
-
@element.inert = !value
|
|
503
|
-
case "visible"
|
|
504
|
-
@element.hidden = !value or @type == "Value"
|
|
505
|
-
case "classes"
|
|
506
|
-
@classes = classNames(value)
|
|
507
|
-
@element.className = @classes.join(" ")
|
|
508
|
-
case "style"
|
|
509
|
-
styles = styleMap(value)
|
|
510
|
-
for @style as property: text
|
|
511
|
-
@element.style.removeProperty(property)
|
|
512
|
-
for styles as property: text
|
|
513
|
-
@element.style.setProperty(property, text)
|
|
514
|
-
@style = styles
|
|
515
|
-
case "savedValue"
|
|
516
|
-
acceptSaved(value)
|
|
517
|
-
case "error"
|
|
518
|
-
@error = value
|
|
519
|
-
@pendingError = value != null
|
|
520
|
-
renderError()
|
|
521
|
-
reportPendingError()
|
|
522
|
-
return null
|
|
523
|
-
|
|
524
|
-
Control:snapshotState()
|
|
525
|
-
return {
|
|
526
|
-
value: @value
|
|
527
|
-
text: @element.value
|
|
528
|
-
checked: @element.checked
|
|
529
|
-
selectedIndex: @element.selectedIndex
|
|
530
|
-
disabled: @element.disabled
|
|
531
|
-
hidden: @element.hidden
|
|
532
|
-
inert: @element.inert
|
|
533
|
-
classes: @element.className
|
|
534
|
-
style: @element.style.cssText
|
|
535
|
-
managedStyle: @style
|
|
536
|
-
managedClasses: @classes
|
|
537
|
-
clean: @clean
|
|
538
|
-
error: @error
|
|
539
|
-
pendingError: @pendingError
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
Control:restoreState(snapshot)
|
|
543
|
-
setValue(snapshot.value)
|
|
544
|
-
if @type == "Text"
|
|
545
|
-
@element.value = snapshot.text
|
|
546
|
-
if @type == "Checkbox"
|
|
547
|
-
@element.checked = snapshot.checked
|
|
548
|
-
if @type == "Select"
|
|
549
|
-
@element.selectedIndex = snapshot.selectedIndex
|
|
550
|
-
@element.disabled = snapshot.disabled
|
|
551
|
-
@element.hidden = snapshot.hidden
|
|
552
|
-
@element.inert = snapshot.inert
|
|
553
|
-
@element.className = snapshot.classes
|
|
554
|
-
@element.style.cssText = snapshot.style
|
|
555
|
-
@style = snapshot.managedStyle
|
|
556
|
-
@classes = snapshot.managedClasses
|
|
557
|
-
@clean = snapshot.clean
|
|
558
|
-
@error = snapshot.error
|
|
559
|
-
@pendingError = snapshot.pendingError
|
|
560
|
-
renderError()
|
|
561
|
-
return null
|
|
562
|
-
|
|
563
|
-
Control:dispose()
|
|
564
|
-
return null
|
|
565
|
-
|
|
566
|
-
mount(document, root, definition, types = null)
|
|
567
|
-
if types == null
|
|
568
|
-
types = new Types()
|
|
569
|
-
control = types.create(document, definition)
|
|
570
|
-
root.appendChild(control.element)
|
|
571
|
-
return control
|
|
1
|
+
import "./date_input"
|
|
2
|
+
alias DateInputClass = class DateInput
|
|
3
|
+
import "./numeric_input"
|
|
4
|
+
alias NumericInputClass = class NumericInput
|
|
5
|
+
import "./file_input"
|
|
6
|
+
alias FileInputClass = class FileInput
|
|
7
|
+
import "./otp_input"
|
|
8
|
+
alias OTPInputClass = class OTPInput
|
|
9
|
+
import "./chip"
|
|
10
|
+
alias ChipClass = class Chip
|
|
11
|
+
import "./combo_box"
|
|
12
|
+
alias ComboBoxClass = class ComboBox
|
|
13
|
+
import "./indicators"
|
|
14
|
+
alias AvatarClass = class Avatar
|
|
15
|
+
alias FormSpinnerClass = class FormSpinner
|
|
16
|
+
import "./button"
|
|
17
|
+
alias ButtonClass = class Button
|
|
18
|
+
import "./input_group"
|
|
19
|
+
alias InputGroupClass = class InputGroup
|
|
20
|
+
import "./markdown"
|
|
21
|
+
alias MarkdownClass = class Markdown
|
|
22
|
+
import "./accordion"
|
|
23
|
+
alias AccordionClass = class Accordion
|
|
24
|
+
alias AccordionItemClass = class AccordionItem
|
|
25
|
+
import "./collections"
|
|
26
|
+
alias ListGroupClass = class ListGroup
|
|
27
|
+
import "./menus"
|
|
28
|
+
alias MenuClass = class Menu
|
|
29
|
+
alias MenuItemClass = class MenuItem
|
|
30
|
+
import "./layouts"
|
|
31
|
+
alias CardClass = class Card
|
|
32
|
+
alias CardGroupClass = class CardGroup
|
|
33
|
+
alias ImageClass = class Image
|
|
34
|
+
alias BadgeClass = class Badge
|
|
35
|
+
alias ToolbarClass = class Toolbar
|
|
36
|
+
import "./tables"
|
|
37
|
+
alias TableClass = class Table
|
|
38
|
+
alias TableHeaderClass = class TableHeader
|
|
39
|
+
alias TableRowClass = class TableRow
|
|
40
|
+
alias TableCellClass = class TableCell
|
|
41
|
+
alias TableColClass = class TableCol
|
|
42
|
+
alias TableDividerClass = class TableDivider
|
|
43
|
+
import "./tabs"
|
|
44
|
+
alias TabClass = class Tab
|
|
45
|
+
alias TabItemClass = class TabItem
|
|
46
|
+
import "./navigation"
|
|
47
|
+
alias NavClass = class Nav
|
|
48
|
+
alias NavBarClass = class NavBar
|
|
49
|
+
alias NavItemClass = class NavItem
|
|
50
|
+
alias NavBarItemClass = class NavBarItem
|
|
51
|
+
alias BreadcrumbClass = class Breadcrumb
|
|
52
|
+
alias BreadcrumbItemClass = class BreadcrumbItem
|
|
53
|
+
|
|
54
|
+
import "./app"
|
|
55
|
+
alias AppClass = class App
|
|
56
|
+
import "./form"
|
|
57
|
+
alias FormClass = class Form
|
|
58
|
+
import "./renderer"
|
|
59
|
+
alias RendererClass = class BootstrapRenderer
|
|
60
|
+
import "./control"
|
|
61
|
+
alias ControlClass = class Control
|
|
62
|
+
alias ValueClass = class Value
|
|
63
|
+
import "./fields"
|
|
64
|
+
alias FieldClass = class Field
|
|
65
|
+
alias InputClass = class Input
|
|
66
|
+
alias CheckboxClass = class Checkbox
|
|
67
|
+
alias SwitchClass = class Switch
|
|
68
|
+
alias RangeClass = class Range
|
|
69
|
+
alias SelectClass = class Select
|
|
70
|
+
alias RadioClass = class Radio
|
|
71
|
+
import "./templates"
|
|
72
|
+
alias makeTemplate = createTemplate(xml)
|
|
73
|
+
alias copyTemplate = cloneTemplate(template)
|
|
74
|
+
import "./widgets"
|
|
75
|
+
alias AlertClass = class Alert
|
|
76
|
+
alias ProgressClass = class Progress
|
|
77
|
+
import "./presentations"
|
|
78
|
+
alias ToastClass = class Toast
|
|
79
|
+
alias ToastStackClass = class ToastStack
|
|
80
|
+
alias DialogClass = class Dialog
|
|
81
|
+
|
|
82
|
+
export global OTPInput
|
|
83
|
+
export global FileInput
|
|
84
|
+
export global NumericInput
|
|
85
|
+
export global DateInput
|
|
86
|
+
export global Chip
|
|
87
|
+
export global ComboBox
|
|
88
|
+
export global Avatar
|
|
89
|
+
export global FormSpinner
|
|
90
|
+
export global Button
|
|
91
|
+
export global InputGroup
|
|
92
|
+
export global Markdown
|
|
93
|
+
export global Accordion
|
|
94
|
+
export global AccordionItem
|
|
95
|
+
export global ListGroup
|
|
96
|
+
export global Menu
|
|
97
|
+
export global MenuItem
|
|
98
|
+
export global Card
|
|
99
|
+
export global CardGroup
|
|
100
|
+
export global Image
|
|
101
|
+
export global Badge
|
|
102
|
+
export global Toolbar
|
|
103
|
+
export global Table
|
|
104
|
+
export global TableHeader
|
|
105
|
+
export global TableRow
|
|
106
|
+
export global TableCell
|
|
107
|
+
export global TableCol
|
|
108
|
+
export global TableDivider
|
|
109
|
+
export global Tab
|
|
110
|
+
export global TabItem
|
|
111
|
+
export global Nav
|
|
112
|
+
export global NavBar
|
|
113
|
+
export global NavItem
|
|
114
|
+
export global NavBarItem
|
|
115
|
+
export global Breadcrumb
|
|
116
|
+
export global BreadcrumbItem
|
|
117
|
+
export global App
|
|
118
|
+
export global Form
|
|
119
|
+
export global BootstrapRenderer
|
|
120
|
+
export global Control
|
|
121
|
+
export global Value
|
|
122
|
+
export global Field
|
|
123
|
+
export global Input
|
|
124
|
+
export global Checkbox
|
|
125
|
+
export global Switch
|
|
126
|
+
export global Range
|
|
127
|
+
export global Select
|
|
128
|
+
export global Radio
|
|
129
|
+
export global Alert
|
|
130
|
+
export global Progress
|
|
131
|
+
export global Toast
|
|
132
|
+
export global ToastStack
|
|
133
|
+
export global Dialog
|
|
134
|
+
export createTemplate(xml)
|
|
135
|
+
export cloneTemplate(template)
|
|
136
|
+
|
|
137
|
+
global OTPInput = OTPInputClass
|
|
138
|
+
global FileInput = FileInputClass
|
|
139
|
+
global NumericInput = NumericInputClass
|
|
140
|
+
global DateInput = DateInputClass
|
|
141
|
+
global Chip = ChipClass
|
|
142
|
+
global ComboBox = ComboBoxClass
|
|
143
|
+
global Avatar = AvatarClass
|
|
144
|
+
global FormSpinner = FormSpinnerClass
|
|
145
|
+
global Button = ButtonClass
|
|
146
|
+
global InputGroup = InputGroupClass
|
|
147
|
+
global Markdown = MarkdownClass
|
|
148
|
+
global Accordion = AccordionClass
|
|
149
|
+
global AccordionItem = AccordionItemClass
|
|
150
|
+
global ListGroup = ListGroupClass
|
|
151
|
+
global Menu = MenuClass
|
|
152
|
+
global MenuItem = MenuItemClass
|
|
153
|
+
global Card = CardClass
|
|
154
|
+
global CardGroup = CardGroupClass
|
|
155
|
+
global Image = ImageClass
|
|
156
|
+
global Badge = BadgeClass
|
|
157
|
+
global Toolbar = ToolbarClass
|
|
158
|
+
global Table = TableClass
|
|
159
|
+
global TableHeader = TableHeaderClass
|
|
160
|
+
global TableRow = TableRowClass
|
|
161
|
+
global TableCell = TableCellClass
|
|
162
|
+
global TableCol = TableColClass
|
|
163
|
+
global TableDivider = TableDividerClass
|
|
164
|
+
global Tab = TabClass
|
|
165
|
+
global TabItem = TabItemClass
|
|
166
|
+
global Nav = NavClass
|
|
167
|
+
global NavBar = NavBarClass
|
|
168
|
+
global NavItem = NavItemClass
|
|
169
|
+
global NavBarItem = NavBarItemClass
|
|
170
|
+
global Breadcrumb = BreadcrumbClass
|
|
171
|
+
global BreadcrumbItem = BreadcrumbItemClass
|
|
172
|
+
global App = AppClass
|
|
173
|
+
global Form = FormClass
|
|
174
|
+
global BootstrapRenderer = RendererClass
|
|
175
|
+
global Control = ControlClass
|
|
176
|
+
global Value = ValueClass
|
|
177
|
+
global Field = FieldClass
|
|
178
|
+
global Input = InputClass
|
|
179
|
+
global Checkbox = CheckboxClass
|
|
180
|
+
global Switch = SwitchClass
|
|
181
|
+
global Range = RangeClass
|
|
182
|
+
global Select = SelectClass
|
|
183
|
+
global Radio = RadioClass
|
|
184
|
+
global Alert = AlertClass
|
|
185
|
+
global Progress = ProgressClass
|
|
186
|
+
global Toast = ToastClass
|
|
187
|
+
global ToastStack = ToastStackClass
|
|
188
|
+
global Dialog = DialogClass
|
|
189
|
+
|
|
190
|
+
createTemplate(xml)
|
|
191
|
+
return makeTemplate(xml)
|
|
192
|
+
|
|
193
|
+
cloneTemplate(template)
|
|
194
|
+
return copyTemplate(template)
|