@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.
Files changed (240) hide show
  1. package/LICENSE +1 -0
  2. package/NOTICE +5 -1
  3. package/README.md +603 -906
  4. package/cli/.lango/localization.mjs +108 -0
  5. package/{dist/node → cli}/.lango/runtime.mjs +120 -20
  6. package/cli/.lango/vendor/i18next.LICENSE +21 -0
  7. package/cli/.lango/vendor/i18next.mjs +2434 -0
  8. package/cli/create.mjs +62 -0
  9. package/cli/create.mjs.map +1 -0
  10. package/dist/.lango/localization.mjs +108 -0
  11. package/dist/.lango/runtime.mjs +120 -20
  12. package/dist/.lango/vendor/i18next.LICENSE +21 -0
  13. package/dist/.lango/vendor/i18next.mjs +2434 -0
  14. package/dist/accordion.mjs +277 -0
  15. package/dist/accordion.mjs.map +1 -0
  16. package/dist/activities.mjs +185 -0
  17. package/dist/activities.mjs.map +1 -0
  18. package/dist/app.mjs +671 -0
  19. package/dist/app.mjs.map +1 -0
  20. package/dist/boot.mjs +24 -0
  21. package/dist/boot.mjs.map +1 -0
  22. package/dist/bootstrap-LICENSE +21 -0
  23. package/dist/bootstrap.min.css +6 -0
  24. package/dist/bootstrap.min.css.map +1 -0
  25. package/dist/button.mjs +77 -0
  26. package/dist/button.mjs.map +1 -0
  27. package/dist/chip.mjs +134 -0
  28. package/dist/chip.mjs.map +1 -0
  29. package/dist/client.css +102 -0
  30. package/dist/collections.mjs +77 -0
  31. package/dist/collections.mjs.map +1 -0
  32. package/dist/combo_box.mjs +408 -0
  33. package/dist/combo_box.mjs.map +1 -0
  34. package/dist/content.mjs +123 -0
  35. package/dist/content.mjs.map +1 -0
  36. package/dist/control.mjs +141 -0
  37. package/dist/control.mjs.map +1 -0
  38. package/dist/date_input.mjs +242 -0
  39. package/dist/date_input.mjs.map +1 -0
  40. package/dist/dimensions.mjs +102 -0
  41. package/dist/dimensions.mjs.map +1 -0
  42. package/dist/error_reporter.mjs +136 -0
  43. package/dist/error_reporter.mjs.map +1 -0
  44. package/dist/fields.mjs +454 -0
  45. package/dist/fields.mjs.map +1 -0
  46. package/dist/file_input.mjs +227 -0
  47. package/dist/file_input.mjs.map +1 -0
  48. package/dist/form.mjs +272 -0
  49. package/dist/form.mjs.map +1 -0
  50. package/dist/heartbeat.mjs +167 -254
  51. package/dist/heartbeat.mjs.map +1 -1
  52. package/dist/index.html +18 -0
  53. package/dist/indicators.mjs +127 -0
  54. package/dist/indicators.mjs.map +1 -0
  55. package/dist/input_changes.mjs +58 -0
  56. package/dist/input_changes.mjs.map +1 -0
  57. package/dist/input_group.mjs +38 -0
  58. package/dist/input_group.mjs.map +1 -0
  59. package/dist/layouts.mjs +195 -0
  60. package/dist/layouts.mjs.map +1 -0
  61. package/dist/library.mjs +130 -807
  62. package/dist/library.mjs.map +1 -1
  63. package/dist/longpoll.mjs +254 -0
  64. package/dist/longpoll.mjs.map +1 -0
  65. package/dist/main.mjs +147 -0
  66. package/dist/main.mjs.map +1 -0
  67. package/dist/markdown.mjs +61 -0
  68. package/dist/markdown.mjs.map +1 -0
  69. package/dist/menus.mjs +468 -0
  70. package/dist/menus.mjs.map +1 -0
  71. package/dist/navigation.mjs +260 -410
  72. package/dist/navigation.mjs.map +1 -1
  73. package/dist/numeric_input.mjs +181 -0
  74. package/dist/numeric_input.mjs.map +1 -0
  75. package/dist/otp_input.mjs +113 -0
  76. package/dist/otp_input.mjs.map +1 -0
  77. package/dist/presentations.mjs +852 -0
  78. package/dist/presentations.mjs.map +1 -0
  79. package/dist/renderer.mjs +295 -0
  80. package/dist/renderer.mjs.map +1 -0
  81. package/dist/rich_content.mjs +99 -0
  82. package/dist/rich_content.mjs.map +1 -0
  83. package/dist/table_scope.mjs +166 -0
  84. package/dist/table_scope.mjs.map +1 -0
  85. package/dist/tables.mjs +1052 -0
  86. package/dist/tables.mjs.map +1 -0
  87. package/dist/tabs.mjs +205 -0
  88. package/dist/tabs.mjs.map +1 -0
  89. package/dist/templates.mjs +46 -0
  90. package/dist/templates.mjs.map +1 -0
  91. package/dist/vendor/DOMPurify-LICENSE +202 -0
  92. package/dist/vendor/dompurify.mjs +2454 -0
  93. package/dist/vendor/flatpickr-LICENSE.md +21 -0
  94. package/dist/vendor/flatpickr.min.css +13 -0
  95. package/dist/vendor/flatpickr.mjs +2340 -0
  96. package/dist/vendor/flatpickr.mjs.map +7 -0
  97. package/dist/vendor/marked-LICENSE.md +44 -0
  98. package/dist/vendor/marked.esm.js.map +7 -0
  99. package/dist/vendor/marked.mjs +85 -0
  100. package/dist/vendor/purify.es.mjs.map +1 -0
  101. package/dist/widgets.mjs +197 -0
  102. package/dist/widgets.mjs.map +1 -0
  103. package/docs/implementation.md +93 -0
  104. package/package.json +25 -43
  105. package/src/accordion.lango +198 -0
  106. package/src/activities.lango +132 -0
  107. package/src/app.lango +540 -0
  108. package/src/boot.lango +12 -0
  109. package/src/button.lango +49 -0
  110. package/src/chip.lango +94 -0
  111. package/src/collections.lango +46 -0
  112. package/src/combo_box.lango +298 -0
  113. package/src/content.lango +75 -0
  114. package/src/control.lango +103 -0
  115. package/src/create.lango +42 -0
  116. package/src/date_input.lango +215 -0
  117. package/src/dimensions.lango +65 -0
  118. package/src/error_reporter.lango +95 -0
  119. package/src/fields.lango +327 -0
  120. package/src/file_input.lango +175 -0
  121. package/src/form.lango +195 -0
  122. package/src/heartbeat.lango +136 -199
  123. package/src/indicators.lango +94 -0
  124. package/src/input_changes.lango +33 -0
  125. package/src/input_group.lango +22 -0
  126. package/src/layouts.lango +137 -0
  127. package/src/library.lango +194 -599
  128. package/src/longpoll.lango +187 -0
  129. package/src/main.lango +118 -0
  130. package/src/markdown.lango +48 -0
  131. package/src/menus.lango +336 -0
  132. package/src/navigation.lango +209 -299
  133. package/src/numeric_input.lango +131 -0
  134. package/src/otp_input.lango +83 -0
  135. package/src/presentations.lango +617 -0
  136. package/src/renderer.lango +296 -0
  137. package/src/rich_content.lango +66 -0
  138. package/src/table_scope.lango +119 -0
  139. package/src/tables.lango +786 -0
  140. package/src/tabs.lango +144 -0
  141. package/src/templates.lango +29 -0
  142. package/src/widgets.lango +141 -0
  143. package/web/client.css +102 -0
  144. package/web/index.html +18 -0
  145. package/dist/application.mjs +0 -429
  146. package/dist/application.mjs.map +0 -1
  147. package/dist/coordinator.mjs +0 -91
  148. package/dist/coordinator.mjs.map +0 -1
  149. package/dist/demo.mjs +0 -110
  150. package/dist/demo.mjs.map +0 -1
  151. package/dist/demo_controls.mjs +0 -59
  152. package/dist/demo_controls.mjs.map +0 -1
  153. package/dist/errors.mjs +0 -201
  154. package/dist/errors.mjs.map +0 -1
  155. package/dist/form_state.mjs +0 -266
  156. package/dist/form_state.mjs.map +0 -1
  157. package/dist/inheritance.mjs +0 -240
  158. package/dist/inheritance.mjs.map +0 -1
  159. package/dist/input_values.mjs +0 -65
  160. package/dist/input_values.mjs.map +0 -1
  161. package/dist/node/.lango/xmldom/conventions.js +0 -429
  162. package/dist/node/.lango/xmldom/dom-parser.js +0 -591
  163. package/dist/node/.lango/xmldom/dom.js +0 -3759
  164. package/dist/node/.lango/xmldom/entities.js +0 -2171
  165. package/dist/node/.lango/xmldom/errors.js +0 -205
  166. package/dist/node/.lango/xmldom/grammar.js +0 -559
  167. package/dist/node/.lango/xmldom/index.js +0 -41
  168. package/dist/node/.lango/xmldom/package.json +0 -1
  169. package/dist/node/.lango/xmldom/sax.js +0 -983
  170. package/dist/node/.lango/xmldom.LICENSE.md +0 -8
  171. package/dist/node/browser_host.mjs +0 -351
  172. package/dist/node/browser_host.mjs.map +0 -1
  173. package/dist/node/create_app.mjs +0 -118
  174. package/dist/node/create_app.mjs.map +0 -1
  175. package/dist/presentation.mjs +0 -89
  176. package/dist/presentation.mjs.map +0 -1
  177. package/dist/protocol.mjs +0 -706
  178. package/dist/protocol.mjs.map +0 -1
  179. package/dist/session.mjs +0 -471
  180. package/dist/session.mjs.map +0 -1
  181. package/dist/tokens.mjs +0 -298
  182. package/dist/tokens.mjs.map +0 -1
  183. package/examples/contacts.lango +0 -293
  184. package/examples/contacts_flow.lango +0 -174
  185. package/examples/contacts_store.lango +0 -109
  186. package/examples/contacts_store_test.lango +0 -65
  187. package/examples/demo.css +0 -87
  188. package/examples/demo_test.lango +0 -356
  189. package/examples/index.html +0 -32
  190. package/examples/pages.lango +0 -174
  191. package/examples/server.lango +0 -189
  192. package/examples/worker.lango +0 -142
  193. package/src/application.lango +0 -327
  194. package/src/browser_host.lango +0 -276
  195. package/src/coordinator.lango +0 -57
  196. package/src/demo.lango +0 -110
  197. package/src/demo_controls.lango +0 -53
  198. package/src/errors.lango +0 -149
  199. package/src/errors_test.lango +0 -157
  200. package/src/form_state.lango +0 -168
  201. package/src/heartbeat_test.lango +0 -479
  202. package/src/inheritance.lango +0 -167
  203. package/src/input_values.lango +0 -37
  204. package/src/logout_test.lango +0 -564
  205. package/src/navigation_test.lango +0 -556
  206. package/src/presentation.lango +0 -55
  207. package/src/protocol.lango +0 -787
  208. package/src/renderer_test.lango +0 -2047
  209. package/src/session.lango +0 -343
  210. package/src/session_test.lango +0 -455
  211. package/src/tabs_test.lango +0 -216
  212. package/src/tokens.lango +0 -215
  213. package/template/.vscode/extensions.json +0 -3
  214. package/template/.vscode/settings.json +0 -9
  215. package/template/README.md +0 -44
  216. package/template/gitignore +0 -4
  217. package/template/package.json +0 -22
  218. package/template/public/app.css +0 -10
  219. package/template/public/index.html +0 -24
  220. package/template/src/client.lango +0 -78
  221. package/template/src/pages.lango +0 -55
  222. package/template/src/server.lango +0 -24
  223. package/template/src/worker.lango +0 -77
  224. package/template/test/app.lango +0 -9
  225. package/tools/browser_runner.lango +0 -32
  226. package/tools/browser_test.lango +0 -343
  227. package/tools/create_app.lango +0 -88
  228. package/tools/create_app_test.lango +0 -43
  229. package/tools/starter_test.lango +0 -227
  230. /package/{dist/node → cli}/.lango/bignumber.mjs +0 -0
  231. /package/{dist → cli}/.lango/xmldom/conventions.js +0 -0
  232. /package/{dist → cli}/.lango/xmldom/dom-parser.js +0 -0
  233. /package/{dist → cli}/.lango/xmldom/dom.js +0 -0
  234. /package/{dist → cli}/.lango/xmldom/entities.js +0 -0
  235. /package/{dist → cli}/.lango/xmldom/errors.js +0 -0
  236. /package/{dist → cli}/.lango/xmldom/grammar.js +0 -0
  237. /package/{dist → cli}/.lango/xmldom/index.js +0 -0
  238. /package/{dist → cli}/.lango/xmldom/package.json +0 -0
  239. /package/{dist → cli}/.lango/xmldom/sax.js +0 -0
  240. /package/{dist → cli}/.lango/xmldom.LICENSE.md +0 -0
