@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
@@ -1,54 +1,61 @@
1
1
  import { AtomControl } from "./AtomControl.js";
2
2
  import { AtomGridView } from "./AtomGridView.js";
3
3
  export class AtomGridSplitter extends AtomControl {
4
- constructor() {
5
- super(...arguments);
4
+ constructor() {
5
+ super(...arguments);
6
+ this.dragging = false;
7
+ }
8
+ preCreate() {
9
+ this.direction = "vertical";
10
+ this.dragging = false;
11
+ }
12
+ create() {
13
+ this.bind(this.element, "styleCursor", [["direction"]], false, v => v === "vertical" ? "ew-resize" : "ns-resize");
14
+ this.bind(this.element, "styleBackgroundColor", [["dragging"]], false, v => v ? "blue" : "lightgray");
15
+ const style = this.element.style;
16
+ style.position = "absolute";
17
+ style.left = style.top = style.bottom = style.right = "0";
18
+ this.bindEvent(this.element, "mousedown", e => {
19
+ e.preventDefault();
20
+ this.dragging = true;
21
+ const parent = this.parent;
22
+ const isVertical = this.direction === "vertical";
23
+ const disposables = [];
24
+ const rect = {
25
+ x: e.screenX,
26
+ y: e.screenY
27
+ };
28
+ const {
29
+ column,
30
+ row
31
+ } = AtomGridView.getCellInfo(this.element);
32
+ const ss = document.createElement("style");
33
+ ss.textContent = "iframe { pointer-events: none }";
34
+ document.head.appendChild(ss);
35
+ disposables.push({
36
+ dispose: () => ss.remove()
37
+ });
38
+ disposables.push(this.bindEvent(document.body, "mousemove", me => {
39
+ const {
40
+ screenX,
41
+ screenY
42
+ } = me;
43
+ const dx = screenX - rect.x;
44
+ const dy = screenY - rect.y;
45
+ if (isVertical) {
46
+ parent.resize("column", column, dx);
47
+ } else {
48
+ parent.resize("row", row, dy);
49
+ }
50
+ rect.x = screenX;
51
+ rect.y = screenY;
52
+ }));
53
+ disposables.push(this.bindEvent(document.body, "mouseup", mup => {
6
54
  this.dragging = false;
7
- }
8
- preCreate() {
9
- this.direction = "vertical";
10
- this.dragging = false;
11
- }
12
- create() {
13
- this.bind(this.element, "styleCursor", [["direction"]], false, (v) => v === "vertical" ? "ew-resize" : "ns-resize");
14
- this.bind(this.element, "styleBackgroundColor", [["dragging"]], false, (v) => v ? "blue" : "lightgray");
15
- const style = this.element.style;
16
- style.position = "absolute";
17
- style.left = style.top = style.bottom = style.right = "0";
18
- this.bindEvent(this.element, "mousedown", (e) => {
19
- e.preventDefault();
20
- this.dragging = true;
21
- const parent = this.parent;
22
- const isVertical = this.direction === "vertical";
23
- const disposables = [];
24
- const rect = { x: e.screenX, y: e.screenY };
25
- const { column, row } = AtomGridView.getCellInfo(this.element);
26
- const ss = document.createElement("style");
27
- ss.textContent = "iframe { pointer-events: none }";
28
- document.head.appendChild(ss);
29
- disposables.push({
30
- dispose: () => ss.remove()
31
- });
32
- disposables.push(this.bindEvent(document.body, "mousemove", (me) => {
33
- const { screenX, screenY } = me;
34
- const dx = screenX - rect.x;
35
- const dy = screenY - rect.y;
36
- if (isVertical) {
37
- parent.resize("column", column, dx);
38
- }
39
- else {
40
- parent.resize("row", row, dy);
41
- }
42
- rect.x = screenX;
43
- rect.y = screenY;
44
- }));
45
- disposables.push(this.bindEvent(document.body, "mouseup", (mup) => {
46
- this.dragging = false;
47
- for (const iterator of disposables) {
48
- iterator.dispose();
49
- }
50
- }));
51
- });
52
- }
53
- }
54
- //# sourceMappingURL=AtomGridSplitter.js.map
55
+ for (const iterator of disposables) {
56
+ iterator.dispose();
57
+ }
58
+ }));
59
+ });
60
+ }
61
+ }
@@ -1,228 +1,236 @@
1
1
  import { visitDescendents } from "../../core/Hacks.js";
