@web-atoms/core 2.6.21 → 2.6.25

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 (137) hide show
  1. package/dist/App.d.ts +1 -1
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/App.js.map +1 -1
  4. package/dist/core/SingleInvoker.d.ts.map +1 -1
  5. package/dist/core/SingleInvoker.js.map +1 -1
  6. package/dist/core/sleep.js.map +1 -1
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/dist-esm/App.d.ts +1 -1
  9. package/dist-esm/App.d.ts.map +1 -1
  10. package/dist-esm/App.js +231 -235
  11. package/dist-esm/App.js.map +1 -1
  12. package/dist-esm/Atom.js +93 -96
  13. package/dist-esm/MockApp.js +17 -18
  14. package/dist-esm/Pack.js +1 -3
  15. package/dist-esm/core/AtomBinder.js +189 -187
  16. package/dist-esm/core/AtomComponent.js +479 -502
  17. package/dist-esm/core/AtomDispatcher.js +46 -48
  18. package/dist-esm/core/AtomDisposableList.js +24 -25
  19. package/dist-esm/core/AtomEnumerator.js +15 -16
  20. package/dist-esm/core/AtomList.js +193 -192
  21. package/dist-esm/core/AtomLoader.js +229 -215
  22. package/dist-esm/core/AtomMap.js +7 -8
  23. package/dist-esm/core/AtomOnce.js +22 -24
  24. package/dist-esm/core/AtomSelectableList.js +240 -243
  25. package/dist-esm/core/AtomUri.js +70 -72
  26. package/dist-esm/core/AtomWatcher.js +105 -111
  27. package/dist-esm/core/Bind.js +271 -269
  28. package/dist-esm/core/BindableProperty.js +26 -27
  29. package/dist-esm/core/CancelTokenFactory.js +21 -24
  30. package/dist-esm/core/Color.js +1 -2
  31. package/dist-esm/core/Colors.js +545 -231
  32. package/dist-esm/core/Command.js +236 -223
  33. package/dist-esm/core/Defer.js +21 -22
  34. package/dist-esm/core/EventScope.js +96 -88
  35. package/dist-esm/core/ExpressionParser.js +132 -144
  36. package/dist-esm/core/ExtendControl.js +7 -8
  37. package/dist-esm/core/FormattedError.js +7 -8
  38. package/dist-esm/core/FormattedString.js +4 -5
  39. package/dist-esm/core/Hacks.js +41 -42
  40. package/dist-esm/core/IFetchEvent.js +1 -2
  41. package/dist-esm/core/IScreen.js +1 -2
  42. package/dist-esm/core/IValueConverter.js +1 -2
  43. package/dist-esm/core/InheritedProperty.js +61 -63
  44. package/dist-esm/core/InjectProperty.js +12 -13
  45. package/dist-esm/core/KeyValuePairs.js +1 -2
  46. package/dist-esm/core/Markdown.js +14 -17
  47. package/dist-esm/core/MarkdownError.js +6 -7
  48. package/dist-esm/core/PropertyBinding.js +1 -2
  49. package/dist-esm/core/PropertyMap.js +28 -27
  50. package/dist-esm/core/Route.js +149 -148
  51. package/dist-esm/core/SingleInvoker.d.ts.map +1 -1
  52. package/dist-esm/core/SingleInvoker.js +32 -35
  53. package/dist-esm/core/SingleInvoker.js.map +1 -1
  54. package/dist-esm/core/StringHelper.js +49 -51
  55. package/dist-esm/core/TransientDisposable.js +14 -16
  56. package/dist-esm/core/WatchProperty.js +18 -17
  57. package/dist-esm/core/WebImage.js +7 -8
  58. package/dist-esm/core/XNode.js +134 -117
  59. package/dist-esm/core/sleep.js +21 -24
  60. package/dist-esm/core/sleep.js.map +1 -1
  61. package/dist-esm/core/types.js +102 -103
  62. package/dist-esm/di/DISingleton.js +7 -5
  63. package/dist-esm/di/DITransient.js +7 -5
  64. package/dist-esm/di/IMockOrInject.js +1 -2
  65. package/dist-esm/di/IServiceProvider.js +1 -2
  66. package/dist-esm/di/Inject.js +67 -67
  67. package/dist-esm/di/Register.js +25 -26
  68. package/dist-esm/di/RegisterScoped.js +4 -3
  69. package/dist-esm/di/RegisterSingleton.js +4 -3
  70. package/dist-esm/di/ServiceCollection.js +38 -37
  71. package/dist-esm/di/ServiceProvider.js +94 -94
  72. package/dist-esm/di/TypeKey.js +13 -12
  73. package/dist-esm/services/BusyIndicatorService.js +7 -11
  74. package/dist-esm/services/CacheService.js +54 -62
  75. package/dist-esm/services/FetchBuilder.js +327 -278
  76. package/dist-esm/services/JsonService.js +118 -116
  77. package/dist-esm/services/MockNavigationService.js +127 -126
  78. package/dist-esm/services/NavigationService.js +95 -102
  79. package/dist-esm/services/ReferenceService.js +30 -33
  80. package/dist-esm/services/http/AjaxOptions.js +1 -3
  81. package/dist-esm/services/http/JsonError.js +16 -15
  82. package/dist-esm/services/http/RestService.js +314 -323
  83. package/dist-esm/style/StyleRule.js +1 -2
  84. package/dist-esm/test.js +0 -1
  85. package/dist-esm/tsconfig.esm.tsbuildinfo +1 -1
  86. package/dist-esm/unit/AtomTest.js +10 -11
  87. package/dist-esm/view-model/Action.js +258 -223
  88. package/dist-esm/view-model/AtomViewModel.js +234 -232
  89. package/dist-esm/view-model/AtomWindowViewModel.js +13 -14
  90. package/dist-esm/view-model/BindableUrlParameter.js +7 -8
  91. package/dist-esm/view-model/Delay.js +21 -25
  92. package/dist-esm/view-model/Disposable.js +28 -29
  93. package/dist-esm/view-model/Load.js +72 -73
  94. package/dist-esm/view-model/Once.js +33 -35
  95. package/dist-esm/view-model/baseTypes.js +4 -5
  96. package/dist-esm/view-model/bindPromise.js +24 -27
  97. package/dist-esm/view-model/bindProperty.js +3 -4
  98. package/dist-esm/view-model/bindUrlParameter.js +39 -43
  99. package/dist-esm/web/controls/AtomComboBox.js +56 -63
  100. package/dist-esm/web/controls/AtomControl.js +485 -490
  101. package/dist-esm/web/controls/AtomGridSplitter.js +57 -50
  102. package/dist-esm/web/controls/AtomGridView.js +230 -222
  103. package/dist-esm/web/controls/AtomItemsControl.js +677 -688
  104. package/dist-esm/web/controls/AtomPage.js +6 -7
  105. package/dist-esm/web/controls/AtomTemplate.js +1 -3
  106. package/dist-esm/web/controls/AtomTemplateControl.js +28 -29
  107. package/dist-esm/web/controls/AtomViewStack.js +19 -20
  108. package/dist-esm/web/core/AtomUI.js +200 -200
  109. package/dist-esm/web/core/Encoder.js +142 -152
  110. package/dist-esm/web/core/HtmlNode.js +141 -139
  111. package/dist-esm/web/images/Busy.js +1 -2
  112. package/dist-esm/web/images/BusyDataUrl.js +2 -869
  113. package/dist-esm/web/images/Button.js +1 -2
  114. package/dist-esm/web/images/ButtonDataUrl.js +2 -30
  115. package/dist-esm/web/images/CloseButton.js +1 -2
  116. package/dist-esm/web/images/CloseButtonDataUrl.js +2 -30
  117. package/dist-esm/web/images/CloseButtonHover.js +1 -2
  118. package/dist-esm/web/images/CloseButtonHoverDataUrl.js +2 -24
  119. package/dist-esm/web/services/LastTarget.js +31 -29
  120. package/dist-esm/web/services/MarkdownService.js +19 -31
  121. package/dist-esm/web/services/NotificationPopup.js +28 -21
  122. package/dist-esm/web/services/PopupService.js +512 -478
  123. package/dist-esm/web/services/PopupWindow.js +266 -247
  124. package/dist-esm/web/styles/AtomAlertWindowStyle.js +39 -40
  125. package/dist-esm/web/styles/AtomFrameStyle.js +15 -16
  126. package/dist-esm/web/styles/AtomNotificationStyle.js +19 -20
  127. package/dist-esm/web/styles/AtomPageLinkStyle.js +11 -12
  128. package/dist-esm/web/styles/AtomPopupStyle.js +9 -10
  129. package/dist-esm/web/styles/AtomStyle.js +61 -64
  130. package/dist-esm/web/styles/AtomStyleSheet.js +50 -51
  131. package/dist-esm/web/styles/AtomWindowStyle.js +116 -117
  132. package/dist-esm/web/styles/IStyleDeclaration.js +1 -2
  133. package/dist-esm/web/styles/StyleBuilder.js +79 -80
  134. package/package.json +3 -1
  135. package/src/App.ts +1 -1
  136. package/src/core/SingleInvoker.ts +1 -1
  137. package/src/core/sleep.ts +1 -1
