verstak 0.23.125 → 0.24.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/source/archive/RxDomV1.js +5 -5
- package/build/dist/source/core/api.d.ts +0 -3
- package/build/dist/source/core/api.js +0 -3
- package/build/dist/source/html/El.d.ts +163 -0
- package/build/dist/source/html/El.js +508 -0
- package/build/dist/source/{core/Utils.d.ts → html/ElUtils.d.ts} +3 -4
- package/build/dist/source/{core/Utils.js → html/ElUtils.js} +14 -46
- package/build/dist/source/html/Elements.d.ts +8 -20
- package/build/dist/source/html/Elements.js +22 -200
- package/build/dist/source/html/HtmlDriver.d.ts +18 -15
- package/build/dist/source/html/HtmlDriver.js +31 -31
- package/build/dist/source/html/HtmlElements.d.ts +176 -175
- package/build/dist/source/html/HtmlElements.js +178 -177
- package/build/dist/source/html/ReactingFocuser.js +2 -2
- package/build/dist/source/html/api.d.ts +1 -0
- package/build/dist/source/html/api.js +1 -0
- package/build/dist/source/html/sensors/FocusSensor.js +1 -1
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/WindowSensor.js +1 -1
- package/package.json +2 -2
- package/build/dist/source/core/Interfaces.d.ts +0 -132
- package/build/dist/source/core/Interfaces.js +0 -34
- package/build/dist/source/core/Verstak.d.ts +0 -61
- package/build/dist/source/core/Verstak.js +0 -887
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { RxTree, BaseDriver } from "reactronic";
|
|
2
|
+
import { equalElCoords, parseElCoords } from "./ElUtils.js";
|
|
3
|
+
export class ElDriver extends BaseDriver {
|
|
4
|
+
allocate(node) {
|
|
5
|
+
return new ElImpl(node);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export var ElKind;
|
|
9
|
+
(function (ElKind) {
|
|
10
|
+
ElKind[ElKind["Section"] = 0] = "Section";
|
|
11
|
+
ElKind[ElKind["Table"] = 1] = "Table";
|
|
12
|
+
ElKind[ElKind["Note"] = 2] = "Note";
|
|
13
|
+
ElKind[ElKind["Group"] = 3] = "Group";
|
|
14
|
+
ElKind[ElKind["Part"] = 4] = "Part";
|
|
15
|
+
ElKind[ElKind["Cursor"] = 5] = "Cursor";
|
|
16
|
+
ElKind[ElKind["Native"] = 6] = "Native";
|
|
17
|
+
})(ElKind || (ElKind = {}));
|
|
18
|
+
export var Align;
|
|
19
|
+
(function (Align) {
|
|
20
|
+
Align[Align["Default"] = 16] = "Default";
|
|
21
|
+
Align[Align["ToBounds"] = 0] = "ToBounds";
|
|
22
|
+
Align[Align["ToLeft"] = 1] = "ToLeft";
|
|
23
|
+
Align[Align["ToCenterX"] = 2] = "ToCenterX";
|
|
24
|
+
Align[Align["ToRight"] = 3] = "ToRight";
|
|
25
|
+
Align[Align["ToTop"] = 4] = "ToTop";
|
|
26
|
+
Align[Align["ToCenterY"] = 8] = "ToCenterY";
|
|
27
|
+
Align[Align["ToBottom"] = 12] = "ToBottom";
|
|
28
|
+
Align[Align["ToCenter"] = 10] = "ToCenter";
|
|
29
|
+
})(Align || (Align = {}));
|
|
30
|
+
export class ElImpl {
|
|
31
|
+
constructor(node) {
|
|
32
|
+
this.node = node;
|
|
33
|
+
this.maxColumnCount = 0;
|
|
34
|
+
this.maxRowCount = 0;
|
|
35
|
+
this.cursorPosition = undefined;
|
|
36
|
+
this.native = undefined;
|
|
37
|
+
this.model = undefined;
|
|
38
|
+
this.controller = undefined;
|
|
39
|
+
this._kind = ElKind.Part;
|
|
40
|
+
this._area = undefined;
|
|
41
|
+
this._coords = UndefinedElCoords;
|
|
42
|
+
this._widthGrowth = 0;
|
|
43
|
+
this._minWidth = "";
|
|
44
|
+
this._maxWidth = "";
|
|
45
|
+
this._heightGrowth = 0;
|
|
46
|
+
this._minHeight = "";
|
|
47
|
+
this._maxHeight = "";
|
|
48
|
+
this._contentAlignment = Align.Default;
|
|
49
|
+
this._elementAlignment = Align.Default;
|
|
50
|
+
this._contentWrapping = true;
|
|
51
|
+
this._overlayVisible = undefined;
|
|
52
|
+
this._hasStyles = false;
|
|
53
|
+
}
|
|
54
|
+
prepareForUpdate() {
|
|
55
|
+
this._area = undefined;
|
|
56
|
+
this._hasStyles = false;
|
|
57
|
+
}
|
|
58
|
+
get isSection() { return this.kind === ElKind.Section; }
|
|
59
|
+
get isTable() { return this.kind === ElKind.Table; }
|
|
60
|
+
get isAuxiliary() { return this.kind > ElKind.Note; }
|
|
61
|
+
get kind() { return this._kind; }
|
|
62
|
+
set kind(value) {
|
|
63
|
+
if (value !== this._kind || this.node.stamp >= Number.MAX_SAFE_INTEGER - 1) {
|
|
64
|
+
if (this.native !== undefined)
|
|
65
|
+
Apply.kind(this, value);
|
|
66
|
+
this._kind = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
get area() { return this._area; }
|
|
70
|
+
set area(value) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
const node = this.node;
|
|
73
|
+
const driver = node.driver;
|
|
74
|
+
if (!driver.isPartitionSeparator) {
|
|
75
|
+
const owner = node.owner;
|
|
76
|
+
const ownerEl = owner.element;
|
|
77
|
+
const prevEl = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.element;
|
|
78
|
+
const cursorPosition = (_b = prevEl === null || prevEl === void 0 ? void 0 : prevEl.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
|
|
79
|
+
const newCursorPosition = this.cursorPosition = owner.children.isStrict ? new CursorPosition(cursorPosition) : undefined;
|
|
80
|
+
const isCursorElement = driver instanceof CursorCommandDriver;
|
|
81
|
+
const coords = getEffectiveElCoords(!isCursorElement, value, ownerEl.maxColumnCount, ownerEl.maxRowCount, cursorPosition, newCursorPosition);
|
|
82
|
+
if (!equalElCoords(coords, this._coords)) {
|
|
83
|
+
if (this.native !== undefined)
|
|
84
|
+
Apply.coords(this, coords);
|
|
85
|
+
this._coords = coords;
|
|
86
|
+
}
|
|
87
|
+
this._area = value !== null && value !== void 0 ? value : {};
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
this.rowBreak();
|
|
91
|
+
}
|
|
92
|
+
get widthGrowth() { return this._widthGrowth; }
|
|
93
|
+
set widthGrowth(value) {
|
|
94
|
+
if (value !== this._widthGrowth) {
|
|
95
|
+
Apply.widthGrowth(this, value);
|
|
96
|
+
this._widthGrowth = value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
get minWidth() { return this._minWidth; }
|
|
100
|
+
set minWidth(value) {
|
|
101
|
+
if (value !== this._minWidth) {
|
|
102
|
+
Apply.minWidth(this, value);
|
|
103
|
+
this._minWidth = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get maxWidth() { return this._maxWidth; }
|
|
107
|
+
set maxWidth(value) {
|
|
108
|
+
if (value !== this._maxWidth) {
|
|
109
|
+
Apply.applyMaxWidth(this, value);
|
|
110
|
+
this._maxWidth = value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
get heightGrowth() { return this._heightGrowth; }
|
|
114
|
+
set heightGrowth(value) {
|
|
115
|
+
if (value !== this._heightGrowth) {
|
|
116
|
+
Apply.heightGrowth(this, value);
|
|
117
|
+
this._heightGrowth = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
get minHeight() { return this._minHeight; }
|
|
121
|
+
set minHeight(value) {
|
|
122
|
+
if (value !== this._minHeight) {
|
|
123
|
+
Apply.minHeight(this, value);
|
|
124
|
+
this._minHeight = value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get maxHeight() { return this._maxHeight; }
|
|
128
|
+
set maxHeight(value) {
|
|
129
|
+
if (value !== this._maxHeight) {
|
|
130
|
+
Apply.maxHeight(this, value);
|
|
131
|
+
this._maxHeight = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
get contentAlignment() { return this._contentAlignment; }
|
|
135
|
+
set contentAlignment(value) {
|
|
136
|
+
if (value !== this._contentAlignment) {
|
|
137
|
+
Apply.contentAlignment(this, value);
|
|
138
|
+
this._contentAlignment = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
get elementAlignment() { return this._elementAlignment; }
|
|
142
|
+
set elementAlignment(value) {
|
|
143
|
+
if (value !== this._elementAlignment) {
|
|
144
|
+
Apply.elementAlignment(this, value);
|
|
145
|
+
this._elementAlignment = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
get contentWrapping() { return this._contentWrapping; }
|
|
149
|
+
set contentWrapping(value) {
|
|
150
|
+
if (value !== this._contentWrapping) {
|
|
151
|
+
Apply.contentWrapping(this, value);
|
|
152
|
+
this._contentWrapping = value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
get overlayVisible() { return this._overlayVisible; }
|
|
156
|
+
set overlayVisible(value) {
|
|
157
|
+
if (value !== this._overlayVisible) {
|
|
158
|
+
Apply.overlayVisible(this, value);
|
|
159
|
+
this._overlayVisible = value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
useStyle(styleName, enabled) {
|
|
163
|
+
Apply.style(this, this._hasStyles, styleName, enabled);
|
|
164
|
+
this._hasStyles = true;
|
|
165
|
+
}
|
|
166
|
+
rowBreak() {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
const node = this.node;
|
|
169
|
+
const prevEl = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.element;
|
|
170
|
+
const cursorPosition = (_b = prevEl === null || prevEl === void 0 ? void 0 : prevEl.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
|
|
171
|
+
const newCursorPosition = this.cursorPosition = new CursorPosition(cursorPosition);
|
|
172
|
+
newCursorPosition.x = 1;
|
|
173
|
+
newCursorPosition.y = newCursorPosition.runningMaxY + 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class CursorPosition {
|
|
177
|
+
constructor(prev) {
|
|
178
|
+
this.x = prev.x;
|
|
179
|
+
this.y = prev.y;
|
|
180
|
+
this.runningMaxX = prev.runningMaxX;
|
|
181
|
+
this.runningMaxY = prev.runningMaxY;
|
|
182
|
+
this.flags = prev.flags & ~CursorFlags.OwnCursorPosition;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
var CursorFlags;
|
|
186
|
+
(function (CursorFlags) {
|
|
187
|
+
CursorFlags[CursorFlags["None"] = 0] = "None";
|
|
188
|
+
CursorFlags[CursorFlags["OwnCursorPosition"] = 1] = "OwnCursorPosition";
|
|
189
|
+
CursorFlags[CursorFlags["UsesRunningColumnCount"] = 2] = "UsesRunningColumnCount";
|
|
190
|
+
CursorFlags[CursorFlags["UsesRunningRowCount"] = 4] = "UsesRunningRowCount";
|
|
191
|
+
})(CursorFlags || (CursorFlags = {}));
|
|
192
|
+
const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
193
|
+
const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
|
|
194
|
+
function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition, newCursorPosition) {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
let result;
|
|
197
|
+
if (typeof (area) === "string") {
|
|
198
|
+
result = parseElCoords(area, { x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
199
|
+
absolutizeElCoords(result, cursorPosition.x, cursorPosition.y, maxX || Infinity, maxY || Infinity, result);
|
|
200
|
+
if (newCursorPosition) {
|
|
201
|
+
newCursorPosition.x = isRegularElement ? result.x2 + 1 : result.x1;
|
|
202
|
+
newCursorPosition.y = result.y1;
|
|
203
|
+
newCursorPosition.flags = CursorFlags.OwnCursorPosition;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (newCursorPosition) {
|
|
207
|
+
let dx;
|
|
208
|
+
let dy;
|
|
209
|
+
if (area) {
|
|
210
|
+
dx = (_a = area.cellsOverWidth) !== null && _a !== void 0 ? _a : 1;
|
|
211
|
+
dy = (_b = area.cellsOverHeight) !== null && _b !== void 0 ? _b : 1;
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
dx = dy = 1;
|
|
215
|
+
const runningX = maxX !== 0 ? maxX : cursorPosition.runningMaxX;
|
|
216
|
+
const runningY = maxY !== 0 ? maxY : cursorPosition.runningMaxY;
|
|
217
|
+
result = { x1: 0, y1: 0, x2: 0, y2: 0 };
|
|
218
|
+
if (dx === 0 && isRegularElement) {
|
|
219
|
+
dx = runningX || 1;
|
|
220
|
+
newCursorPosition.flags = CursorFlags.UsesRunningColumnCount;
|
|
221
|
+
}
|
|
222
|
+
if (dx >= 0) {
|
|
223
|
+
if (isRegularElement) {
|
|
224
|
+
result.x1 = cursorPosition.x;
|
|
225
|
+
result.x2 = absolutizePosition(result.x1 + dx - 1, 0, maxX || Infinity);
|
|
226
|
+
newCursorPosition.x = result.x2 + 1;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
result.x1 = result.x2 = cursorPosition.x + dx;
|
|
230
|
+
newCursorPosition.x = result.x2;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (isRegularElement) {
|
|
235
|
+
result.x1 = Math.max(cursorPosition.x + dx, 1);
|
|
236
|
+
result.x2 = cursorPosition.x;
|
|
237
|
+
newCursorPosition.x = result.x2 + 1;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
result.x1 = result.x2 = cursorPosition.x + dx;
|
|
241
|
+
newCursorPosition.x = result.x2;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (dy === 0 && isRegularElement) {
|
|
245
|
+
dy = runningY || 1;
|
|
246
|
+
newCursorPosition.flags |= CursorFlags.UsesRunningRowCount;
|
|
247
|
+
}
|
|
248
|
+
if (dy >= 0) {
|
|
249
|
+
if (isRegularElement) {
|
|
250
|
+
result.y1 = cursorPosition.y;
|
|
251
|
+
result.y2 = absolutizePosition(result.y1 + dy - 1, 0, maxY || Infinity);
|
|
252
|
+
if (result.y2 > newCursorPosition.runningMaxY)
|
|
253
|
+
newCursorPosition.runningMaxY = result.y2;
|
|
254
|
+
}
|
|
255
|
+
else
|
|
256
|
+
result.y1 = result.y2 = cursorPosition.y + dy;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
if (isRegularElement) {
|
|
260
|
+
result.y1 = Math.max(cursorPosition.y + dy, 1);
|
|
261
|
+
result.y2 = cursorPosition.y;
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
result.y1 = result.y2 = cursorPosition.y + dy;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else
|
|
268
|
+
throw new Error("relative layout requires sequential children");
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
function absolutizeElCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
|
|
272
|
+
const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
|
|
273
|
+
const x2 = absolutizePosition(area.x2, x1, maxWidth);
|
|
274
|
+
if (x1 <= x2)
|
|
275
|
+
result.x1 = x1, result.x2 = x2;
|
|
276
|
+
else
|
|
277
|
+
result.x1 = x2, result.x2 = x1;
|
|
278
|
+
const y1 = absolutizePosition(area.y1, cursorY, maxHeight);
|
|
279
|
+
const y2 = absolutizePosition(area.y2, y1, maxHeight);
|
|
280
|
+
if (y1 <= y2)
|
|
281
|
+
result.y1 = y1, result.y2 = y2;
|
|
282
|
+
else
|
|
283
|
+
result.y1 = y2, result.y2 = y1;
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
function absolutizePosition(pos, cursor, max) {
|
|
287
|
+
if (pos === 0)
|
|
288
|
+
pos = cursor;
|
|
289
|
+
else if (pos < 0)
|
|
290
|
+
pos = Math.max(max + pos, 1);
|
|
291
|
+
else
|
|
292
|
+
pos = Math.min(pos, max);
|
|
293
|
+
return pos;
|
|
294
|
+
}
|
|
295
|
+
export class CursorCommand {
|
|
296
|
+
}
|
|
297
|
+
export class CursorCommandDriver extends ElDriver {
|
|
298
|
+
constructor() {
|
|
299
|
+
super("cursor", false, el => el.kind = ElKind.Cursor);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
export class Apply {
|
|
303
|
+
static kind(element, value) {
|
|
304
|
+
const kind = Constants.layouts[value];
|
|
305
|
+
kind && element.native.setAttribute(Constants.kindAttrName, kind);
|
|
306
|
+
VerstakDriversByLayout[value](element);
|
|
307
|
+
}
|
|
308
|
+
static coords(element, value) {
|
|
309
|
+
if (element.native instanceof HTMLElement) {
|
|
310
|
+
const s = element.native.style;
|
|
311
|
+
if (value) {
|
|
312
|
+
const x1 = value.x1 || 1;
|
|
313
|
+
const y1 = value.y1 || 1;
|
|
314
|
+
const x2 = value.x2 || x1;
|
|
315
|
+
const y2 = value.y2 || y1;
|
|
316
|
+
s.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
|
|
317
|
+
}
|
|
318
|
+
else
|
|
319
|
+
s.gridArea = "";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
static widthGrowth(element, value) {
|
|
323
|
+
if (element.native instanceof HTMLElement) {
|
|
324
|
+
const s = element.native.style;
|
|
325
|
+
if (value > 0) {
|
|
326
|
+
s.flexGrow = `${value}`;
|
|
327
|
+
s.flexBasis = "0";
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
s.flexGrow = "";
|
|
331
|
+
s.flexBasis = "";
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
static minWidth(element, value) {
|
|
336
|
+
if (element.native instanceof HTMLElement)
|
|
337
|
+
element.native.style.minWidth = `${value}`;
|
|
338
|
+
}
|
|
339
|
+
static applyMaxWidth(element, value) {
|
|
340
|
+
if (element.native instanceof HTMLElement)
|
|
341
|
+
element.native.style.maxWidth = `${value}`;
|
|
342
|
+
}
|
|
343
|
+
static heightGrowth(element, value) {
|
|
344
|
+
const bNode = element.node;
|
|
345
|
+
const driver = bNode.driver;
|
|
346
|
+
if (driver.isPartitionSeparator) {
|
|
347
|
+
if (element.native instanceof HTMLElement) {
|
|
348
|
+
const s = element.native.style;
|
|
349
|
+
if (value > 0)
|
|
350
|
+
s.flexGrow = `${value}`;
|
|
351
|
+
else
|
|
352
|
+
s.flexGrow = "";
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const hostDriver = bNode.host.driver;
|
|
357
|
+
if (hostDriver.isPartitionSeparator) {
|
|
358
|
+
Apply.elementAlignment(element, Align.ToBounds);
|
|
359
|
+
Apply.heightGrowth(bNode.host.slot.instance.element, value);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
static minHeight(element, value) {
|
|
364
|
+
if (element.native instanceof HTMLElement)
|
|
365
|
+
element.native.style.minHeight = `${value}`;
|
|
366
|
+
}
|
|
367
|
+
static maxHeight(element, value) {
|
|
368
|
+
if (element.native instanceof HTMLElement)
|
|
369
|
+
element.native.style.maxHeight = `${value}`;
|
|
370
|
+
}
|
|
371
|
+
static contentAlignment(element, value) {
|
|
372
|
+
if (element.native instanceof HTMLElement) {
|
|
373
|
+
const s = element.native.style;
|
|
374
|
+
if ((value & Align.Default) === 0) {
|
|
375
|
+
const v = AlignToCss[(value >> 2) & 0b11];
|
|
376
|
+
const h = AlignToCss[value & 0b11];
|
|
377
|
+
const t = TextAlignCss[value & 0b11];
|
|
378
|
+
s.justifyContent = v;
|
|
379
|
+
s.alignItems = h;
|
|
380
|
+
s.textAlign = t;
|
|
381
|
+
}
|
|
382
|
+
else
|
|
383
|
+
s.justifyContent = s.alignContent = s.textAlign = "";
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
static elementAlignment(element, value) {
|
|
387
|
+
if (element.native instanceof HTMLElement) {
|
|
388
|
+
const s = element.native.style;
|
|
389
|
+
if ((value & Align.Default) === 0) {
|
|
390
|
+
const v = AlignToCss[(value >> 2) & 0b11];
|
|
391
|
+
const h = AlignToCss[value & 0b11];
|
|
392
|
+
s.alignSelf = v;
|
|
393
|
+
s.justifySelf = h;
|
|
394
|
+
}
|
|
395
|
+
else
|
|
396
|
+
s.alignSelf = s.justifySelf = "";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
static contentWrapping(element, value) {
|
|
400
|
+
if (element.native instanceof HTMLElement) {
|
|
401
|
+
const s = element.native.style;
|
|
402
|
+
if (value) {
|
|
403
|
+
s.flexFlow = "wrap";
|
|
404
|
+
s.overflow = "";
|
|
405
|
+
s.textOverflow = "";
|
|
406
|
+
s.whiteSpace = "";
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
s.flexFlow = "";
|
|
410
|
+
s.overflow = "hidden";
|
|
411
|
+
s.textOverflow = "ellipsis";
|
|
412
|
+
s.whiteSpace = "nowrap";
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
static overlayVisible(element, value) {
|
|
417
|
+
const e = element.native;
|
|
418
|
+
if (e instanceof HTMLElement) {
|
|
419
|
+
const s = e.style;
|
|
420
|
+
const host = RxTree.findMatchingHost(element.node, n => n.element.native instanceof HTMLElement || n.element.native instanceof SVGElement);
|
|
421
|
+
const nativeHost = host === null || host === void 0 ? void 0 : host.element.native;
|
|
422
|
+
if (value === true) {
|
|
423
|
+
const doc = document.body;
|
|
424
|
+
const rect = nativeHost.getBoundingClientRect();
|
|
425
|
+
if (doc.offsetWidth - rect.left > rect.right)
|
|
426
|
+
s.left = "0", s.right = "";
|
|
427
|
+
else
|
|
428
|
+
s.left = "", s.right = "0";
|
|
429
|
+
if (doc.clientHeight - rect.top > rect.bottom)
|
|
430
|
+
s.top = "100%", s.bottom = "";
|
|
431
|
+
else
|
|
432
|
+
s.top = "", s.bottom = "100%";
|
|
433
|
+
s.display = "";
|
|
434
|
+
s.position = "absolute";
|
|
435
|
+
s.minWidth = "100%";
|
|
436
|
+
s.boxSizing = "border-box";
|
|
437
|
+
nativeHost.style.position = "relative";
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
nativeHost.style.position = "";
|
|
441
|
+
if (value === false)
|
|
442
|
+
s.display = "none";
|
|
443
|
+
else
|
|
444
|
+
s.position = s.display = s.left = s.right = s.top = s.bottom = "";
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
static style(element, secondary, styleName, enabled) {
|
|
449
|
+
const native = element.native;
|
|
450
|
+
enabled !== null && enabled !== void 0 ? enabled : (enabled = true);
|
|
451
|
+
if (secondary)
|
|
452
|
+
native.classList.toggle(styleName, enabled);
|
|
453
|
+
else
|
|
454
|
+
native.className = enabled ? styleName : "";
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
export const Constants = {
|
|
458
|
+
element: "element",
|
|
459
|
+
partition: "partition",
|
|
460
|
+
layouts: ["section", "table", "note", "group", "", ""],
|
|
461
|
+
keyAttrName: "key",
|
|
462
|
+
kindAttrName: "kind",
|
|
463
|
+
};
|
|
464
|
+
const VerstakDriversByLayout = [
|
|
465
|
+
el => {
|
|
466
|
+
const owner = el.node.owner.element;
|
|
467
|
+
const s = el.native.style;
|
|
468
|
+
s.display = "flex";
|
|
469
|
+
s.flexDirection = "column";
|
|
470
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
471
|
+
s.textAlign = "initial";
|
|
472
|
+
s.flexShrink = "1";
|
|
473
|
+
s.minWidth = "0";
|
|
474
|
+
},
|
|
475
|
+
el => {
|
|
476
|
+
const owner = el.node.owner.element;
|
|
477
|
+
const s = el.native.style;
|
|
478
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
479
|
+
s.display = "grid";
|
|
480
|
+
s.flexBasis = "0";
|
|
481
|
+
s.gridAutoRows = "minmax(min-content, 1fr)";
|
|
482
|
+
s.gridAutoColumns = "minmax(min-content, 1fr)";
|
|
483
|
+
s.textAlign = "initial";
|
|
484
|
+
},
|
|
485
|
+
el => {
|
|
486
|
+
const owner = el.node.owner.element;
|
|
487
|
+
const s = el.native.style;
|
|
488
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
489
|
+
s.display = "inline-grid";
|
|
490
|
+
s.flexShrink = "1";
|
|
491
|
+
},
|
|
492
|
+
el => {
|
|
493
|
+
const s = el.native.style;
|
|
494
|
+
s.display = "contents";
|
|
495
|
+
},
|
|
496
|
+
el => {
|
|
497
|
+
const owner = el.node.owner.element;
|
|
498
|
+
const s = el.native.style;
|
|
499
|
+
s.display = owner.isTable ? "contents" : "flex";
|
|
500
|
+
s.flexDirection = "row";
|
|
501
|
+
},
|
|
502
|
+
el => {
|
|
503
|
+
},
|
|
504
|
+
el => {
|
|
505
|
+
},
|
|
506
|
+
];
|
|
507
|
+
const AlignToCss = ["stretch", "start", "center", "end"];
|
|
508
|
+
const TextAlignCss = ["justify", "left", "center", "right"];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ElCoords } from "./
|
|
1
|
+
import { ElCoords } from "./El.js";
|
|
2
|
+
export declare function objectHasMember<T>(obj: any, member: string): obj is T;
|
|
3
|
+
export declare function emitLetters(n: number): string;
|
|
2
4
|
export declare function parseElCoords(text: string, result: ElCoords): ElCoords;
|
|
3
5
|
export declare function emitElCoords(value: ElCoords): string;
|
|
4
|
-
export declare function emitLetters(n: number): string;
|
|
5
6
|
export declare function emitCellPosition(x: number, y: number): string;
|
|
6
7
|
export declare function equalElCoords(a: ElCoords, b: ElCoords): boolean;
|
|
7
|
-
export declare function objectHasMember<T>(obj: any, member: string): obj is T;
|
|
8
|
-
export declare function getCallerInfo(prefix: string): string;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export function objectHasMember(obj, member) {
|
|
2
|
+
return obj === Object(obj) && !Array.isArray(obj) && member in obj;
|
|
3
|
+
}
|
|
4
|
+
export function emitLetters(n) {
|
|
5
|
+
if (n < 0)
|
|
6
|
+
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
7
|
+
let result = "";
|
|
8
|
+
while (n >= 0) {
|
|
9
|
+
const r = n % 26;
|
|
10
|
+
n = Math.floor(n / 26) - 1;
|
|
11
|
+
result = String.fromCharCode(65 + r) + result;
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
1
15
|
export function parseElCoords(text, result) {
|
|
2
16
|
let i = 0;
|
|
3
17
|
let value = 0;
|
|
@@ -134,17 +148,6 @@ export function emitElCoords(value) {
|
|
|
134
148
|
const p2 = emitCellPosition(value.x2, value.y2);
|
|
135
149
|
return `${p1}${p2 !== "" ? `:${p2}` : ""}`;
|
|
136
150
|
}
|
|
137
|
-
export function emitLetters(n) {
|
|
138
|
-
if (n < 0)
|
|
139
|
-
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
140
|
-
let result = "";
|
|
141
|
-
while (n >= 0) {
|
|
142
|
-
const r = n % 26;
|
|
143
|
-
n = Math.floor(n / 26) - 1;
|
|
144
|
-
result = String.fromCharCode(65 + r) + result;
|
|
145
|
-
}
|
|
146
|
-
return result;
|
|
147
|
-
}
|
|
148
151
|
export function emitCellPosition(x, y) {
|
|
149
152
|
let result = "";
|
|
150
153
|
if (x > 0 && y > 0)
|
|
@@ -174,38 +177,3 @@ function isCapitalLetter(ch) {
|
|
|
174
177
|
function isLowercaseLetter(ch) {
|
|
175
178
|
return 97 <= ch && ch <= 122;
|
|
176
179
|
}
|
|
177
|
-
export function objectHasMember(obj, member) {
|
|
178
|
-
return obj === Object(obj) && !Array.isArray(obj) && member in obj;
|
|
179
|
-
}
|
|
180
|
-
export function getCallerInfo(prefix) {
|
|
181
|
-
const restore = Error.stackTraceLimit = 20;
|
|
182
|
-
const error = new Error();
|
|
183
|
-
const stack = error.stack || "";
|
|
184
|
-
Error.stackTraceLimit = restore;
|
|
185
|
-
const lines = stack.split("\n");
|
|
186
|
-
let i = lines.findIndex(x => x.indexOf(".specify") >= 0);
|
|
187
|
-
i = i >= 0 ? i + 2 : 5;
|
|
188
|
-
let caller = extractFunctionAndLocation(lines[i]);
|
|
189
|
-
let location = caller;
|
|
190
|
-
if (caller.func.endsWith(".update")) {
|
|
191
|
-
i = i - 1;
|
|
192
|
-
caller = extractFunctionAndLocation(lines[i]);
|
|
193
|
-
location = extractFunctionAndLocation(lines[i + 1]);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
while (!caller.func && i > 0) {
|
|
197
|
-
i = i - 1;
|
|
198
|
-
caller = extractFunctionAndLocation(lines[i]);
|
|
199
|
-
}
|
|
200
|
-
location = extractFunctionAndLocation(lines[i + 1]);
|
|
201
|
-
}
|
|
202
|
-
const result = `${prefix}·${caller.func}@${location.file}`;
|
|
203
|
-
return result;
|
|
204
|
-
}
|
|
205
|
-
function extractFunctionAndLocation(s) {
|
|
206
|
-
const match = s.match(/(?:\s*at\s+)?(?:(\S+)\s\()?(?:.*?)([^\/\(\):]+)(?:(:|\d)*\)?)$/);
|
|
207
|
-
return {
|
|
208
|
-
func: (match === null || match === void 0 ? void 0 : match[1]) || "",
|
|
209
|
-
file: (match === null || match === void 0 ? void 0 : match[2]) || "",
|
|
210
|
-
};
|
|
211
|
-
}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RxNodeDecl } from "reactronic";
|
|
2
|
+
import { El, ElArea } from "./El.js";
|
|
2
3
|
import { HtmlDriver } from "./HtmlDriver.js";
|
|
3
|
-
export declare function Section<M = unknown, R = void>(
|
|
4
|
-
export declare function Table<M = unknown, R = void>(
|
|
4
|
+
export declare function Section<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M, R>>, preset?: RxNodeDecl<El<HTMLElement, M, R>>): El<HTMLElement, M, R>;
|
|
5
|
+
export declare function Table<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M, R>>, preset?: RxNodeDecl<El<HTMLElement, M, R>>): El<HTMLElement, M, R>;
|
|
5
6
|
export declare function row<T = void>(builder?: (element: void) => T, shiftCursorDown?: number): void;
|
|
6
7
|
export declare function startNewRow(shiftCursorDown?: number): void;
|
|
7
8
|
export declare function cursor(areaParams: ElArea): void;
|
|
8
|
-
export declare function Note(content: string,
|
|
9
|
-
export declare function HtmlNote(content: string,
|
|
10
|
-
export declare function Group<M = unknown, R = void>(
|
|
11
|
-
export declare function Fragment<M = unknown, R = void>(
|
|
9
|
+
export declare function Note(content: string, declaration?: RxNodeDecl<El<HTMLElement, void, void>>): El<HTMLElement, void, void>;
|
|
10
|
+
export declare function HtmlNote(content: string, declaration?: RxNodeDecl<El<HTMLElement, void, void>>): El<HTMLElement, void, void>;
|
|
11
|
+
export declare function Group<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M, R>>, preset?: RxNodeDecl<El<HTMLElement, M, R>>): El<HTMLElement, M, R>;
|
|
12
|
+
export declare function Fragment<M = unknown, R = void>(declaration?: RxNodeDecl<El<void, M, R>>, preset?: RxNodeDecl<El<void, M, R>>): El<void, M, R>;
|
|
12
13
|
export declare class VerstakHtmlDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
13
|
-
applyKind(element: El<T, any, any>, value: ElKind): void;
|
|
14
|
-
applyCoords(element: El<T>, value: ElCoords | undefined): void;
|
|
15
|
-
applyWidthGrowth(element: El<T>, value: number): void;
|
|
16
|
-
applyMinWidth(element: El<T>, value: string): void;
|
|
17
|
-
applyMaxWidth(element: El<T>, value: string): void;
|
|
18
|
-
applyHeightGrowth(element: El<T>, value: number): void;
|
|
19
|
-
applyMinHeight(element: El<T>, value: string): void;
|
|
20
|
-
applyMaxHeight(element: El<T>, value: string): void;
|
|
21
|
-
applyContentAlignment(element: El<T>, value: Align): void;
|
|
22
|
-
applyElementAlignment(element: El<T>, value: Align): void;
|
|
23
|
-
applyContentWrapping(element: El<T>, value: boolean): void;
|
|
24
|
-
applyOverlayVisible(element: El<T>, value: boolean | undefined): void;
|
|
25
|
-
applyStyle(element: El<T, any, any>, secondary: boolean, styleName: string, enabled?: boolean): void;
|
|
26
14
|
update(element: El<T>): void | Promise<void>;
|
|
27
15
|
}
|