@@ -0,0 +1,1052 @@
1
+ import { measure } from "./dimensions.mjs";
2
+ import { TableScope } from "./table_scope.mjs";
3
+ import { Control } from "./control.mjs";
4
+ import { Form } from "./form.mjs";
5
+ import { cloneMarkup } from "./templates.mjs";
6
+ import { appendContent, bindAction, decorate } from "./content.mjs";
7
+ import {
8
+ hostGlobal as __hostGlobal,
9
+ hostGlobalCall as __hostGlobalCall,
10
+ xmlEscape as __xmlEscape,
11
+ getClass as __getClass,
12
+ isKindof as __isKindof,
13
+ isNumber as __isNumber,
14
+ isString as __isString,
15
+ isBool as __isBool,
16
+ isObject as __isObject,
17
+ isArray as __isArray,
18
+ includes as __includes,
19
+ entries as __entries,
20
+ add as __add,
21
+ remove as __remove,
22
+ requireBoolean as __requireBoolean,
23
+ normalize as __normalize,
24
+ finite as __finite,
25
+ numericAdd as __numericAdd,
26
+ call as __call,
27
+ boundary as __boundary,
28
+ requireArity as __requireArity,
29
+ withArity as __withArity,
30
+ } from "./.lango/runtime.mjs";
31
+
32
+ export class Table extends Control {
33
+ rows;
34
+ columns;
35
+ #renderer;
36
+ #props;
37
+ #building;
38
+ #mode;
39
+ #layout;
40
+ #lookup;
41
+ #header;
42
+ #aliases;
43
+ #table;
44
+ #body;
45
+ #template;
46
+ constructor(form, props, renderer) {
47
+ super(form, props, cloneMarkup("table", ["<div class=\"table-responsive\"><table class=\"table\"><colgroup></colgroup><tbody></tbody></table></div>"].join("")));
48
+ __requireArity(arguments.length, [0, 1, 2], "constructor");
49
+ form = __boundary(form);
50
+ props = __boundary(props);
51
+ renderer = __boundary(renderer);
52
+ this.#renderer = renderer;
53
+ this.#props = props;
54
+ this.#building = true;
55
+ this.#mode = __normalize(props.valueMode);
56
+ if (__requireBoolean(__normalize(this.#mode) === null)) {
57
+ this.#mode = "none";
58
+ }
59
+ let modes = ["none", "cells", "rows", "mixed"];
60
+ if (__requireBoolean(!__requireBoolean(__normalize(modes.includes(__normalize(this.#mode)))))) {
61
+ throw "Table valueMode must be none, cells, rows or mixed";
62
+ }
63
+ this.#layout = new TableScope(form);
64
+ this.#lookup = new TableScope(form);
65
+ this.rows = [];
66
+ this.columns = [];
67
+ this.#header = null;
68
+ this.#aliases = __normalize(__hostGlobal(["Object"]).create(null));
69
+ this.#table = __normalize(this.element.firstElementChild);
70
+ this.#body = __normalize(this.#table.lastElementChild);
71
+ this.#template = __normalize(props.rowTemplate);
72
+ if (__requireBoolean(__requireBoolean(__normalize(this.#template) !== null) && __requireBoolean(__normalize(this.#template.type) !== "tableRowTemplate"))) {
73
+ throw "Table rowTemplate requires a TableRowTemplate";
74
+ }
75
+ let table = __normalize(this.#table);
76
+ let group = __normalize(table.firstElementChild);
77
+ let headings = [];
78
+ let hasCaptions = false;
79
+ try {
80
+ if (__requireBoolean(__normalize(props.stripedRows) === true)) {
81
+ __add(table.classList, "table-striped");
82
+ }
83
+ if (__requireBoolean(__normalize(props.stripedColumns) === true)) {
84
+ __add(table.classList, "table-striped-columns");
85
+ }
86
+ if (__requireBoolean(__normalize(props.hoverableRows) === true)) {
87
+ __add(table.classList, "table-hover");
88
+ }
89
+ if (__requireBoolean(__normalize(props.small) === true)) {
90
+ __add(table.classList, "table-sm");
91
+ }
92
+ if (__requireBoolean(__requireBoolean(__normalize(props.border) !== null) && __requireBoolean(__normalize(props.border) !== false))) {
93
+ __add(table.classList, "table-bordered");
94
+ if (__requireBoolean(__isObject(__normalize(props.border)))) {
95
+ if (__requireBoolean(props.border.color !== null)) {
96
+ __normalize(table.style.setProperty("--bs-table-border-color", props.border.color));
97
+ }
98
+ if (__requireBoolean(props.border.width !== null)) {
99
+ __normalize(table.style.setProperty("--bs-border-width", `${props.border.width}px`));
100
+ }
101
+ }
102
+ }
103
+ if (__requireBoolean(__normalize(props.caption) !== null)) {
104
+ let caption = __normalize(__hostGlobal(["document"]).createElement("caption"));
105
+ appendContent(__normalize(this.#layout), caption, __normalize(props.caption), renderer);
106
+ __normalize(table.prepend(caption));
107
+ }
108
+ if (__requireBoolean(__normalize(props.aria) !== null)) {
109
+ for (const [name, value] of __entries(__normalize(props.aria))) {
110
+ __normalize(table.setAttribute(`aria-${name}`, value));
111
+ }
112
+ }
113
+ if (__requireBoolean(__normalize(props.controls) !== null)) {
114
+ for (const definition of __normalize(props.controls)) {
115
+ if (__normalize(definition.type) === "tableCol") {
116
+ let col = new TableCol(__normalize(this.#layout), definition);
117
+ __normalize(this.#layout.register(null, col));
118
+ col.name = __normalize(definition.name);
119
+ if (__requireBoolean(__normalize(col.name) !== null)) {
120
+ for (const previous of __normalize(this.columns)) {
121
+ if (__requireBoolean(__normalize(previous.name) === __normalize(col.name))) {
122
+ throw `Duplicate column name: ${__normalize(col.name)}`;
123
+ }
124
+ }
125
+ }
126
+ this.columns.push(col);
127
+ headings.push({ type: "tableCell", colSpan: __normalize(definition.colSpan), controls: __normalize(definition.caption) });
128
+ if (__requireBoolean(__normalize(definition.caption) !== null)) {
129
+ hasCaptions = true;
130
+ }
131
+ __normalize(group.appendChild(__normalize(col.element)));
132
+ } else if (__normalize(definition.type) === "tableHeader") {
133
+ if (__requireBoolean(__normalize(this.#header) !== null)) {
134
+ throw "Table accepts one TableHeader";
135
+ }
136
+ this.#header = new TableHeader(__normalize(this.#layout), definition, renderer);
137
+ __normalize(this.#layout.register(__normalize(definition.name), __normalize(this.#header)));
138
+ __normalize(table.insertBefore(__normalize(this.#header.element), __normalize(this.#body)));
139
+ } else if (__normalize(definition.type) === "tableRow") {
140
+ let row = new TableRow(form, definition, renderer, false);
141
+ this.rows.push(row);
142
+ __normalize(this.#body.appendChild(__normalize(row.element)));
143
+ } else if (__normalize(definition.type) === "tableDivider") {
144
+ let divider = new TableDivider(__normalize(this.#layout), definition);
145
+ __normalize(this.#layout.register(__normalize(definition.name), divider));
146
+ __normalize(this.#body.appendChild(__normalize(divider.element)));
147
+ } else {
148
+ throw `Unsupported Table child: ${__normalize(definition.type)}`;
149
+ }
150
+ }
151
+ }
152
+ if (__requireBoolean(__requireBoolean(__normalize(this.#header) === null) && __requireBoolean(hasCaptions))) {
153
+ let generated = { controls: [{ type: "tableRow", controls: headings }] };
154
+ this.#header = new TableHeader(__normalize(this.#layout), generated, renderer);
155
+ __normalize(this.#layout.register(null, __normalize(this.#header)));
156
+ __normalize(table.insertBefore(__normalize(this.#header.element), __normalize(this.#body)));
157
+ }
158
+ let width = 1;
159
+ for (const row of __normalize(this.rows)) {
160
+ width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
161
+ }
162
+ for (const child of __normalize(this.#layout.owned)) {
163
+ if (__requireBoolean(__isKindof(child, TableDivider))) {
164
+ applySpan(child.element.firstElementChild, "colspan", width);
165
+ }
166
+ }
167
+ if (__requireBoolean(__normalize(props.value) !== null)) {
168
+ this.setValue(__normalize(props.value));
169
+ } else {
170
+ this.publish(this.names(__normalize(this.rows)));
171
+ this.resize(__normalize(this.rows));
172
+ }
173
+ this.#building = false;
174
+ } catch (error) {
175
+ this.dispose();
176
+ throw error;
177
+ }
178
+ }
179
+ find(name) {
180
+ __requireArity(arguments.length, [0], "find");
181
+ name = __boundary(name);
182
+ return __normalize(this.#lookup.find(name));
183
+ return null;
184
+ }
185
+ names(rows, replace = false) {
186
+ __requireArity(arguments.length, [0], "names");
187
+ rows = __boundary(rows);
188
+ replace = __boundary(replace);
189
+ let result = __normalize(__hostGlobal(["Object"]).create(null));
190
+ for (const [name, control] of __entries(__normalize(this.#layout.controls))) {
191
+ if (__requireBoolean(__requireBoolean(!__requireBoolean(replace)) || __requireBoolean(!__requireBoolean(__isKindof(control, TableDivider))))) {
192
+ addName(result, name, control);
193
+ }
194
+ }
195
+ let sources = __normalize(rows.slice());
196
+ if (__requireBoolean(__normalize(this.#header) !== null)) {
197
+ for (const row of __normalize(this.#header.rows)) {
198
+ __add(sources, row);
199
+ }
200
+ }
201
+ for (const row of sources) {
202
+ addName(result, __normalize(row.name), row);
203
+ for (const cell of __normalize(row.cells)) {
204
+ if (__requireBoolean(__normalize(cell.name) !== null)) {
205
+ addName(result, __normalize(cell.name), cell);
206
+ } else {
207
+ if (__requireBoolean(!__requireBoolean(__normalize(row.generated)))) {
208
+ for (const [name, control] of __entries(cell.scope.controls)) {
209
+ addName(result, name, control);
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ return result;
216
+ return null;
217
+ }
218
+ publish(names) {
219
+ __requireArity(arguments.length, [0], "publish");
220
+ names = __boundary(names);
221
+ if (__requireBoolean(__normalize(this.#props.name) === null)) {
222
+ for (const [name, control] of __entries(names)) {
223
+ if (__requireBoolean(__requireBoolean(__includes(name, __normalize(this.form.controls))) && __requireBoolean(__normalize(this.form.controls[name]) !== __normalize(this.#aliases[name])))) {
224
+ throw `Invalid or duplicate control name: ${name}`;
225
+ }
226
+ }
227
+ for (const [name, control] of __entries(__normalize(this.#aliases))) {
228
+ if (__requireBoolean(__normalize(this.form.controls[name]) === control)) {
229
+ __normalize(__hostGlobal(["Reflect"]).deleteProperty(__normalize(this.form.controls), name));
230
+ }
231
+ }
232
+ for (const [name, control] of __entries(names)) {
233
+ this.form.controls[name] = control;
234
+ }
235
+ this.#aliases = names;
236
+ }
237
+ this.#lookup.controls = names;
238
+ return null;
239
+ return null;
240
+ }
241
+ getValue() {
242
+ if (__requireBoolean(__normalize(this.#mode) === "none")) {
243
+ return null;
244
+ }
245
+ if (__requireBoolean(__normalize(this.#mode) === "cells")) {
246
+ return __normalize(this.#lookup.getValue());
247
+ }
248
+ let rows = [];
249
+ for (const row of __normalize(this.rows)) {
250
+ rows.push(__normalize(row.getRowValue(__normalize(this.columns))));
251
+ }
252
+ if (__requireBoolean(__normalize(this.#mode) === "rows")) {
253
+ return rows;
254
+ }
255
+ return { cells: __normalize(this.#lookup.getValue()), rows: rows };
256
+ return null;
257
+ }
258
+ prepareValue() {
259
+ let pending = [];
260
+ let ready = __normalize(this.#layout.prepareValue());
261
+ if (__requireBoolean(ready !== null)) {
262
+ pending.push(ready);
263
+ }
264
+ for (const row of __normalize(this.rows)) {
265
+ ready = __normalize(row.prepareValue());
266
+ if (__requireBoolean(ready !== null)) {
267
+ pending.push(ready);
268
+ }
269
+ }
270
+ return allReady(pending);
271
+ return null;
272
+ }
273
+ clearValidation() {
274
+ super.clearValidation();
275
+ if (__requireBoolean(__normalize(this.#layout) !== null)) {
276
+ __normalize(this.#layout.clearValidation());
277
+ }
278
+ if (__requireBoolean(__normalize(this.rows) !== null)) {
279
+ for (const row of __normalize(this.rows)) {
280
+ __normalize(row.clearValidation());
281
+ }
282
+ }
283
+ return null;
284
+ return null;
285
+ }
286
+ createRow(value) {
287
+ __requireArity(arguments.length, [0], "createRow");
288
+ value = __boundary(value);
289
+ rowValue(value);
290
+ let definition = null;
291
+ if (__requireBoolean(__normalize(this.#template) !== null)) {
292
+ definition = __hostGlobalCall(["structuredClone"], __normalize(this.#template));
293
+ } else {
294
+ let cells = [];
295
+ for (const column of __normalize(this.columns)) {
296
+ cells.push({ type: "tableCell", colSpan: __normalize(column.span) });
297
+ }
298
+ definition = { controls: cells };
299
+ }
300
+ let row = new TableRow(__normalize(this.form), definition, __normalize(this.#renderer), false);
301
+ row.generated = true;
302
+ try {
303
+ __normalize(row.setRowValue(value, __normalize(this.columns)));
304
+ } catch (error) {
305
+ __normalize(row.dispose());
306
+ throw error;
307
+ }
308
+ return row;
309
+ return null;
310
+ }
311
+ setValue(values) {
312
+ __requireArity(arguments.length, [0], "setValue");
313
+ values = __boundary(values);
314
+ if (__requireBoolean(values === null)) {
315
+ values = [];
316
+ }
317
+ if (__requireBoolean(!__requireBoolean(__isArray(values)))) {
318
+ throw "Table value must be an array of row maps";
319
+ }
320
+ let staged = [];
321
+ try {
322
+ for (const value of values) {
323
+ staged.push(this.createRow(value));
324
+ }
325
+ let next = this.names(staged, true);
326
+ validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
327
+ this.publish(next);
328
+ } catch (error) {
329
+ for (const row of staged) {
330
+ __normalize(row.dispose());
331
+ }
332
+ throw error;
333
+ }
334
+ if (__requireBoolean(!__requireBoolean(__normalize(this.#building)))) {
335
+ __normalize(this.form.clearResources());
336
+ }
337
+ for (const row of __normalize(this.rows)) {
338
+ __normalize(row.dispose());
339
+ }
340
+ this.rows = staged;
341
+ __normalize(this.#body.replaceChildren());
342
+ for (const child of __normalize(this.#layout.owned.slice())) {
343
+ if (__requireBoolean(__isKindof(child, TableDivider))) {
344
+ __normalize(this.#layout.unregister(child));
345
+ __normalize(child.dispose());
346
+ }
347
+ }
348
+ for (const row of staged) {
349
+ __normalize(this.#body.appendChild(__normalize(row.element)));
350
+ }
351
+ this.resize(staged);
352
+ return this;
353
+ return null;
354
+ }
355
+ addRow(value = null) {
356
+ value = __boundary(value);
357
+ return this.insertRow(__normalize(this.rows.length), value);
358
+ return null;
359
+ }
360
+ insertRow(beforeIndex, value = null) {
361
+ __requireArity(arguments.length, [0], "insertRow");
362
+ beforeIndex = __boundary(beforeIndex);
363
+ value = __boundary(value);
364
+ tableIndex(beforeIndex, __normalize(this.rows.length), true);
365
+ let row = this.createRow(value);
366
+ let staged = __normalize(this.rows.slice());
367
+ __normalize(staged.splice(beforeIndex, 0, row));
368
+ try {
369
+ let next = this.names(staged);
370
+ validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
371
+ this.publish(next);
372
+ } catch (error) {
373
+ __normalize(row.dispose());
374
+ throw error;
375
+ }
376
+ __normalize(this.form.clearResources());
377
+ let anchor = null;
378
+ if (__requireBoolean(beforeIndex < __normalize(this.rows.length))) {
379
+ anchor = __normalize(__normalize(this.rows[beforeIndex]).element);
380
+ }
381
+ __normalize(this.#body.insertBefore(__normalize(row.element), anchor));
382
+ this.rows = staged;
383
+ this.resize(staged);
384
+ return this;
385
+ return null;
386
+ }
387
+ deleteRow(index) {
388
+ __requireArity(arguments.length, [0], "deleteRow");
389
+ index = __boundary(index);
390
+ tableIndex(index, __normalize(this.rows.length));
391
+ let staged = __normalize(this.rows.slice());
392
+ let row = __normalize(__normalize(staged.splice(index, 1))[0]);
393
+ validateBoundaries(__normalize(this.#header), staged, __normalize(this.columns));
394
+ this.publish(this.names(staged));
395
+ __normalize(this.form.clearResources());
396
+ __normalize(row.dispose());
397
+ __remove(row.element);
398
+ this.rows = staged;
399
+ this.resize(staged);
400
+ return this;
401
+ return null;
402
+ }
403
+ setRowValue(index, value) {
404
+ __requireArity(arguments.length, [0, 1], "setRowValue");
405
+ index = __boundary(index);
406
+ value = __boundary(value);
407
+ tableIndex(index, __normalize(this.rows.length));
408
+ __normalize(__normalize(this.rows[index]).setRowValue(value, __normalize(this.columns)));
409
+ return this;
410
+ return null;
411
+ }
412
+ setRowData(index, value) {
413
+ __requireArity(arguments.length, [0, 1], "setRowData");
414
+ index = __boundary(index);
415
+ value = __boundary(value);
416
+ tableIndex(index, __normalize(this.rows.length));
417
+ let row = __normalize(this.rows[index]);
418
+ row.data = __hostGlobalCall(["structuredClone"], value);
419
+ return this;
420
+ return null;
421
+ }
422
+ setCellValue(index, column, value) {
423
+ __requireArity(arguments.length, [0, 1, 2], "setCellValue");
424
+ index = __boundary(index);
425
+ column = __boundary(column);
426
+ value = __boundary(value);
427
+ tableIndex(index, __normalize(this.rows.length));
428
+ let selected = columnIndex(column, __normalize(this.columns));
429
+ let row = __normalize(this.rows[index]);
430
+ tableIndex(selected, row.cells.length);
431
+ __normalize(row.cells[selected].setValue(value));
432
+ return this;
433
+ return null;
434
+ }
435
+ resize(rows) {
436
+ __requireArity(arguments.length, [0], "resize");
437
+ rows = __boundary(rows);
438
+ let width = 1;
439
+ for (const row of rows) {
440
+ width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
441
+ }
442
+ if (__requireBoolean(__normalize(this.#header) !== null)) {
443
+ for (const row of __normalize(this.#header.rows)) {
444
+ width = __normalize(__hostGlobal(["Math"]).max(width, __normalize(row.width)));
445
+ }
446
+ }
447
+ for (const child of __normalize(this.#layout.owned)) {
448
+ if (__requireBoolean(__isKindof(child, TableDivider))) {
449
+ applySpan(child.element.firstElementChild, "colspan", width);
450
+ }
451
+ }
452
+ for (const col of __normalize(this.columns)) {
453
+ __normalize(col.detach());
454
+ }
455
+ let first = validateBoundaries(__normalize(this.#header), rows, __normalize(this.columns));
456
+ if (__requireBoolean(first !== null)) {
457
+ let offset = 0;
458
+ for (const col of __normalize(this.columns)) {
459
+ offset = __numericAdd(offset, __normalize(col.span));
460
+ if (__requireBoolean(__normalize(col.resize))) {
461
+ __normalize(col.attach(__normalize(first.boundary(offset)), __normalize(this.#table)));
462
+ }
463
+ }
464
+ }
465
+ return null;
466
+ return null;
467
+ }
468
+ dispose() {
469
+ if (__requireBoolean(__normalize(this.#aliases) !== null)) {
470
+ for (const [name, control] of __entries(__normalize(this.#aliases))) {
471
+ if (__requireBoolean(__normalize(this.form.controls[name]) === control)) {
472
+ __normalize(__hostGlobal(["Reflect"]).deleteProperty(__normalize(this.form.controls), name));
473
+ }
474
+ }
475
+ this.#aliases = __normalize(__hostGlobal(["Object"]).create(null));
476
+ }
477
+ if (__requireBoolean(__normalize(this.rows) !== null)) {
478
+ for (const row of __normalize(this.rows)) {
479
+ __normalize(row.dispose());
480
+ }
481
+ this.rows = [];
482
+ }
483
+ if (__requireBoolean(__normalize(this.#layout) !== null)) {
484
+ __normalize(this.#layout.dispose());
485
+ }
486
+ return super.dispose();
487
+ return null;
488
+ }
489
+ }
490
+
491
+ export class TableHeader extends Control {
492
+ rows;
493
+ constructor(form, props, renderer) {
494
+ super(form, props, cloneMarkup("table-header", ["<thead></thead>"].join("")));
495
+ __requireArity(arguments.length, [0, 1, 2], "constructor");
496
+ form = __boundary(form);
497
+ props = __boundary(props);
498
+ renderer = __boundary(renderer);
499
+ decorate(this, props);
500
+ this.rows = [];
501
+ try {
502
+ if (__requireBoolean(__normalize(props.controls) !== null)) {
503
+ for (const definition of __normalize(props.controls)) {
504
+ if (__requireBoolean(__normalize(definition.type) !== "tableRow")) {
505
+ throw "TableHeader accepts TableRow definitions";
506
+ }
507
+ let row = new TableRow(form, definition, renderer, true);
508
+ this.rows.push(row);
509
+ __normalize(this.element.appendChild(__normalize(row.element)));
510
+ }
511
+ }
512
+ } catch (error) {
513
+ this.dispose();
514
+ throw error;
515
+ }
516
+ }
517
+ prepareValue() {
518
+ let pending = [];
519
+ for (const row of __normalize(this.rows)) {
520
+ let ready = __normalize(row.prepareValue());
521
+ if (__requireBoolean(ready !== null)) {
522
+ pending.push(ready);
523
+ }
524
+ }
525
+ return allReady(pending);
526
+ return null;
527
+ }
528
+ clearValidation() {
529
+ super.clearValidation();
530
+ if (__requireBoolean(__normalize(this.rows) !== null)) {
531
+ for (const row of __normalize(this.rows)) {
532
+ __normalize(row.clearValidation());
533
+ }
534
+ }
535
+ return null;
536
+ return null;
537
+ }
538
+ dispose() {
539
+ for (const row of __normalize(this.rows)) {
540
+ __normalize(row.dispose());
541
+ }
542
+ this.rows = [];
543
+ return super.dispose();
544
+ return null;
545
+ }
546
+ }
547
+
548
+ export class TableRow extends Control {
549
+ name;
550
+ data;
551
+ generated;
552
+ width;
553
+ cells;
554
+ #scope;
555
+ constructor(form, props, renderer, heading) {
556
+ super(form, props, cloneMarkup("table-row", ["<tr></tr>"].join("")));
557
+ __requireArity(arguments.length, [0, 1, 2, 3], "constructor");
558
+ form = __boundary(form);
559
+ props = __boundary(props);
560
+ renderer = __boundary(renderer);
561
+ heading = __boundary(heading);
562
+ decorate(this, props);
563
+ this.name = __normalize(props.name);
564
+ this.data = __hostGlobalCall(["structuredClone"], __normalize(props.data));
565
+ this.generated = false;
566
+ this.width = 0;
567
+ this.cells = [];
568
+ this.#scope = new TableScope(form);
569
+ try {
570
+ if (__requireBoolean(__normalize(props.controls) !== null)) {
571
+ for (const definition of __normalize(props.controls)) {
572
+ if (__requireBoolean(__normalize(definition.type) !== "tableCell")) {
573
+ throw "TableRow accepts TableCell definitions";
574
+ }
575
+ let cell = new TableCell(__normalize(this.#scope), definition, renderer, heading);
576
+ __normalize(this.#scope.register(__normalize(definition.name), cell));
577
+ this.cells.push(cell);
578
+ this.width = __numericAdd(__normalize(this.width), cell.element.colSpan);
579
+ __normalize(this.element.appendChild(__normalize(cell.element)));
580
+ }
581
+ }
582
+ bindAction(this, __normalize(this.element), __normalize(props.url));
583
+ } catch (error) {
584
+ this.dispose();
585
+ throw error;
586
+ }
587
+ }
588
+ boundary(column) {
589
+ __requireArity(arguments.length, [0], "boundary");
590
+ column = __boundary(column);
591
+ let offset = 0;
592
+ for (const cell of __normalize(this.cells)) {
593
+ offset = __numericAdd(offset, cell.element.colSpan);
594
+ if (__requireBoolean(offset === column)) {
595
+ return __normalize(cell.element);
596
+ }
597
+ }
598
+ return null;
599
+ return null;
600
+ }
601
+ setRowValue(value, columns) {
602
+ __requireArity(arguments.length, [0, 1], "setRowValue");
603
+ value = __boundary(value);
604
+ columns = __boundary(columns);
605
+ rowValue(value);
606
+ for (const [index, cell] of __entries(__normalize(this.cells))) {
607
+ let name = __normalize(cell.name);
608
+ if (__requireBoolean(index < __normalize(columns.length))) {
609
+ name = __normalize(__normalize(columns[index]).name);
610
+ }
611
+ let field = null;
612
+ if (__requireBoolean(__requireBoolean(__requireBoolean(value !== null) && __requireBoolean(name !== null)) && __requireBoolean(__normalize(__hostGlobal(["Object"]).hasOwn(value, name))))) {
613
+ field = __normalize(value[name]);
614
+ }
615
+ __normalize(cell.setValue(field));
616
+ }
617
+ return this;
618
+ return null;
619
+ }
620
+ getRowValue(columns) {
621
+ __requireArity(arguments.length, [0], "getRowValue");
622
+ columns = __boundary(columns);
623
+ let result = __normalize(__hostGlobal(["Object"]).create(null));
624
+ for (const [index, cell] of __entries(__normalize(this.cells))) {
625
+ let name = __normalize(cell.name);
626
+ if (__requireBoolean(index < __normalize(columns.length))) {
627
+ name = __normalize(__normalize(columns[index]).name);
628
+ }
629
+ if (__requireBoolean(name !== null)) {
630
+ if (__requireBoolean(__includes(name, result))) {
631
+ throw `Duplicate row value name: ${name}`;
632
+ }
633
+ result[name] = __normalize(cell.getValue());
634
+ }
635
+ }
636
+ return result;
637
+ return null;
638
+ }
639
+ getValue() {
640
+ return __normalize(this.#scope.getValue());
641
+ return null;
642
+ }
643
+ prepareValue() {
644
+ return __normalize(this.#scope.prepareValue());
645
+ return null;
646
+ }
647
+ clearValidation() {
648
+ super.clearValidation();
649
+ if (__requireBoolean(__normalize(this.#scope) !== null)) {
650
+ __normalize(this.#scope.clearValidation());
651
+ }
652
+ return null;
653
+ return null;
654
+ }
655
+ dispose() {
656
+ if (__requireBoolean(__normalize(this.#scope) !== null)) {
657
+ __normalize(this.#scope.dispose());
658
+ }
659
+ return super.dispose();
660
+ return null;
661
+ }
662
+ }
663
+
664
+ export class TableCell extends Control {
665
+ name;
666
+ scope;
667
+ constructor(form, props, renderer, heading) {
668
+ super(form, props, cellElement(heading));
669
+ __requireArity(arguments.length, [0, 1, 2, 3], "constructor");
670
+ form = __boundary(form);
671
+ props = __boundary(props);
672
+ renderer = __boundary(renderer);
673
+ heading = __boundary(heading);
674
+ this.name = __normalize(props.name);
675
+ this.scope = new TableScope(form);
676
+ try {
677
+ applySpan(__normalize(this.element), "colspan", __normalize(props.colSpan));
678
+ applySpan(__normalize(this.element), "rowspan", __normalize(props.rowSpan));
679
+ if (__requireBoolean(__normalize(props.verticalAlignment) !== null)) {
680
+ this.element.style.verticalAlign = __normalize(props.verticalAlignment);
681
+ }
682
+ if (__requireBoolean(__normalize(props.horizontalAlignment) !== null)) {
683
+ this.element.style.textAlign = __normalize(props.horizontalAlignment);
684
+ }
685
+ appendContent(__normalize(this.scope), __normalize(this.element), __normalize(props.controls), renderer);
686
+ decorate(this, props);
687
+ bindAction(this, __normalize(this.element), __normalize(props.url));
688
+ } catch (error) {
689
+ this.dispose();
690
+ throw error;
691
+ }
692
+ }
693
+ find(name) {
694
+ __requireArity(arguments.length, [0], "find");
695
+ name = __boundary(name);
696
+ return __normalize(this.scope.find(name));
697
+ return null;
698
+ }
699
+ getValue() {
700
+ if (__requireBoolean(__normalize(this.scope.owned.length) === 0)) {
701
+ return null;
702
+ }
703
+ if (__requireBoolean(__normalize(this.scope.owned.length) === 1)) {
704
+ return __normalize(__normalize(this.scope.owned[0]).getValue());
705
+ }
706
+ return __normalize(this.scope.getValue());
707
+ return null;
708
+ }
709
+ setValue(value) {
710
+ __requireArity(arguments.length, [0], "setValue");
711
+ value = __boundary(value);
712
+ if (__requireBoolean(__normalize(this.scope.owned.length) === 0)) {
713
+ let text = "";
714
+ if (__requireBoolean(value !== null)) {
715
+ if (__requireBoolean(__requireBoolean(__isObject(value)) || __requireBoolean(__isArray(value)))) {
716
+ text = __normalize(__hostGlobal(["JSON"]).stringify(value));
717
+ } else {
718
+ text = `${value}`;
719
+ }
720
+ }
721
+ let handle = __normalize(this.element.querySelector(":scope > .lango-col-resize"));
722
+ this.element.textContent = text;
723
+ if (__requireBoolean(handle !== null)) {
724
+ __normalize(this.element.appendChild(handle));
725
+ }
726
+ } else {
727
+ if (__requireBoolean(value === null)) {
728
+ for (const control of __normalize(this.scope.owned)) {
729
+ clearValue(control);
730
+ }
731
+ } else {
732
+ if (__requireBoolean(__normalize(this.scope.owned.length) === 1)) {
733
+ __normalize(__normalize(this.scope.owned[0]).setValue(value));
734
+ } else {
735
+ __normalize(this.scope.setValue(value));
736
+ }
737
+ }
738
+ }
739
+ return this;
740
+ return null;
741
+ }
742
+ prepareValue() {
743
+ return __normalize(this.scope.prepareValue());
744
+ return null;
745
+ }
746
+ clearValidation() {
747
+ super.clearValidation();
748
+ if (__requireBoolean(__normalize(this.scope) !== null)) {
749
+ __normalize(this.scope.clearValidation());
750
+ }
751
+ return null;
752
+ return null;
753
+ }
754
+ dispose() {
755
+ if (__requireBoolean(__normalize(this.scope) !== null)) {
756
+ __normalize(this.scope.dispose());
757
+ }
758
+ return super.dispose();
759
+ return null;
760
+ }
761
+ }
762
+
763
+ export class TableDivider extends Control {
764
+ constructor(form, props) {
765
+ super(form, props, cloneMarkup("table-divider", ["<tr class=\"lango-table-divider\" aria-hidden=\"true\"><td><hr /></td></tr>"].join("")));
766
+ __requireArity(arguments.length, [0, 1], "constructor");
767
+ form = __boundary(form);
768
+ props = __boundary(props);
769
+ decorate(this, props);
770
+ }
771
+ }
772
+
773
+ export class TableCol extends Control {
774
+ name;
775
+ span;
776
+ resize;
777
+ #handle;
778
+ constructor(form, props) {
779
+ super(form, props, cloneMarkup("table-col", ["<col />"].join("")));
780
+ __requireArity(arguments.length, [0, 1], "constructor");
781
+ form = __boundary(form);
782
+ props = __boundary(props);
783
+ decorate(this, props);
784
+ this.span = spanValue(__normalize(props.colSpan));
785
+ this.resize = __normalize(props.resize) === true;
786
+ applySpan(__normalize(this.element), "span", __normalize(this.span));
787
+ let width = columnWidth(__normalize(props.width));
788
+ if (__requireBoolean(width !== null)) {
789
+ this.element.style.width = width;
790
+ }
791
+ }
792
+ size(width) {
793
+ __requireArity(arguments.length, [0], "size");
794
+ width = __boundary(width);
795
+ if (__requireBoolean(width < 24)) {
796
+ width = 24;
797
+ }
798
+ let ruler = __normalize(__hostGlobal(["document"]).createElement("span"));
799
+ ruler.textContent = "0";
800
+ let font = __hostGlobalCall(["getComputedStyle"], __normalize(this.element));
801
+ ruler.style.font = __normalize(font.font);
802
+ ruler.style.position = "absolute";
803
+ ruler.style.visibility = "hidden";
804
+ __normalize(__hostGlobal(["document"]).body.appendChild(ruler));
805
+ let unit = __normalize(__normalize(ruler.getBoundingClientRect()).width);
806
+ __remove(ruler);
807
+ this.element.style.width = `${__finite(width / unit)}ch`;
808
+ __normalize(this.#handle.setAttribute("aria-valuenow", `${width}`));
809
+ return null;
810
+ return null;
811
+ }
812
+ attach(cell, table) {
813
+ __requireArity(arguments.length, [0, 1], "attach");
814
+ cell = __boundary(cell);
815
+ table = __boundary(table);
816
+ let handle = __normalize(__hostGlobal(["document"]).createElement("button"));
817
+ handle.type = "button";
818
+ handle.className = "lango-col-resize";
819
+ __normalize(handle.setAttribute("role", "separator"));
820
+ __normalize(handle.setAttribute("aria-orientation", "vertical"));
821
+ __normalize(handle.setAttribute("aria-label", "↔"));
822
+ __normalize(handle.setAttribute("aria-valuemin", "24"));
823
+ __normalize(handle.setAttribute("aria-valuenow", "24"));
824
+ this.#handle = handle;
825
+ __add(cell.classList, "lango-resizable-cell");
826
+ __normalize(cell.appendChild(handle));
827
+ let drag = { active: false, x: 0, width: 0 };
828
+ let down = __withArity((event) => {
829
+ event = __boundary(event);
830
+ if (__requireBoolean(__requireBoolean(__normalize(event.button) !== 0) || __requireBoolean(__normalize(drag.active)))) {
831
+ return null;
832
+ }
833
+ __normalize(event.preventDefault());
834
+ drag.active = true;
835
+ drag.x = __normalize(event.clientX);
836
+ drag.width = __finite(__normalize(__normalize(this.element.getBoundingClientRect()).width) / __normalize(this.span));
837
+ let style = __normalize(table.style);
838
+ style.tableLayout = "fixed";
839
+ __normalize(handle.setPointerCapture(__normalize(event.pointerId)));
840
+ return null;
841
+ }, [0], "closure");
842
+ let move = __withArity((event) => {
843
+ event = __boundary(event);
844
+ if (__requireBoolean(__normalize(drag.active))) {
845
+ this.size(__numericAdd(__normalize(drag.width), __finite(__finite(__normalize(event.clientX) - __normalize(drag.x)) / __normalize(this.span))));
846
+ }
847
+ return null;
848
+ }, [0], "closure");
849
+ let up = __withArity((event) => {
850
+ event = __boundary(event);
851
+ if (__requireBoolean(__normalize(drag.active))) {
852
+ drag.active = false;
853
+ }
854
+ return null;
855
+ }, [0], "closure");
856
+ let key = __withArity((event) => {
857
+ event = __boundary(event);
858
+ if (__requireBoolean(__requireBoolean(__normalize(event.key) !== "ArrowLeft") && __requireBoolean(__normalize(event.key) !== "ArrowRight"))) {
859
+ return null;
860
+ }
861
+ __normalize(event.preventDefault());
862
+ let style = __normalize(table.style);
863
+ style.tableLayout = "fixed";
864
+ let step = 10;
865
+ if (__requireBoolean(__normalize(event.key) === "ArrowLeft")) {
866
+ step = __finite(-10);
867
+ }
868
+ this.size(__numericAdd(__finite(__normalize(__normalize(this.element.getBoundingClientRect()).width) / __normalize(this.span)), step));
869
+ return null;
870
+ }, [0], "closure");
871
+ __normalize(handle.addEventListener("pointerdown", down));
872
+ __normalize(handle.addEventListener("pointermove", move));
873
+ __normalize(handle.addEventListener("lostpointercapture", up));
874
+ __normalize(handle.addEventListener("pointerup", up));
875
+ __normalize(handle.addEventListener("pointercancel", up));
876
+ __normalize(handle.addEventListener("keydown", key));
877
+ let release = () => {
878
+ __normalize(handle.removeEventListener("pointerdown", down));
879
+ __normalize(handle.removeEventListener("pointermove", move));
880
+ __normalize(handle.removeEventListener("lostpointercapture", up));
881
+ __normalize(handle.removeEventListener("pointerup", up));
882
+ __normalize(handle.removeEventListener("pointercancel", up));
883
+ __normalize(handle.removeEventListener("keydown", key));
884
+ __remove(handle);
885
+ return null;
886
+ };
887
+ __add(this.release, release);
888
+ return null;
889
+ }
890
+ detach() {
891
+ for (const release of __normalize(this.release)) {
892
+ __call(release, );
893
+ }
894
+ this.release = [];
895
+ return null;
896
+ return null;
897
+ }
898
+ }
899
+ export function spanValue(value) {
900
+ __requireArity(arguments.length, [0], "spanValue");
901
+ value = __boundary(value);
902
+ if (__requireBoolean(value === null)) {
903
+ return 1;
904
+ }
905
+ if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(value))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(value))))) || __requireBoolean(value < 1)) || __requireBoolean(value > 1000))) {
906
+ throw "Table span must be an integer between 1 and 1000";
907
+ }
908
+ return value;
909
+ return null;
910
+ }
911
+
912
+ function applySpan(element, name, value) {
913
+ __requireArity(arguments.length, [0, 1, 2], "applySpan");
914
+ element = __boundary(element);
915
+ name = __boundary(name);
916
+ value = __boundary(value);
917
+ let span = spanValue(value);
918
+ if (__requireBoolean(span === 1)) {
919
+ __normalize(element.removeAttribute(name));
920
+ } else {
921
+ __normalize(element.setAttribute(name, `${span}`));
922
+ }
923
+ return null;
924
+ return null;
925
+ }
926
+
927
+ export function columnWidth(value) {
928
+ __requireArity(arguments.length, [0], "columnWidth");
929
+ value = __boundary(value);
930
+ return measure(value, "ch");
931
+ return null;
932
+ }
933
+
934
+ function clearValue(control) {
935
+ __requireArity(arguments.length, [0], "clearValue");
936
+ control = __boundary(control);
937
+ if (__requireBoolean(__isKindof(control, Form))) {
938
+ for (const child of __normalize(control.owned)) {
939
+ clearValue(child);
940
+ }
941
+ } else {
942
+ __normalize(control.setValue(null));
943
+ }
944
+ return null;
945
+ return null;
946
+ }
947
+
948
+ function cellElement(heading) {
949
+ __requireArity(arguments.length, [0], "cellElement");
950
+ heading = __boundary(heading);
951
+ if (__requireBoolean(heading)) {
952
+ return cloneMarkup("table-heading", ["<th scope=\"col\"></th>"].join(""));
953
+ }
954
+ return cloneMarkup("table-cell", ["<td></td>"].join(""));
955
+ return null;
956
+ }
957
+
958
+ function addName(names, name, control) {
959
+ __requireArity(arguments.length, [0, 1, 2], "addName");
960
+ names = __boundary(names);
961
+ name = __boundary(name);
962
+ control = __boundary(control);
963
+ if (__requireBoolean(name === null)) {
964
+ return null;
965
+ }
966
+ if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isString(name))) || __requireBoolean(name === "")) || __requireBoolean(__normalize(name.includes("/")))) || __requireBoolean(__includes(name, names)))) {
967
+ throw `Invalid or duplicate control name: ${name}`;
968
+ }
969
+ names[name] = control;
970
+ return null;
971
+ return null;
972
+ }
973
+
974
+ function rowValue(value) {
975
+ __requireArity(arguments.length, [0], "rowValue");
976
+ value = __boundary(value);
977
+ if (__requireBoolean(__requireBoolean(value !== null) && __requireBoolean(__requireBoolean(!__requireBoolean(__isObject(value))) || __requireBoolean(__isArray(value))))) {
978
+ throw "Table row value must be a map or null";
979
+ }
980
+ return value;
981
+ return null;
982
+ }
983
+
984
+ function tableIndex(index, length, insertion = false) {
985
+ __requireArity(arguments.length, [0, 1], "tableIndex");
986
+ index = __boundary(index);
987
+ length = __boundary(length);
988
+ insertion = __boundary(insertion);
989
+ let limit = __finite(length - 1);
990
+ if (__requireBoolean(insertion)) {
991
+ limit = length;
992
+ }
993
+ if (__requireBoolean(__requireBoolean(__requireBoolean(__requireBoolean(!__requireBoolean(__isNumber(index))) || __requireBoolean(!__requireBoolean(__normalize(__hostGlobal(["Number"]).isInteger(index))))) || __requireBoolean(index < 0)) || __requireBoolean(index > limit))) {
994
+ throw `Table index out of range: ${index}`;
995
+ }
996
+ return index;
997
+ return null;
998
+ }
999
+
1000
+ function columnIndex(column, columns) {
1001
+ __requireArity(arguments.length, [0, 1], "columnIndex");
1002
+ column = __boundary(column);
1003
+ columns = __boundary(columns);
1004
+ if (__requireBoolean(__isString(column))) {
1005
+ for (const [index, col] of __entries(columns)) {
1006
+ if (__requireBoolean(__normalize(col.name) === column)) {
1007
+ return index;
1008
+ }
1009
+ }
1010
+ throw `Unknown table column: ${column}`;
1011
+ }
1012
+ return tableIndex(column, __normalize(columns.length));
1013
+ return null;
1014
+ }
1015
+
1016
+ function validateBoundaries(header, rows, columns) {
1017
+ __requireArity(arguments.length, [0, 1, 2], "validateBoundaries");
1018
+ header = __boundary(header);
1019
+ rows = __boundary(rows);
1020
+ columns = __boundary(columns);
1021
+ let offset;
1022
+ let first = null;
1023
+ if (__requireBoolean(__requireBoolean(header !== null) && __requireBoolean(header.rows.length > 0))) {
1024
+ first = header.rows[0];
1025
+ } else {
1026
+ if (__requireBoolean(__normalize(rows.length) > 0)) {
1027
+ first = __normalize(rows[0]);
1028
+ }
1029
+ }
1030
+ if (__requireBoolean(first !== null)) {
1031
+ offset = 0;
1032
+ for (const col of columns) {
1033
+ offset = __numericAdd(offset, __normalize(col.span));
1034
+ if (__requireBoolean(__requireBoolean(__normalize(col.resize)) && __requireBoolean(__normalize(first.boundary(offset)) === null))) {
1035
+ throw "Resizable column must end at a first-row cell boundary";
1036
+ }
1037
+ }
1038
+ }
1039
+ return first;
1040
+ return null;
1041
+ }
1042
+
1043
+ function allReady(pending) {
1044
+ __requireArity(arguments.length, [0], "allReady");
1045
+ pending = __boundary(pending);
1046
+ if (__requireBoolean(__normalize(pending.length) === 0)) {
1047
+ return null;
1048
+ }
1049
+ return __normalize(__hostGlobal(["Promise"]).all(pending));
1050
+ return null;
1051
+ }
1052
+ //# sourceMappingURL=tables.mjs.map