@@ -7,185 +7,184 @@ import { visitDescendents } from "../../core/Hacks.js";
7
7
  import WebImage from "../../core/WebImage.js";
8
8
  import XNode, { isControl } from "../../core/XNode.js";
9
9
  const isAtomControl = isControl;
10
- const fromHyphenToCamel = (input) => input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
10
+ const fromHyphenToCamel = input => input.replace(/-([a-z])/g, g => g[1].toUpperCase());
11
11
  if (typeof bridge !== "undefined" && bridge.platform) {
12
- throw new Error("AtomControl of Web should not be used with Xamarin Forms");
12
+ throw new Error("AtomControl of Web should not be used with Xamarin Forms");
13
13
  }
14
14
  function setAttribute(name) {
15
- return (ctrl, e, value) => {
16
- e.setAttribute(name, value);
17
- };
15
+ return (ctrl, e, value) => {
16
+ e.setAttribute(name, value);
17
+ };
18
18
  }
19
19
  function setEvent(name) {
20
- return (ctrl, e, value) => {
21
- ctrl.bindEvent(e, name, value);
22
- };
20
+ return (ctrl, e, value) => {
21
+ ctrl.bindEvent(e, name, value);
22
+ };
23
23
  }
24
24
  function setStyle(name, applyUnit) {
25
- if (applyUnit) {
26
- return (ctrl, e, value) => {
27
- if (typeof value === "number") {
28
- e.style[name] = value + applyUnit;
29
- return;
30
- }
31
- e.style[name] = value;
32
- };
33
- }
25
+ if (applyUnit) {
34
26
  return (ctrl, e, value) => {
35
- e.style[name] = value;
27
+ if (typeof value === "number") {
28
+ e.style[name] = value + applyUnit;
29
+ return;
30
+ }
31
+ e.style[name] = value;
36
32
  };
33
+ }
34
+ return (ctrl, e, value) => {
35
+ e.style[name] = value;
36
+ };
37
37
  }