2
2
  import { AtomControl } from "./AtomControl.js";
3
3
  export class AtomGridView extends AtomControl {
4
- constructor() {
5
- super(...arguments);
6
- this.attempt = 0;
7
- this.availableRect = null;
8
- this.childrenReady = false;
9
- }
10
- static getCellInfo(e) {
11
- let row = 0;
12
- let column = 0;
13
- let rowSpan = 1;
14
- let colSpan = 1;
15
- const cell = e.cell;
16
- if (cell) {
17
- console.warn("Attribute `cell` is obsolete, please use row and column attributes separately");
18
- const tokens = cell.split(",")
19
- .map((s) => s.trim().split(":").map((st) => parseInt(st.trim(), 10)));
20
- column = tokens[0][0];
21
- row = tokens[1][0];
22
- colSpan = tokens[0][1] || 1;
23
- rowSpan = tokens[1][1] || 1;
24
- }
25
- else {
26
- let c = ((e.row) || "0");
27
- let tokens = c.split(":").map((st) => parseInt(st.trim(), 10));
28
- row = tokens[0];
29
- rowSpan = tokens[1] || 1;
30
- c = ((e.column) || "0");
31
- tokens = c.split(":").map((st) => parseInt(st.trim(), 10));
32
- column = tokens[0];
33
- colSpan = tokens[1] || 1;
34
- }
35
- return {
36
- row,
37
- rowSpan,
38
- column,
39
- colSpan,
40
- };
41
- }
42
- append(e) {
43
- const ee = e instanceof AtomControl ? e.element : e;
44
- ee._logicalParent = this.element;
45
- this.children = this.children || [];
46
- this.children.push(e instanceof AtomControl ? e.element : e);
47
- return this;
48
- }
49
- onUpdateUI() {
50
- this.attempt++;
51
- const c1 = this.children ??= [];
52
- c1.length = 0;
53
- let child = this.element.firstElementChild;
54
- while (child) {
55
- const c = child;
56
- c1.push(c);
57
- child = child.nextElementSibling;
58
- c.remove();
59
- }
60
- const width = this.element.offsetWidth ||
61
- this.element.clientWidth ||
62
- parseFloat(this.element.style.width) ||
63
- 0;
64
- const height = this.element.offsetHeight ||
65
- this.element.clientHeight ||
66
- parseFloat(this.element.style.height) ||
67
- 0;
68
- if (!(width && height)) {
69
- if (this.childrenReady) {
70
- setTimeout(() => {
71
- this.invalidate();
72
- }, 5000);
73
- return;
74
- }
75
- if (this.attempt > 100) {
76
- console.error(`AtomDockPanel (${width}, ${height}) must both have non zero width and height`);
77
- return;
78
- }
79
- setTimeout(() => {
80
- this.invalidate();
81
- }, 100);
82
- return;
83
- }
84
- if (!this.children) {
85
- return;
86
- }
87
- this.attempt = 0;
88
- this.availableRect = { width, height, x: 0, y: 0 };
89
- this.columnSizes = (this.columns || "*").split(",")
90
- .map((s) => this.toSize(s.trim(), this.availableRect.width));
91
- this.rowSizes = (this.rows || "*").split(",")
92
- .map((s) => this.toSize(s.trim(), this.availableRect.height));
93
- this.assignOffsets(this.columnSizes, this.availableRect.width);
94
- this.assignOffsets(this.rowSizes, this.availableRect.height);
95
- for (const iterator of this.children) {
96
- const host = document.createElement("section");
97
- host.appendChild(iterator);
98
- this.element.appendChild(host);
99
- }
100
- super.onUpdateUI();
101
- this.updateSize();
102
- this.childrenReady = true;
103
- }
104
- resize(item, index, delta) {
105
- const a = item === "column" ? this.columnSizes : this.rowSizes;
106
- const prev = a[index - 1];
107
- const next = a[index + 1];
108
- if ((!prev) || (!next)) {
109
- throw new Error("Grid Splitter cannot be start or end element in GridView");
110
- }
111
- const current = a[index];
112
- prev.size += delta;
113
- current.offset += delta;
114
- next.offset += delta;
115
- next.size -= delta;
116
- this.updateSize();
117
- }
118
- onPropertyChanged(name) {
119
- switch (name) {
120
- case "rows":
121
- case "columns":
122
- if (this.childrenReady) {
123
- this.invalidate();
124
- }
125
- break;
126
- }
4
+ constructor() {
5
+ super(...arguments);
6
+ this.attempt = 0;
7
+ this.availableRect = null;
8
+ this.childrenReady = false;
9
+ }
10
+ static getCellInfo(e) {
11
+ let row = 0;
12
+ let column = 0;
13
+ let rowSpan = 1;
14
+ let colSpan = 1;
15
+ const cell = e.cell;
16
+ if (cell) {
17
+ console.warn("Attribute `cell` is obsolete, please use row and column attributes separately");
18
+ const tokens = cell.split(",").map(s => s.trim().split(":").map(st => parseInt(st.trim(), 10)));
19
+ column = tokens[0][0];
20
+ row = tokens[1][0];
21
+ colSpan = tokens[0][1] || 1;
22
+ rowSpan = tokens[1][1] || 1;
23
+ } else {
24
+ let c = e.row || "0";
25
+ let tokens = c.split(":").map(st => parseInt(st.trim(), 10));
26
+ row = tokens[0];
27
+ rowSpan = tokens[1] || 1;
28
+ c = e.column || "0";
29
+ tokens = c.split(":").map(st => parseInt(st.trim(), 10));
30
+ column = tokens[0];
31
+ colSpan = tokens[1] || 1;
127
32
  }
128
- onUpdateSize() {
129
- if (!this.children) {
130
- return;
131
- }
132
- for (const iterator of this.children) {
133
- this.updateStyle(iterator);
134
- }
33
+ return {
34
+ row,
35
+ rowSpan,
36
+ column,
37
+ colSpan
38
+ };
39
+ }
40
+ append(e) {
41
+ const ee = e instanceof AtomControl ? e.element : e;
42
+ ee._logicalParent = this.element;
43
+ this.children = this.children || [];
44
+ this.children.push(e instanceof AtomControl ? e.element : e);
45
+ return this;
46
+ }
47
+ onUpdateUI() {
48
+ this.attempt++;
49
+ const c1 = this.children ??= [];
50
+ c1.length = 0;
51
+ let child = this.element.firstElementChild;
52
+ while (child) {
53
+ const c = child;
54
+ c1.push(c);
55
+ child = child.nextElementSibling;
56
+ c.remove();
135
57
  }
136
- preCreate() {
137
- this.columns = null;
138
- this.rows = null;
139
- const style = this.element.style;
140
- style.position = "absolute";
141
- style.left = style.right = style.top = style.bottom = "0";
142
- style.overflow = "hidden";
143
- this.bindEvent(window, "resize", () => {
144
- this.updateSize();
145
- });
146
- this.bindEvent(document.body, "resize", () => {
147
- this.updateSize();
148
- });
149
- }
150
- updateStyle(e) {
151
- const { colSpan, column, row, rowSpan } = AtomGridView.getCellInfo(e);
152
- const host = e.parentElement;
153
- if (!host) {
154
- return;
155
- }
156
- host.style.position = "absolute";
157
- host.style.overflow = "hidden";
158
- host.style.padding = "0";
159
- host.style.margin = "0";
160
- if (this.rowSizes.length <= row || this.columnSizes.length <= column) {
161
- return;
162
- }
163
- const rowStart = this.rowSizes[row].offset;
164
- let rowSize = 0;
165
- for (let i = row; i < row + rowSpan; i++) {
166
- rowSize += this.rowSizes[i].size;
167
- }
168
- host.style.top = `${rowStart}px`;
169
- host.style.height = `${rowSize}px`;
170
- const colStart = this.columnSizes[column].offset;
171
- let colSize = 0;
172
- for (let i = column; i < column + colSpan; i++) {
173
- colSize += this.columnSizes[i].size;
174
- }
175
- host.style.left = `${colStart}px`;
176
- host.style.width = `${colSize}px`;
177
- visitDescendents(host, (el, ac) => {
178
- if (ac) {
179
- ac.invalidate();
180
- return false;
181
- }
182
- return true;
183
- });
184
- }
185
- toSize(s, total) {
186
- if (!s || s === "*") {
187
- return { offset: -1, size: NaN };
188
- }
189
- let n = 0;
190
- if (s.endsWith("%")) {
191
- s = s.substr(0, s.length - 1);
192
- n = parseFloat(s);
193
- return { offset: -1, size: total * n / 100 };
194
- }
195
- return { offset: -1, size: parseFloat(s) };
196
- }
197
- assignOffsets(a, end) {
198
- let start = 0;
199
- let fill = null;
200
- for (const item of a) {
201
- item.offset = start;
202
- if (isNaN(item.size)) {
203
- fill = item;
204
- break;
205
- }
206
- start += item.size;
207
- }
208
- if (!fill) {
209
- return;
210
- }
211
- const lastStart = start;
212
- start = end;
213
- const r = a.map((x) => x).reverse();
214
- for (const item of r) {
215
- if (isNaN(item.size)) {
216
- if (fill !== item) {
217
- throw new Error("Multiple * cannot be defined");
218
- }
219
- break;
220
- }
221
- start -= item.size;
222
- item.offset = start;
223
- }
224
- fill.offset = lastStart;
225
- fill.size = start - lastStart;
58
+ const width = this.element.offsetWidth || this.element.clientWidth || parseFloat(this.element.style.width) || 0;
59
+ const height = this.element.offsetHeight || this.element.clientHeight || parseFloat(this.element.style.height) || 0;
60
+ if (!(width && height)) {
61
+ if (this.childrenReady) {
62
+ setTimeout(() => {
63
+ this.invalidate();
64
+ }, 5000);
65
+ return;
66
+ }
67
+ if (this.attempt > 100) {
68
+ console.error(`AtomDockPanel (${width}, ${height}) must both have non zero width and height`);
69
+ return;
70
+ }
71
+ setTimeout(() => {
72
+ this.invalidate();
73
+ }, 100);
74
+ return;
75
+ }
76
+ if (!this.children) {
77
+ return;
78
+ }
79
+ this.attempt = 0;
80
+ this.availableRect = {
81
+ width,
82
+ height,
83
+ x: 0,
84
+ y: 0
85
+ };
86
+ this.columnSizes = (this.columns || "*").split(",").map(s => this.toSize(s.trim(), this.availableRect.width));
87
+ this.rowSizes = (this.rows || "*").split(",").map(s => this.toSize(s.trim(), this.availableRect.height));
88
+ this.assignOffsets(this.columnSizes, this.availableRect.width);
89
+ this.assignOffsets(this.rowSizes, this.availableRect.height);
90
+ for (const iterator of this.children) {
91
+ const host = document.createElement("section");
92
+ host.appendChild(iterator);
93
+ this.element.appendChild(host);
94
+ }
95
+ super.onUpdateUI();
96
+ this.updateSize();
97
+ this.childrenReady = true;
98
+ }
99
+ resize(item, index, delta) {
100
+ const a = item === "column" ? this.columnSizes : this.rowSizes;
101
+ const prev = a[index - 1];
102
+ const next = a[index + 1];
103
+ if (!prev || !next) {
104
+ throw new Error("Grid Splitter cannot be start or end element in GridView");
105
+ }
106
+ const current = a[index];
107
+ prev.size += delta;
108
+ current.offset += delta;
109
+ next.offset += delta;
110
+ next.size -= delta;
111
+ this.updateSize();
112
+ }
113
+ onPropertyChanged(name) {
114
+ switch (name) {
115
+ case "rows":
116
+ case "columns":
117
+ if (this.childrenReady) {
118
+ this.invalidate();
119
+ }
120
+ break;
121
+ }
122
+ }
123
+ onUpdateSize() {
124
+ if (!this.children) {
125
+ return;
126
+ }
127
+ for (const iterator of this.children) {
128
+ this.updateStyle(iterator);
129
+ }
130
+ }
131
+ preCreate() {
132
+ this.columns = null;
133
+ this.rows = null;
134
+ const style = this.element.style;
135
+ style.position = "absolute";
136
+ style.left = style.right = style.top = style.bottom = "0";
137
+ style.overflow = "hidden";
138
+ this.bindEvent(window, "resize", () => {
139
+ this.updateSize();
140
+ });
141
+ this.bindEvent(document.body, "resize", () => {
142
+ this.updateSize();
143
+ });
144
+ }
145
+ updateStyle(e) {
146
+ const {
147
+ colSpan,
148
+ column,
149
+ row,
150
+ rowSpan
151
+ } = AtomGridView.getCellInfo(e);
152
+ const host = e.parentElement;
153
+ if (!host) {
154
+ return;
155
+ }
156
+ host.style.position = "absolute";
157
+ host.style.overflow = "hidden";
158
+ host.style.padding = "0";
159
+ host.style.margin = "0";
160
+ if (this.rowSizes.length <= row || this.columnSizes.length <= column) {
161
+ return;
162
+ }
163
+ const rowStart = this.rowSizes[row].offset;
164
+ let rowSize = 0;
165
+ for (let i = row; i < row + rowSpan; i++) {
166
+ rowSize += this.rowSizes[i].size;
167
+ }
168
+ host.style.top = `${rowStart}px`;
169
+ host.style.height = `${rowSize}px`;
170
+ const colStart = this.columnSizes[column].offset;
171
+ let colSize = 0;
172
+ for (let i = column; i < column + colSpan; i++) {
173
+ colSize += this.columnSizes[i].size;
174
+ }
175
+ host.style.left = `${colStart}px`;
176
+ host.style.width = `${colSize}px`;
177
+ visitDescendents(host, (el, ac) => {
178
+ if (ac) {
179
+ ac.invalidate();
180
+ return false;
181
+ }
182
+ return true;
183
+ });
184
+ }
185
+ toSize(s, total) {
186
+ if (!s || s === "*") {
187
+ return {
188
+ offset: -1,
189
+ size: NaN
190
+ };
191
+ }
192
+ let n = 0;
193
+ if (s.endsWith("%")) {
194
+ s = s.substr(0, s.length - 1);
195
+ n = parseFloat(s);
196
+ return {
197
+ offset: -1,
198
+ size: total * n / 100
199
+ };
200
+ }
201
+ return {
202
+ offset: -1,
203
+ size: parseFloat(s)
204
+ };
205
+ }
206
+ assignOffsets(a, end) {
207
+ let start = 0;
208
+ let fill = null;
209
+ for (const item of a) {
210
+ item.offset = start;
211
+ if (isNaN(item.size)) {
212
+ fill = item;
213
+ break;
214
+ }
215
+ start += item.size;
216
+ }
217
+ if (!fill) {
218
+ return;
219
+ }
220
+ const lastStart = start;
221
+ start = end;
222
+ const r = a.map(x => x).reverse();
223
+ for (const item of r) {
224
+ if (isNaN(item.size)) {
225
+ if (fill !== item) {
226
+ throw new Error("Multiple * cannot be defined");
227
+ }
228
+ break;
229
+ }
230
+ start -= item.size;
231
+ item.offset = start;
226
232
  }
227
- }
228
- //# sourceMappingURL=AtomGridView.js.map
233
+ fill.offset = lastStart;
234
+ fill.size = start - lastStart;
235
+ }
236
+ }