38
38
  function disposeChildren(owner, e) {
39
- if (!e) {
40
- return;
41
- }
42
- let s = e.firstElementChild;
43
- while (s) {
44
- const c = s;
45
- s = s.nextElementSibling;
46
- const ac = c.atomControl;
47
- if (ac) {
48
- ac.dispose();
49
- c.remove();
50
- continue;
51
- }
52
- disposeChildren(owner, c);
53
- owner.unbind(c);
54
- owner.unbindEvent(c);
55
- c.remove();
39
+ if (!e) {
40
+ return;
41
+ }
42
+ let s = e.firstElementChild;
43
+ while (s) {
44
+ const c = s;
45
+ s = s.nextElementSibling;
46
+ const ac = c.atomControl;
47
+ if (ac) {
48
+ ac.dispose();
49
+ c.remove();
50
+ continue;
56
51
  }
52
+ disposeChildren(owner, c);
53
+ owner.unbind(c);
54
+ owner.unbindEvent(c);
55
+ c.remove();
56
+ }
57
57
  }
58
58
  export const ElementValueSetters = {
59
- text(ctrl, e, value) {
60
- e.textContent = value;
61
- },
62
- ["class"](ctrl, e, value) {
63
- if (typeof value === "string") {
64
- e.className = value;
65
- return;
66
- }
67
- ctrl.setElementClass(e, value, true);
68
- },
69
- alt: setAttribute("alt"),
70
- title: setAttribute("title"),
71
- href: setAttribute("href"),
72
- target: setAttribute("target"),
73
- style: setAttribute("style"),
74
- styleLeft: setStyle("left", "px"),
75
- styleTop: setStyle("top", "px"),
76
- styleBottom: setStyle("bottom", "px"),
77
- styleRight: setStyle("right", "px"),
78
- styleWidth: setStyle("width", "px"),
79
- styleHeight: setStyle("height", "px"),
80
- stylePosition: setStyle("position"),
81
- styleFontSize: setStyle("fontSize", "px"),
82
- styleFontFamily: setStyle("fontFamily"),
83
- styleFontWeight: setStyle("fontWeight"),
84
- styleBorder: setStyle("border"),
85
- styleBorderWidth: setStyle("borderWidth", "px"),
86
- styleBorderColor: setStyle("borderColor"),
87
- styleColor: setStyle("color"),
88
- styleBackgroundColor: setStyle("backgroundColor"),
89
- dir: setAttribute("dir"),
90
- name: setAttribute("name"),
91
- tabIndex: setAttribute("tabIndex"),
92
- contentEditable: setAttribute("contentEditable"),
93
- eventClick: setEvent("click"),
94
- eventKeydown: setEvent("keydown"),
95
- eventKeyup: setEvent("keyup"),
96
- eventKeypress: setEvent("keypress"),
97
- eventMousedown: setEvent("mousedown"),
98
- eventMouseup: setEvent("mouseup"),
99
- eventMousemove: setEvent("mousemove"),
100
- src(ctrl, e, value) {
101
- if (value && /^http\:/i.test(value)) {
102
- e.src = value.substring(5);
103
- return;
104
- }
105
- e.src = value;
106
- },
107
- styleClass(ctrl, e, value) {
108
- ctrl.setElementClass(e, value);
109
- },
110
- styleDisplay(ctrl, e, value) {
111
- if (typeof value === "boolean") {
112
- e.style.display = value ? "" : "none";
113
- return;
114
- }
115
- e.style.display = value;
116
- },
117
- formattedText(ctrl, e, value) {
118
- if (value instanceof FormattedString) {
119
- value.applyTo(ctrl.app, e);
120
- }
121
- else {
122
- e.textContent = (value || "").toString();
123
- }
124
- },
125
- disabled(ctrl, e, value) {
126
- if (value) {
127
- e.setAttribute("disabled", "");
128
- return;
129
- }
130
- e.removeAttribute("disabled");
131
- },
132
- autofocus(ctrl, element, value) {
133
- if (value === false) {
134
- return;
135
- }
136
- ctrl.app.callLater(() => {
137
- const ie = element;
138
- if (ie) {
139
- setTimeout(() => requestAnimationFrame(() => ie.focus()), 100);
140
- }
141
- });
142
- },
143
- autocomplete(ctrl, element, value) {
144
- ctrl.app.callLater(() => {
145
- element.autocomplete = value;
146
- });
147
- },
148
- onCreate(ctrl, element, value) {
149
- value(ctrl, element);
150
- },
151
- watch(ctrl, element, value) {
152
- setTimeout((c1, e1, v1) => {
153
- e1.dispatchEvent(new CustomEvent("watch", {
154
- bubbles: true,
155
- cancelable: true,
156
- detail: {
157
- control: c1,
158
- value: v1
159
- }
160
- }));
161
- }, 1, ctrl, element, value);
162
- },
163
- ariaLabel(ctrl, e, value) {
164
- if (value === null) {
165
- e.removeAttribute("aria-label");
166
- return;
167
- }
168
- if (typeof value === "object") {
169
- value = JSON.stringify(value);
170
- }
171
- if (typeof value !== "string") {
172
- value = value.toString();
173
- }
174
- e.setAttribute("aria-label", value);
175
- },
176
- ariaPlaceholder(ctrl, e, value) {
177
- if (value === null) {
178
- e.removeAttribute("aria-placeholder");
179
- return;
180
- }
181
- if (typeof value === "object") {
182
- value = JSON.stringify(value);
183
- }
184
- if (typeof value !== "string") {
185
- value = value.toString();
186
- }
187
- e.setAttribute("aria-placeholder", value);
59
+ text(ctrl, e, value) {
60
+ e.textContent = value;
61
+ },
62
+ ["class"](ctrl, e, value) {
63
+ if (typeof value === "string") {
64
+ e.className = value;
65
+ return;
66
+ }
67
+ ctrl.setElementClass(e, value, true);
68
+ },
69
+ alt: setAttribute("alt"),
70
+ title: setAttribute("title"),
71
+ href: setAttribute("href"),
72
+ target: setAttribute("target"),
73
+ style: setAttribute("style"),
74
+ styleLeft: setStyle("left", "px"),
75
+ styleTop: setStyle("top", "px"),
76
+ styleBottom: setStyle("bottom", "px"),
77
+ styleRight: setStyle("right", "px"),
78
+ styleWidth: setStyle("width", "px"),
79
+ styleHeight: setStyle("height", "px"),
80
+ stylePosition: setStyle("position"),
81
+ styleFontSize: setStyle("fontSize", "px"),
82
+ styleFontFamily: setStyle("fontFamily"),
83
+ styleFontWeight: setStyle("fontWeight"),
84
+ styleBorder: setStyle("border"),
85
+ styleBorderWidth: setStyle("borderWidth", "px"),
86
+ styleBorderColor: setStyle("borderColor"),
87
+ styleColor: setStyle("color"),
88
+ styleBackgroundColor: setStyle("backgroundColor"),
89
+ dir: setAttribute("dir"),
90
+ name: setAttribute("name"),
91
+ tabIndex: setAttribute("tabIndex"),
92
+ contentEditable: setAttribute("contentEditable"),
93
+ eventClick: setEvent("click"),
94
+ eventKeydown: setEvent("keydown"),
95
+ eventKeyup: setEvent("keyup"),
96
+ eventKeypress: setEvent("keypress"),
97
+ eventMousedown: setEvent("mousedown"),
98
+ eventMouseup: setEvent("mouseup"),
99
+ eventMousemove: setEvent("mousemove"),
100
+ src(ctrl, e, value) {
101
+ if (value && /^http\:/i.test(value)) {
102
+ e.src = value.substring(5);
103
+ return;
104
+ }
105
+ e.src = value;
106
+ },
107
+ styleClass(ctrl, e, value) {
108
+ ctrl.setElementClass(e, value);
109
+ },
110
+ styleDisplay(ctrl, e, value) {
111
+ if (typeof value === "boolean") {
112
+ e.style.display = value ? "" : "none";
113
+ return;
114
+ }
115
+ e.style.display = value;
116
+ },
117
+ formattedText(ctrl, e, value) {
118
+ if (value instanceof FormattedString) {
119
+ value.applyTo(ctrl.app, e);
120
+ } else {
121
+ e.textContent = (value || "").toString();
122
+ }
123
+ },
124
+ disabled(ctrl, e, value) {
125
+ if (value) {
126
+ e.setAttribute("disabled", "");
127
+ return;
128
+ }
129
+ e.removeAttribute("disabled");
130
+ },
131
+ autofocus(ctrl, element, value) {
132
+ if (value === false) {
133
+ return;
134
+ }
135
+ ctrl.app.callLater(() => {
136
+ const ie = element;
137
+ if (ie) {
138
+ setTimeout(() => requestAnimationFrame(() => ie.focus()), 100);
139
+ }
140
+ });
141
+ },
142
+ autocomplete(ctrl, element, value) {
143
+ ctrl.app.callLater(() => {
144
+ element.autocomplete = value;
145
+ });
146
+ },
147
+ onCreate(ctrl, element, value) {
148
+ value(ctrl, element);
149
+ },
150
+ watch(ctrl, element, value) {
151
+ setTimeout((c1, e1, v1) => {
152
+ e1.dispatchEvent(new CustomEvent("watch", {
153
+ bubbles: true,
154
+ cancelable: true,
155
+ detail: {
156
+ control: c1,
157
+ value: v1
158
+ }
159
+ }));
160
+ }, 1, ctrl, element, value);
161
+ },
162
+ ariaLabel(ctrl, e, value) {
163
+ if (value === null) {
164
+ e.removeAttribute("aria-label");
165
+ return;
166
+ }
167
+ if (typeof value === "object") {
168
+ value = JSON.stringify(value);
169
+ }
170
+ if (typeof value !== "string") {
171
+ value = value.toString();
172
+ }
173
+ e.setAttribute("aria-label", value);
174
+ },
175
+ ariaPlaceholder(ctrl, e, value) {
176
+ if (value === null) {
177
+ e.removeAttribute("aria-placeholder");
178
+ return;
179
+ }
180
+ if (typeof value === "object") {
181
+ value = JSON.stringify(value);
182
+ }
183
+ if (typeof value !== "string") {
184
+ value = value.toString();
188
185
  }
186
+ e.setAttribute("aria-placeholder", value);
187
+ }
189
188
  };
190
189
  ElementValueSetters["aria-label"] = ElementValueSetters.ariaLabel;
191
190
  ElementValueSetters["aria-placeholder"] = ElementValueSetters.ariaPlaceholder;
@@ -209,361 +208,357 @@ ElementValueSetters["on-create"] = ElementValueSetters.onCreate;
209
208
  let propertyId = 1;
210
209
  ;
211
210
  export class AtomControl extends AtomComponent {
212
- static from(e1) {
213
- let e = e1;
214
- while (e) {
215
- const { atomControl } = e;
216
- if (atomControl) {
217
- return atomControl;
218
- }
219
- e = e._logicalParent ?? e.parentElement;
220
- }
211
+ static from(e1) {
212
+ let e = e1;
213
+ while (e) {
214
+ const {
215
+ atomControl
216
+ } = e;
217
+ if (atomControl) {
218
+ return atomControl;
219
+ }
220
+ e = e._logicalParent ?? e.parentElement;
221
221
  }
222
- static registerProperty(attributeName, attributeValue, setter) {
223
- const setterSymbol = `${attributeName}_${attributeValue}_${propertyId++}`;
224
- ElementValueSetters[setterSymbol] = setter;
225
- function setterFx(v) {
226
- return {
227
- [setterSymbol]: v
228
- };
229
- }
230
- setterFx.toString = () => {
231
- return setterSymbol;
232
- };
233
- setterFx.property = setterSymbol;
234
- return setterFx;
222
+ }
223
+ static registerProperty(attributeName, attributeValue, setter) {
224
+ const setterSymbol = `${attributeName}_${attributeValue}_${propertyId++}`;
225
+ ElementValueSetters[setterSymbol] = setter;
226
+ function setterFx(v) {
227
+ return {
228
+ [setterSymbol]: v
229
+ };
235
230
  }
236
- get parent() {
237
- let e = this.element?._logicalParent || this.element?.parentElement;
238
- if (!e) {
239
- return null;
240
- }
241
- while (e) {
242
- const ac = e.atomControl;
243
- if (ac) {
244
- return ac;
245
- }
246
- e = e._logicalParent || e.parentElement;
247
- }
231
+ setterFx.toString = () => {
232
+ return setterSymbol;
233
+ };
234
+ setterFx.property = setterSymbol;
235
+ return setterFx;
236
+ }
237
+ get parent() {
238
+ let e = this.element?._logicalParent || this.element?.parentElement;
239
+ if (!e) {
240
+ return null;
248
241
  }
249
- get factory() {
250
- return AtomControl;
242
+ while (e) {
243
+ const ac = e.atomControl;
244
+ if (ac) {
245
+ return ac;
246
+ }
247
+ e = e._logicalParent || e.parentElement;
251
248
  }
252
- constructor(app, e = document.createElement("div")) {
253
- super(app, e);
249
+ }
250
+ get factory() {
251
+ return AtomControl;
252
+ }
253
+ constructor(app, e = document.createElement("div")) {
254
+ super(app, e);
255
+ }
256
+ onPropertyChanged(name) {
257
+ super.onPropertyChanged(name);
258
+ switch (name) {
259
+ case "renderer":
260
+ this.rendererChanged();
261
+ break;
254
262
  }
255
- onPropertyChanged(name) {
256
- super.onPropertyChanged(name);
257
- switch (name) {
258
- case "renderer":
259
- this.rendererChanged();
260
- break;
261
- }
263
+ }
264
+ atomParent(e) {
265
+ while (e) {
266
+ const ac = e.atomControl;
267
+ if (ac) {
268
+ return ac;
269
+ }
270
+ e = e._logicalParent ?? e.parentElement;
262
271
  }
263
- atomParent(e) {
264
- while (e) {
265
- const ac = e.atomControl;
266
- if (ac) {
267
- return ac;
268
- }
269
- e = e._logicalParent ?? e.parentElement;
270
- }
272
+ }
273
+ append(element) {
274
+ if (element instanceof AtomControl) {
275
+ this.element.appendChild(element.element);
276
+ } else {
277
+ this.element.appendChild(element);
271
278
  }
272
- append(element) {
273
- if (element instanceof AtomControl) {
274
- this.element.appendChild(element.element);
275
- }
276
- else {
277
- this.element.appendChild(element);
278
- }
279
- return this;
280
- }
281
- updateSize() {
282
- this.onUpdateSize();
283
- visitDescendents(this.element, (e, ac) => {
284
- if (ac) {
285
- ac.updateSize();
286
- return false;
287
- }
288
- return true;
289
- });
290
- }
291
- rendererChanged() {
292
- disposeChildren(this, this.element);
293
- this.element.innerHTML = "";
294
- const r = this.renderer;
295
- if (!r) {
296
- return;
297
- }
298
- delete this.render;
299
- this.render(r);
279
+ return this;
280
+ }
281
+ updateSize() {
282
+ this.onUpdateSize();
283
+ visitDescendents(this.element, (e, ac) => {
284
+ if (ac) {
285
+ ac.updateSize();
286
+ return false;
287
+ }
288
+ return true;
289
+ });
290
+ }
291
+ rendererChanged() {
292
+ disposeChildren(this, this.element);
293
+ this.element.innerHTML = "";
294
+ const r = this.renderer;
295
+ if (!r) {
296
+ return;
300
297
  }
301
- preCreate() {
298
+ delete this.render;
299
+ this.render(r);
300
+ }
301
+ preCreate() {}
302
+ setElementValue(element, name, value) {
303
+ if (value === undefined) {
304
+ return;
302
305
  }
303
- setElementValue(element, name, value) {
304
- if (value === undefined) {
305
- return;
306
- }
307
- const setter = ElementValueSetters[name];
308
- if (setter !== void 0) {
309
- setter(this, element, value);
310
- return;
311
- }
312
- if (/^(data|aria)\-/.test(name)) {
313
- if (value === null) {
314
- element.removeAttribute(name);
315
- return;
316
- }
317
- if (typeof value === "object") {
318
- value = JSON.stringify(value);
319
- }
320
- if (typeof value !== "string") {
321
- value = value.toString();
322
- }
323
- element.setAttribute(name, value);
324
- return;
325
- }
326
- if (/^style/.test(name)) {
327
- name = name.substring(5);
328
- if (name.startsWith("-")) {
329
- name = fromHyphenToCamel(name.substring(1));
330
- }
331
- else {
332
- name = name.charAt(0).toLowerCase() + name.substring(1);
333
- }
334
- if (value instanceof WebImage) {
335
- value = `url(${value})`;
336
- }
337
- element.style[name] = value;
338
- return;
339
- }
340
- if (/^event/.test(name)) {
341
- name = name.substring(5);
342
- if (name.startsWith("-")) {
343
- name = fromHyphenToCamel(name.substring(1));
344
- }
345
- else {
346
- name = name.charAt(0).toLowerCase() + name.substring(1);
347
- }
348
- this.bindEvent(element, name, value);
349
- return;
350
- }
351
- if (name.startsWith("attr-")) {
352
- if (value === null) {
353
- element.removeAttribute(name.substring(5));
354
- return;
355
- }
356
- element.setAttribute(name.substring(5), value);
357
- }
358
- else {
359
- element[name] = value;
360
- }
306
+ const setter = ElementValueSetters[name];
307
+ if (setter !== void 0) {
308
+ setter(this, element, value);
309
+ return;
361
310
  }
362
- setElementClass(element, value, clear) {
363
- const s = value;
364
- if (s && typeof s === "object") {
365
- if (!s.className) {
366
- if (clear) {
367
- let sr = "";
368
- for (const key in s) {
369
- if (s.hasOwnProperty(key)) {
370
- const sv = s[key];
371
- if (sv) {
372
- sr += (sr ? (" " + key) : key);
373
- }
374
- }
375
- }
376
- element.className = sr;
377
- return;
378
- }
379
- for (const key in s) {
380
- if (s.hasOwnProperty(key)) {
381
- const sv = s[key];
382
- if (sv) {
383
- if (!element.classList.contains(key)) {
384
- element.classList.add(key);
385
- }
386
- }
387
- else {
388
- if (element.classList.contains(key)) {
389
- element.classList.remove(key);
390
- }
391
- }
392
- }
393
- }
394
- return;
395
- }
396
- }
397
- const sv1 = s ? (s.className || s.toString()) : "";
398
- element.className = sv1;
399
- }
400
- onUpdateSize() {
401
- }
402
- removeAllChildren(e) {
403
- let child = e.firstElementChild;
404
- while (child) {
405
- const c = child;
406
- child = child.nextElementSibling;
407
- const ac = c;
408
- if (ac && ac.atomControl) {
409
- ac.atomControl.dispose();
311
+ if (/^(data|aria)\-/.test(name)) {
312
+ if (value === null) {
313
+ element.removeAttribute(name);
314
+ return;
315
+ }
316
+ if (typeof value === "object") {
317
+ value = JSON.stringify(value);
318
+ }
319
+ if (typeof value !== "string") {
320
+ value = value.toString();
321
+ }
322
+ element.setAttribute(name, value);
323
+ return;
324
+ }
325
+ if (/^style/.test(name)) {
326
+ name = name.substring(5);
327
+ if (name.startsWith("-")) {
328
+ name = fromHyphenToCamel(name.substring(1));
329
+ } else {
330
+ name = name.charAt(0).toLowerCase() + name.substring(1);
331
+ }
332
+ if (value instanceof WebImage) {
333
+ value = `url(${value})`;
334
+ }
335
+ element.style[name] = value;
336
+ return;
337
+ }
338
+ if (/^event/.test(name)) {
339
+ name = name.substring(5);
340
+ if (name.startsWith("-")) {
341
+ name = fromHyphenToCamel(name.substring(1));
342
+ } else {
343
+ name = name.charAt(0).toLowerCase() + name.substring(1);
344
+ }
345
+ this.bindEvent(element, name, value);
346
+ return;
347
+ }
348
+ if (name.startsWith("attr-")) {
349
+ if (value === null) {
350
+ element.removeAttribute(name.substring(5));
351
+ return;
352
+ }
353
+ element.setAttribute(name.substring(5), value);
354
+ } else {
355
+ element[name] = value;
356
+ }
357
+ }
358
+ setElementClass(element, value, clear) {
359
+ const s = value;
360
+ if (s && typeof s === "object") {
361
+ if (!s.className) {
362
+ if (clear) {
363
+ let sr = "";
364
+ for (const key in s) {
365
+ if (s.hasOwnProperty(key)) {
366
+ const sv = s[key];
367
+ if (sv) {
368
+ sr += sr ? " " + key : key;
369
+ }
410
370
  }
411
- else {
412
- this.unbindEvent(child);
413
- this.unbind(child);
371
+ }
372
+ element.className = sr;
373
+ return;
374
+ }
375
+ for (const key in s) {
376
+ if (s.hasOwnProperty(key)) {
377
+ const sv = s[key];
378
+ if (sv) {
379
+ if (!element.classList.contains(key)) {
380
+ element.classList.add(key);
381
+ }
382
+ } else {
383
+ if (element.classList.contains(key)) {
384
+ element.classList.remove(key);
385
+ }
414
386
  }
415
- c.remove();
387
+ }
416
388
  }
389
+ return;
390
+ }
417
391
  }
418
- createNode(app, e, iterator, creator) {
419
- const name = iterator.name;
420
- const attributes = iterator.attributes;
421
- if (typeof name === "string") {
422
- const element = document.createElement(name);
423
- if (name === "input") {
424
- if (!attributes.autocomplete) {
425
- this.app.callLater(() => {
426
- element.autocomplete = "google-stop";
427
- });
428
- }
429
- }
430
- e?.appendChild(element);
431
- this.render(iterator, element, creator);
432
- return element;
433
- }
434
- if (name[isAtomControl]) {
435
- const forName = attributes?.for;
436
- const ctrl = new (name)(app, forName ? document.createElement(forName) : undefined);
437
- const element = ctrl.element;
438
- e?.appendChild(element);
439
- ctrl.render(iterator, element, creator);
440
- return element;
441
- }
442
- throw new Error(`not implemented create for ${iterator.name}`);
392
+ const sv1 = s ? s.className || s.toString() : "";
393
+ element.className = sv1;
394
+ }
395
+ onUpdateSize() {}
396
+ removeAllChildren(e) {
397
+ let child = e.firstElementChild;
398
+ while (child) {
399
+ const c = child;
400
+ child = child.nextElementSibling;
401
+ const ac = c;
402
+ if (ac && ac.atomControl) {
403
+ ac.atomControl.dispose();
404
+ } else {
405
+ this.unbindEvent(child);
406
+ this.unbind(child);
407
+ }
408
+ c.remove();
443
409
  }
444
- toTemplate(app, iterator, creator) {
445
- if (iterator.isTemplate) {
446
- return this.toTemplate(app, iterator.children[0], creator);
447
- }
448
- const name = iterator.name;
449
- if (typeof name === "string") {
450
- return class Template extends AtomControl {
451
- constructor(a = app, e = document.createElement(name)) {
452
- super(a, e);
453
- }
454
- create() {
455
- super.create();
456
- this.render(iterator, undefined, creator);
457
- }
458
- };
410
+ }
411
+ createNode(app, e, iterator, creator) {
412
+ const name = iterator.name;
413
+ const attributes = iterator.attributes;
414
+ if (typeof name === "string") {
415
+ const element = document.createElement(name);
416
+ if (name === "input") {
417
+ if (!attributes.autocomplete) {
418
+ this.app.callLater(() => {
419
+ element.autocomplete = "google-stop";
420
+ });
421
+ }
422
+ }
423
+ e?.appendChild(element);
424
+ this.render(iterator, element, creator);
425
+ return element;
426
+ }
427
+ if (name[isAtomControl]) {
428
+ const forName = attributes?.for;
429
+ const ctrl = new name(app, forName ? document.createElement(forName) : undefined);
430
+ const element = ctrl.element;
431
+ e?.appendChild(element);
432
+ ctrl.render(iterator, element, creator);
433
+ return element;
434
+ }
435
+ throw new Error(`not implemented create for ${iterator.name}`);
436
+ }
437
+ toTemplate(app, iterator, creator) {
438
+ if (iterator.isTemplate) {
439
+ return this.toTemplate(app, iterator.children[0], creator);
440
+ }
441
+ const name = iterator.name;
442
+ if (typeof name === "string") {
443
+ return class Template extends AtomControl {
444
+ constructor(a = app, e = document.createElement(name)) {
445
+ super(a, e);
459
446
  }
460
- if (name[isAtomControl]) {
461
- const forName = name.attributes?.for;
462
- if (forName) {
463
- return class Template extends name {
464
- constructor(a = app, e = document.createElement(forName)) {
465
- super(a, e);
466
- }
467
- create() {
468
- super.create();
469
- this.render(iterator, undefined, creator);
470
- }
471
- };
472
- }
473
- return class Template extends name {
474
- constructor(a = app, e) {
475
- super(a, e);
476
- }
477
- create() {
478
- super.create();
479
- this.render(iterator, undefined, creator);
480
- }
481
- };
447
+ create() {
448
+ super.create();
449
+ this.render(iterator, undefined, creator);
482
450
  }
483
- throw new Error(`Creating template from ${name} not supported`);
451
+ };
484
452
  }
485
- dispatchClickEvent(e, data) {
486
- let clickEvent = data.clickEvent;
487
- if (!clickEvent) {
488
- return;
453
+ if (name[isAtomControl]) {
454
+ const forName = name.attributes?.for;
455
+ if (forName) {
456
+ return class Template extends name {
457
+ constructor(a = app, e = document.createElement(forName)) {
458
+ super(a, e);
459
+ }
460
+ create() {
461
+ super.create();
462
+ this.render(iterator, undefined, creator);
463
+ }
464
+ };
465
+ }
466
+ return class Template extends name {
467
+ constructor(a = app, e) {
468
+ super(a, e);
489
469
  }
490
- clickEvent = clickEvent.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
491
- const ce = new CustomEvent(clickEvent, { detail: data, bubbles: true, cancelable: true });
492
- e.target.dispatchEvent(ce);
493
- if (ce.preventClickEvent) {
494
- e.preventDefault();
470
+ create() {
471
+ super.create();
472
+ this.render(iterator, undefined, creator);
495
473
  }
474
+ };
475
+ }
476
+ throw new Error(`Creating template from ${name} not supported`);
477
+ }
478
+ dispatchClickEvent(e, data) {
479
+ let clickEvent = data.clickEvent;
480
+ if (!clickEvent) {
481
+ return;
496
482
  }
483
+ clickEvent = clickEvent.replace(/-([a-z])/g, g => g[1].toUpperCase());
484
+ const ce = new CustomEvent(clickEvent, {
485
+ detail: data,
486
+ bubbles: true,
487
+ cancelable: true
488
+ });
489
+ e.target.dispatchEvent(ce);
490
+ if (ce.preventClickEvent) {
491
+ e.preventDefault();
492
+ }
493
+ }
497
494
  }
498
- __decorate([
499
- BindableProperty,
500
- __metadata("design:type", XNode)
501
- ], AtomControl.prototype, "renderer", void 0);
495
+ __decorate([BindableProperty, __metadata("design:type", XNode)], AtomControl.prototype, "renderer", void 0);
502
496
  const getSelection = () => {
503
- const sel = window.getSelection();
504
- if (sel.rangeCount) {
505
- var frag = sel.getRangeAt(0).cloneContents();
506
- var el = document.createElement("div");
507
- el.appendChild(frag);
508
- return el.innerHTML;
509
- }
510
- return "";
497
+ const sel = window.getSelection();
498
+ if (sel.rangeCount) {
499
+ var frag = sel.getRangeAt(0).cloneContents();
500
+ var el = document.createElement("div");
501
+ el.appendChild(frag);
502
+ return el.innerHTML;
503
+ }
504
+ return "";
511
505
  };
512
506
  const body = document.body;
513
507
  const html = body.parentElement;
514
- window.addEventListener("click", (e) => {
515
- if (e.defaultPrevented) {
516
- return;
517
- }
518
- if (getSelection()) {
508
+ window.addEventListener("click", e => {
509
+ if (e.defaultPrevented) {
510
+ return;
511
+ }
512
+ if (getSelection()) {
513
+ return;
514
+ }
515
+ const originalTarget = e.target;
516
+ let start = originalTarget;
517
+ if (originalTarget === html) {
518
+ return;
519
+ }
520
+ let clickEvent;
521
+ while (start && start !== body) {
522
+ clickEvent ||= start.getAttribute("data-click-event");
523
+ if (start.tagName === "A") {
524
+ if (!clickEvent) {
519
525
  return;
520
- }
521
- const originalTarget = e.target;
522
- let start = originalTarget;
523
- if (originalTarget === html) {
524
- return;
525
- }
526
- let clickEvent;
527
- while (start && start !== body) {
528
- clickEvent ||= start.getAttribute("data-click-event");
529
- if (start.tagName === "A") {
530
- if (!clickEvent) {
531
- return;
532
- }
533
- if (clickEvent === "route") {
534
- const { href } = start;
535
- if (href) {
536
- if (Command.invokeRoute(href, true)) {
537
- e.preventDefault();
538
- e.stopImmediatePropagation();
539
- e.stopPropagation();
540
- }
541
- }
542
- }
526
+ }
527
+ if (clickEvent === "route") {
528
+ const {
529
+ href
530
+ } = start;
531
+ if (href) {
532
+ if (Command.invokeRoute(href, true)) {
543
533
  e.preventDefault();
544
534
  e.stopImmediatePropagation();
545
535
  e.stopPropagation();
546
- break;
536
+ }
547
537
  }
548
- start = start.parentNode;
549
- }
550
- let control = AtomControl.from(originalTarget);
551
- if (control !== void 0) {
552
- const data = new Proxy(originalTarget, {
553
- get(target, p) {
554
- if (typeof p !== "string") {
555
- return;
556
- }
557
- while (target) {
558
- const value = target.dataset[p];
559
- if (value !== void 0) {
560
- return value;
561
- }
562
- target = target.parentElement;
563
- }
564
- }
565
- });
566
- control.dispatchClickEvent(e, data);
538
+ }
539
+ e.preventDefault();
540
+ e.stopImmediatePropagation();
541
+ e.stopPropagation();
542
+ break;
567
543
  }
568
- });
569
- //# sourceMappingURL=AtomControl.js.map
544
+ start = start.parentNode;
545
+ }
546
+ let control = AtomControl.from(originalTarget);
547
+ if (control !== void 0) {
548
+ const data = new Proxy(originalTarget, {
549
+ get(target, p) {
550
+ if (typeof p !== "string") {
551
+ return;
552
+ }
553
+ while (target) {
554
+ const value = target.dataset[p];
555
+ if (value !== void 0) {
556
+ return value;
557
+ }
558
+ target = target.parentElement;
559
+ }
560
+ }
561
+ });
562
+ control.dispatchClickEvent(e, data);
563
+ }
564
+ });