verstak 0.22.512 → 0.22.515
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/core/VBlock.d.ts +21 -20
- package/build/dist/source/core/VBlock.js +79 -75
- package/build/dist/source/html/Blocks.d.ts +15 -15
- package/build/dist/source/html/Blocks.js +42 -44
- package/build/dist/source/html/HtmlBlocks.d.ts +174 -174
- package/build/dist/source/html/HtmlBlocks.js +176 -176
- package/build/dist/source/html/HtmlDriver.js +1 -1
- package/build/dist/source/html/ReactingFocuser.d.ts +1 -1
- package/build/dist/source/html/ReactingFocuser.js +2 -2
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ export declare const enum Priority {
|
|
|
12
12
|
export declare type Type<T> = new (...args: any[]) => T;
|
|
13
13
|
export declare type BlockBody<T = unknown, M = unknown, R = void> = Render<T, M, R> | BlockVmt<T, M, R>;
|
|
14
14
|
export interface BlockVmt<T = unknown, M = unknown, R = void> {
|
|
15
|
+
key?: string;
|
|
15
16
|
reacting?: boolean;
|
|
16
17
|
triggers?: unknown;
|
|
17
18
|
initialize?: Render<T, M, R>;
|
|
@@ -19,7 +20,7 @@ export interface BlockVmt<T = unknown, M = unknown, R = void> {
|
|
|
19
20
|
render?: Render<T, M, R>;
|
|
20
21
|
finalize?: Render<T, M, R>;
|
|
21
22
|
}
|
|
22
|
-
export declare function
|
|
23
|
+
export declare function asBaseFor<T, M, R>(outer: BlockBody<T, M, R> | undefined, base: BlockBody<T, M, R>): BlockVmt<T, M, R>;
|
|
23
24
|
export declare function setContext<T extends Object>(type: Type<T>, context: T): void;
|
|
24
25
|
export declare function use<T extends Object>(type: Type<T>): T;
|
|
25
26
|
export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
@@ -27,22 +28,22 @@ export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
|
27
28
|
static readonly longFrameDuration = 300;
|
|
28
29
|
static currentRenderingPriority: Priority;
|
|
29
30
|
static frameDuration: number;
|
|
30
|
-
abstract readonly
|
|
31
|
+
abstract readonly key: string;
|
|
31
32
|
abstract readonly driver: AbstractDriver<T>;
|
|
32
33
|
abstract readonly body: Readonly<BlockVmt<T, M, R>>;
|
|
33
34
|
abstract model: M;
|
|
34
35
|
abstract cells: Cells;
|
|
35
36
|
abstract widthGrowth: number;
|
|
36
|
-
abstract
|
|
37
|
-
abstract
|
|
37
|
+
abstract minWidth: string;
|
|
38
|
+
abstract maxWidth: string;
|
|
38
39
|
abstract heightGrowth: number;
|
|
39
|
-
abstract
|
|
40
|
-
abstract
|
|
41
|
-
abstract
|
|
42
|
-
abstract
|
|
43
|
-
abstract
|
|
44
|
-
abstract
|
|
45
|
-
abstract
|
|
40
|
+
abstract minHeight: string;
|
|
41
|
+
abstract maxHeight: string;
|
|
42
|
+
abstract contentAlignment: Align;
|
|
43
|
+
abstract frameAlignment: Align;
|
|
44
|
+
abstract contentWrapping: boolean;
|
|
45
|
+
abstract floating: boolean;
|
|
46
|
+
abstract childrenShuffling: boolean;
|
|
46
47
|
abstract renderingPriority?: Priority;
|
|
47
48
|
abstract readonly level: number;
|
|
48
49
|
abstract readonly host: VBlock;
|
|
@@ -56,7 +57,7 @@ export declare abstract class VBlock<T = unknown, M = unknown, R = void> {
|
|
|
56
57
|
static get current(): VBlock;
|
|
57
58
|
static renderNestedTreesThenDo(action: (error: unknown) => void): void;
|
|
58
59
|
static runForAllBlocks<T>(action: (e: T) => void): void;
|
|
59
|
-
static claim<T = undefined, M = unknown, R = void>(
|
|
60
|
+
static claim<T = undefined, M = unknown, R = void>(driver: AbstractDriver<T> | undefined, body: BlockBody<T, M, R>): VBlock<T, M, R>;
|
|
60
61
|
static getDefaultLoggingOptions(): LoggingOptions | undefined;
|
|
61
62
|
static setDefaultLoggingOptions(logging?: LoggingOptions): void;
|
|
62
63
|
}
|
|
@@ -83,15 +84,15 @@ export declare class AbstractDriver<T> {
|
|
|
83
84
|
deploy(block: VBlock<T>, sequential: boolean): void;
|
|
84
85
|
applyCellRange(block: VBlock<T, any, any>, cellRange: CellRange | undefined): void;
|
|
85
86
|
applyWidthGrowth(block: VBlock<T, any, any>, widthGrowth: number): void;
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
applyMinWidth(block: VBlock<T, any, any>, minWidth: string): void;
|
|
88
|
+
applyMaxWidth(block: VBlock<T, any, any>, maxWidth: string): void;
|
|
88
89
|
applyHeightGrowth(block: VBlock<T, any, any>, heightGrowth: number): void;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
applyMinHeight(block: VBlock<T, any, any>, minHeight: string): void;
|
|
91
|
+
applyMaxHeight(block: VBlock<T, any, any>, maxHeight: string): void;
|
|
92
|
+
applyContentAlignment(block: VBlock<T, any, any>, contentAlignment: Align): void;
|
|
93
|
+
applyFrameAlignment(block: VBlock<T, any, any>, frameAlignment: Align): void;
|
|
94
|
+
applyContentWrapping(block: VBlock<T, any, any>, contentWrapping: boolean): void;
|
|
95
|
+
applyFloating(block: VBlock<T, any, any>, floating: boolean): void;
|
|
95
96
|
render(block: VBlock<T>): void | Promise<void>;
|
|
96
97
|
}
|
|
97
98
|
export declare class StaticDriver<T> extends AbstractDriver<T> {
|
|
@@ -25,7 +25,7 @@ export var Priority;
|
|
|
25
25
|
Priority[Priority["AsyncP1"] = 1] = "AsyncP1";
|
|
26
26
|
Priority[Priority["AsyncP2"] = 2] = "AsyncP2";
|
|
27
27
|
})(Priority || (Priority = {}));
|
|
28
|
-
export function
|
|
28
|
+
export function asBaseFor(outer, base) {
|
|
29
29
|
if (outer instanceof Function)
|
|
30
30
|
outer = { render: outer };
|
|
31
31
|
if (base instanceof Function)
|
|
@@ -60,22 +60,22 @@ export class VBlock {
|
|
|
60
60
|
static runForAllBlocks(action) {
|
|
61
61
|
forEachChildRecursively(gSysRoot, action);
|
|
62
62
|
}
|
|
63
|
-
static claim(
|
|
63
|
+
static claim(driver, body) {
|
|
64
64
|
var _a, _b;
|
|
65
|
-
if (body instanceof Function)
|
|
66
|
-
body = { render: body };
|
|
67
65
|
let result;
|
|
68
66
|
const owner = gCurrent.instance;
|
|
69
67
|
const children = owner.children;
|
|
70
68
|
let ex = undefined;
|
|
71
69
|
driver !== null && driver !== void 0 ? driver : (driver = AbstractDriver.group);
|
|
72
|
-
|
|
70
|
+
if (body instanceof Function)
|
|
71
|
+
body = { render: body };
|
|
72
|
+
let key = body.key;
|
|
73
73
|
if (driver.isRow) {
|
|
74
74
|
const last = children.lastClaimedItem();
|
|
75
75
|
if (((_a = last === null || last === void 0 ? void 0 : last.instance) === null || _a === void 0 ? void 0 : _a.driver) === driver)
|
|
76
76
|
ex = last;
|
|
77
77
|
}
|
|
78
|
-
ex !== null && ex !== void 0 ? ex : (ex = children.claim(
|
|
78
|
+
ex !== null && ex !== void 0 ? ex : (ex = children.claim(key = key || `${++owner.numerator}!`, undefined, "nested blocks can be declared inside render function only"));
|
|
79
79
|
if (ex) {
|
|
80
80
|
result = ex.instance;
|
|
81
81
|
if (result.driver !== driver && driver !== undefined)
|
|
@@ -86,7 +86,7 @@ export class VBlock {
|
|
|
86
86
|
result.body = body;
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
result = new VBlockImpl(
|
|
89
|
+
result = new VBlockImpl(key || `${++owner.numerator}!`, driver, owner, body);
|
|
90
90
|
result.item = children.add(result);
|
|
91
91
|
VBlockImpl.grandCount++;
|
|
92
92
|
if (body.reacting)
|
|
@@ -144,23 +144,23 @@ export class AbstractDriver {
|
|
|
144
144
|
}
|
|
145
145
|
applyWidthGrowth(block, widthGrowth) {
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
applyMinWidth(block, minWidth) {
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
applyMaxWidth(block, maxWidth) {
|
|
150
150
|
}
|
|
151
151
|
applyHeightGrowth(block, heightGrowth) {
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
applyMinHeight(block, minHeight) {
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
applyMaxHeight(block, maxHeight) {
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
applyContentAlignment(block, contentAlignment) {
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
applyFrameAlignment(block, frameAlignment) {
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
applyContentWrapping(block, contentWrapping) {
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
applyFloating(block, floating) {
|
|
164
164
|
}
|
|
165
165
|
render(block) {
|
|
166
166
|
var _a;
|
|
@@ -188,8 +188,8 @@ export class StaticDriver extends AbstractDriver {
|
|
|
188
188
|
super.initialize(block, this.element);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
return block.stamp >= 0 ? block.
|
|
191
|
+
function getBlockKey(block) {
|
|
192
|
+
return block.stamp >= 0 ? block.key : undefined;
|
|
193
193
|
}
|
|
194
194
|
class VBlockContext extends ObservableObject {
|
|
195
195
|
constructor(type, instance) {
|
|
@@ -203,29 +203,29 @@ __decorate([
|
|
|
203
203
|
__metadata("design:type", Object)
|
|
204
204
|
], VBlockContext.prototype, "type", void 0);
|
|
205
205
|
class VBlockImpl extends VBlock {
|
|
206
|
-
constructor(
|
|
206
|
+
constructor(key, driver, owner, body) {
|
|
207
207
|
super();
|
|
208
|
-
this.
|
|
208
|
+
this.key = key;
|
|
209
209
|
this.driver = driver;
|
|
210
210
|
this.body = body;
|
|
211
211
|
this.model = undefined;
|
|
212
212
|
this.assignedCells = undefined;
|
|
213
213
|
this.appliedCellRange = Cursor.UndefinedCellRange;
|
|
214
214
|
this.appliedWidthGrowth = 0;
|
|
215
|
-
this.
|
|
216
|
-
this.
|
|
215
|
+
this.appliedMinWidth = "";
|
|
216
|
+
this.appliedMaxWidth = "";
|
|
217
217
|
this.appliedHeightGrowth = 0;
|
|
218
|
-
this.
|
|
219
|
-
this.
|
|
220
|
-
this.
|
|
221
|
-
this.
|
|
222
|
-
this.
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
218
|
+
this.appliedMinHeight = "";
|
|
219
|
+
this.appliedMaxHeight = "";
|
|
220
|
+
this.appliedContentAlignment = Align.Default;
|
|
221
|
+
this.appliedFrameAlignment = Align.Default;
|
|
222
|
+
this.appliedContentWrapping = false;
|
|
223
|
+
this.appliedFloating = false;
|
|
224
|
+
this.childrenShuffling = false;
|
|
225
225
|
this.renderingPriority = Priority.SyncP0;
|
|
226
226
|
this.level = owner.level + 1;
|
|
227
227
|
this.host = owner;
|
|
228
|
-
this.children = new Collection(driver.isSequential,
|
|
228
|
+
this.children = new Collection(driver.isSequential, getBlockKey);
|
|
229
229
|
this.numerator = 0;
|
|
230
230
|
this.item = undefined;
|
|
231
231
|
this.stamp = 0;
|
|
@@ -255,18 +255,18 @@ class VBlockImpl extends VBlock {
|
|
|
255
255
|
this.appliedWidthGrowth = value;
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
get
|
|
259
|
-
set
|
|
260
|
-
if (value !== this.
|
|
261
|
-
this.driver.
|
|
262
|
-
this.
|
|
258
|
+
get minWidth() { return this.appliedMinWidth; }
|
|
259
|
+
set minWidth(value) {
|
|
260
|
+
if (value !== this.appliedMinWidth) {
|
|
261
|
+
this.driver.applyMinWidth(this, value);
|
|
262
|
+
this.appliedMinWidth = value;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
get
|
|
266
|
-
set
|
|
267
|
-
if (value !== this.
|
|
268
|
-
this.driver.
|
|
269
|
-
this.
|
|
265
|
+
get maxWidth() { return this.appliedMaxWidth; }
|
|
266
|
+
set maxWidth(value) {
|
|
267
|
+
if (value !== this.appliedMaxWidth) {
|
|
268
|
+
this.driver.applyMaxWidth(this, value);
|
|
269
|
+
this.appliedMaxWidth = value;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
get heightGrowth() { return this.appliedHeightGrowth; }
|
|
@@ -276,46 +276,46 @@ class VBlockImpl extends VBlock {
|
|
|
276
276
|
this.appliedHeightGrowth = value;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
get
|
|
280
|
-
set
|
|
281
|
-
if (value !== this.
|
|
282
|
-
this.driver.
|
|
283
|
-
this.
|
|
279
|
+
get minHeight() { return this.appliedMinHeight; }
|
|
280
|
+
set minHeight(value) {
|
|
281
|
+
if (value !== this.appliedMinWidth) {
|
|
282
|
+
this.driver.applyMinWidth(this, value);
|
|
283
|
+
this.appliedMinWidth = value;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
get
|
|
287
|
-
set
|
|
288
|
-
if (value !== this.
|
|
289
|
-
this.driver.
|
|
290
|
-
this.
|
|
286
|
+
get maxHeight() { return this.appliedMaxHeight; }
|
|
287
|
+
set maxHeight(value) {
|
|
288
|
+
if (value !== this.appliedMaxWidth) {
|
|
289
|
+
this.driver.applyMaxWidth(this, value);
|
|
290
|
+
this.appliedMaxWidth = value;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
get
|
|
294
|
-
set
|
|
295
|
-
if (value !== this.
|
|
296
|
-
this.driver.
|
|
297
|
-
this.
|
|
293
|
+
get contentAlignment() { return this.appliedContentAlignment; }
|
|
294
|
+
set contentAlignment(value) {
|
|
295
|
+
if (value !== this.appliedContentAlignment) {
|
|
296
|
+
this.driver.applyContentAlignment(this, value);
|
|
297
|
+
this.appliedContentAlignment = value;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
get
|
|
301
|
-
set
|
|
302
|
-
if (value !== this.
|
|
303
|
-
this.driver.
|
|
304
|
-
this.
|
|
300
|
+
get frameAlignment() { return this.appliedFrameAlignment; }
|
|
301
|
+
set frameAlignment(value) {
|
|
302
|
+
if (value !== this.appliedFrameAlignment) {
|
|
303
|
+
this.driver.applyFrameAlignment(this, value);
|
|
304
|
+
this.appliedFrameAlignment = value;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
get
|
|
308
|
-
set
|
|
309
|
-
if (value !== this.
|
|
310
|
-
this.driver.
|
|
311
|
-
this.
|
|
307
|
+
get contentWrapping() { return this.appliedContentWrapping; }
|
|
308
|
+
set contentWrapping(value) {
|
|
309
|
+
if (value !== this.appliedContentWrapping) {
|
|
310
|
+
this.driver.applyContentWrapping(this, value);
|
|
311
|
+
this.appliedContentWrapping = value;
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
get
|
|
315
|
-
set
|
|
316
|
-
if (value !== this.
|
|
317
|
-
this.driver.
|
|
318
|
-
this.
|
|
314
|
+
get floating() { return this.appliedFloating; }
|
|
315
|
+
set floating(value) {
|
|
316
|
+
if (value !== this.appliedFloating) {
|
|
317
|
+
this.driver.applyFloating(this, value);
|
|
318
|
+
this.appliedFloating = value;
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
configureReactronic(options) {
|
|
@@ -380,8 +380,12 @@ function runRenderNestedTreesThenDo(error, action) {
|
|
|
380
380
|
let promised = undefined;
|
|
381
381
|
try {
|
|
382
382
|
children.endMerge(error);
|
|
383
|
-
for (const item of children.removedItems(true))
|
|
383
|
+
for (const item of children.removedItems(true)) {
|
|
384
|
+
const b = item.instance;
|
|
385
|
+
if (b.key !== b.body.key)
|
|
386
|
+
console.warn(`every conditionally rendered block requires explicit key: ${b.key}, ${b.driver.name}`);
|
|
384
387
|
runFinalize(item, true);
|
|
388
|
+
}
|
|
385
389
|
if (!error) {
|
|
386
390
|
const ownerIsBlock = owner.driver.isBlock;
|
|
387
391
|
const sequential = children.strict;
|
|
@@ -449,7 +453,7 @@ function renderIncrementally(owner, stamp, allChildren, items, priority) {
|
|
|
449
453
|
VBlock.currentRenderingPriority = priority;
|
|
450
454
|
try {
|
|
451
455
|
const sequential = block.children.strict;
|
|
452
|
-
if (block.
|
|
456
|
+
if (block.childrenShuffling)
|
|
453
457
|
shuffle(items);
|
|
454
458
|
const frameDurationLimit = priority === Priority.AsyncP2 ? VBlock.shortFrameDuration : Infinity;
|
|
455
459
|
let frameDuration = Math.min(frameDurationLimit, Math.max(VBlock.frameDuration / 4, VBlock.shortFrameDuration));
|
|
@@ -493,7 +497,7 @@ function prepareRender(item, redeploy, sequential) {
|
|
|
493
497
|
if ((_a = block.body) === null || _a === void 0 ? void 0 : _a.reacting) {
|
|
494
498
|
Transaction.outside(() => {
|
|
495
499
|
if (Rx.isLogging)
|
|
496
|
-
Rx.setLoggingHint(block, block.
|
|
500
|
+
Rx.setLoggingHint(block, block.key);
|
|
497
501
|
Rx.getController(block.rerender).configure({
|
|
498
502
|
order: block.level,
|
|
499
503
|
});
|
|
@@ -530,7 +534,7 @@ function runRender(item) {
|
|
|
530
534
|
}
|
|
531
535
|
catch (e) {
|
|
532
536
|
runRenderNestedTreesThenDo(e, NOP);
|
|
533
|
-
console.log(`Rendering failed: ${block.
|
|
537
|
+
console.log(`Rendering failed: ${block.key}`);
|
|
534
538
|
console.log(`${e}`);
|
|
535
539
|
}
|
|
536
540
|
});
|
|
@@ -550,7 +554,7 @@ function runFinalize(item, isLeader) {
|
|
|
550
554
|
else
|
|
551
555
|
gFirstToDispose = gLastToDispose = item;
|
|
552
556
|
if (gFirstToDispose === item)
|
|
553
|
-
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.
|
|
557
|
+
Transaction.run({ separation: "disposal", hint: `runDisposalLoop(initiator=${item.instance.key})` }, () => {
|
|
554
558
|
void runDisposalLoop().then(NOP, error => console.log(error));
|
|
555
559
|
});
|
|
556
560
|
}
|
|
@@ -648,7 +652,7 @@ function defaultReject(error) {
|
|
|
648
652
|
Promise.prototype.then = reactronicDomHookedThen;
|
|
649
653
|
const NOP = (...args) => { };
|
|
650
654
|
const gSysDriver = new StaticDriver(null, "SYSTEM", LayoutKind.Group);
|
|
651
|
-
const gSysRoot = Collection.createItem(new VBlockImpl(
|
|
655
|
+
const gSysRoot = Collection.createItem(new VBlockImpl(gSysDriver.name, gSysDriver, { level: 0 }, { reacting: true, render: NOP }));
|
|
652
656
|
gSysRoot.instance.item = gSysRoot;
|
|
653
657
|
Object.defineProperty(gSysRoot.instance, "host", {
|
|
654
658
|
value: gSysRoot.instance,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { VBlock, BlockBody, Align, CellRange } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export declare function Block<M = unknown, R = void>(
|
|
4
|
-
export declare function PlainText(content: string,
|
|
5
|
-
export declare function HtmlText(content: string,
|
|
6
|
-
export declare function Grid<M = unknown, R = void>(
|
|
7
|
-
export declare function Line<T = void>(
|
|
8
|
-
export declare function lineFeed(
|
|
9
|
-
export declare function Group<M = unknown, R = void>(
|
|
3
|
+
export declare function Block<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
4
|
+
export declare function PlainText(content: string, body?: BlockBody<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
|
|
5
|
+
export declare function HtmlText(content: string, body?: BlockBody<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
|
|
6
|
+
export declare function Grid<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
7
|
+
export declare function Line<T = void>(body: (block: void) => T): void;
|
|
8
|
+
export declare function lineFeed(noCoalescing?: boolean, key?: string): VBlock<HTMLElement>;
|
|
9
|
+
export declare function Group<M = unknown, R = void>(body: BlockBody<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
|
|
10
10
|
export declare class VerstakDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
11
11
|
applyCellRange(block: VBlock<T>, cellRange: CellRange | undefined): void;
|
|
12
12
|
applyWidthGrowth(block: VBlock<T>, widthGrowth: number): void;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
applyMinWidth(block: VBlock<T>, minWidth: string): void;
|
|
14
|
+
applyMaxWidth(block: VBlock<T>, maxWidth: string): void;
|
|
15
15
|
applyHeightGrowth(block: VBlock<T>, heightGrowth: number): void;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
applyMinHeight(block: VBlock<T>, minHeight: string): void;
|
|
17
|
+
applyMaxHeight(block: VBlock<T>, maxHeight: string): void;
|
|
18
|
+
applyContentAlignment(block: VBlock<T>, contentAlign: Align): void;
|
|
19
|
+
applyFrameAlignment(block: VBlock<T>, frameAlign: Align): void;
|
|
20
|
+
applyContentWrapping(block: VBlock<T>, contentWrapping: boolean): void;
|
|
21
|
+
applyFloating(block: VBlock<T>, floating: boolean): void;
|
|
22
22
|
render(block: VBlock<T>): void | Promise<void>;
|
|
23
23
|
}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import { VBlock, LayoutKind, Align, GridCursor,
|
|
1
|
+
import { VBlock, LayoutKind, Align, GridCursor, asBaseFor } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export function Block(
|
|
4
|
-
return VBlock.claim(
|
|
3
|
+
export function Block(body) {
|
|
4
|
+
return VBlock.claim(VerstakTags.block, body);
|
|
5
5
|
}
|
|
6
|
-
export function PlainText(content,
|
|
7
|
-
return VBlock.claim(
|
|
6
|
+
export function PlainText(content, body) {
|
|
7
|
+
return VBlock.claim(VerstakTags.text, asBaseFor(body, {
|
|
8
8
|
render(b) {
|
|
9
9
|
b.native.innerText = content;
|
|
10
10
|
},
|
|
11
11
|
}));
|
|
12
12
|
}
|
|
13
|
-
export function HtmlText(content,
|
|
14
|
-
return VBlock.claim(
|
|
13
|
+
export function HtmlText(content, body) {
|
|
14
|
+
return VBlock.claim(VerstakTags.text, asBaseFor(body, {
|
|
15
15
|
render(b) {
|
|
16
16
|
b.native.innerHTML = content;
|
|
17
17
|
},
|
|
18
18
|
}));
|
|
19
19
|
}
|
|
20
|
-
export function Grid(
|
|
21
|
-
return VBlock.claim(
|
|
20
|
+
export function Grid(body) {
|
|
21
|
+
return VBlock.claim(VerstakTags.grid, body);
|
|
22
22
|
}
|
|
23
|
-
export function Line(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return result;
|
|
23
|
+
export function Line(body) {
|
|
24
|
+
lineFeed();
|
|
25
|
+
body();
|
|
26
|
+
lineFeed();
|
|
28
27
|
}
|
|
29
|
-
export function lineFeed(
|
|
30
|
-
return VBlock.claim(
|
|
28
|
+
export function lineFeed(noCoalescing, key) {
|
|
29
|
+
return VBlock.claim(VerstakTags.row, { key });
|
|
31
30
|
}
|
|
32
|
-
export function Group(
|
|
33
|
-
return VBlock.claim(
|
|
31
|
+
export function Group(body) {
|
|
32
|
+
return VBlock.claim(VerstakTags.group, body);
|
|
34
33
|
}
|
|
35
34
|
export class VerstakDriver extends HtmlDriver {
|
|
36
35
|
applyCellRange(block, cellRange) {
|
|
@@ -57,11 +56,11 @@ export class VerstakDriver extends HtmlDriver {
|
|
|
57
56
|
css.flexBasis = "";
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
block.native.style.minWidth = `${
|
|
59
|
+
applyMinWidth(block, minWidth) {
|
|
60
|
+
block.native.style.minWidth = `${minWidth}`;
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
block.native.style.maxWidth = `${
|
|
62
|
+
applyMaxWidth(block, maxWidth) {
|
|
63
|
+
block.native.style.maxWidth = `${maxWidth}`;
|
|
65
64
|
}
|
|
66
65
|
applyHeightGrowth(block, heightGrowth) {
|
|
67
66
|
if (block.driver.isRow) {
|
|
@@ -72,22 +71,22 @@ export class VerstakDriver extends HtmlDriver {
|
|
|
72
71
|
css.flexGrow = "";
|
|
73
72
|
}
|
|
74
73
|
else if (block.host.driver.isRow) {
|
|
75
|
-
block.driver.
|
|
74
|
+
block.driver.applyFrameAlignment(block, Align.Stretch);
|
|
76
75
|
block.host.driver.applyHeightGrowth(block.host, heightGrowth);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
|
|
80
|
-
block.native.style.minHeight = `${
|
|
78
|
+
applyMinHeight(block, minHeight) {
|
|
79
|
+
block.native.style.minHeight = `${minHeight}`;
|
|
81
80
|
}
|
|
82
|
-
|
|
83
|
-
block.native.style.maxHeight = `${
|
|
81
|
+
applyMaxHeight(block, maxHeight) {
|
|
82
|
+
block.native.style.maxHeight = `${maxHeight}`;
|
|
84
83
|
}
|
|
85
|
-
|
|
84
|
+
applyContentAlignment(block, contentAlign) {
|
|
86
85
|
const css = block.native.style;
|
|
87
|
-
if ((
|
|
88
|
-
const v = AlignToCss[(
|
|
89
|
-
const h = AlignToCss[
|
|
90
|
-
const t = TextAlignCss[
|
|
86
|
+
if ((contentAlign & Align.Default) === 0) {
|
|
87
|
+
const v = AlignToCss[(contentAlign >> 2) & 0b11];
|
|
88
|
+
const h = AlignToCss[contentAlign & 0b11];
|
|
89
|
+
const t = TextAlignCss[contentAlign & 0b11];
|
|
91
90
|
css.justifyContent = v;
|
|
92
91
|
css.alignItems = h;
|
|
93
92
|
css.textAlign = t;
|
|
@@ -95,32 +94,32 @@ export class VerstakDriver extends HtmlDriver {
|
|
|
95
94
|
else
|
|
96
95
|
css.justifyContent = css.alignContent = css.textAlign = "";
|
|
97
96
|
}
|
|
98
|
-
|
|
97
|
+
applyFrameAlignment(block, frameAlign) {
|
|
99
98
|
const css = block.native.style;
|
|
100
|
-
if ((
|
|
101
|
-
const v = AlignToCss[(
|
|
102
|
-
const h = AlignToCss[
|
|
99
|
+
if ((frameAlign & Align.Default) === 0) {
|
|
100
|
+
const v = AlignToCss[(frameAlign >> 2) & 0b11];
|
|
101
|
+
const h = AlignToCss[frameAlign & 0b11];
|
|
103
102
|
css.alignSelf = v;
|
|
104
103
|
css.justifySelf = h;
|
|
105
104
|
}
|
|
106
105
|
else
|
|
107
106
|
css.alignSelf = css.justifySelf = "";
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
if (
|
|
108
|
+
applyContentWrapping(block, contentWrapping) {
|
|
109
|
+
if (contentWrapping)
|
|
111
110
|
block.native.setAttribute("wrapping", "true");
|
|
112
111
|
else
|
|
113
112
|
block.native.removeAttribute("wrapping");
|
|
114
113
|
}
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
block.native.setAttribute("
|
|
114
|
+
applyFloating(block, floating) {
|
|
115
|
+
if (floating)
|
|
116
|
+
block.native.setAttribute("floating", "true");
|
|
118
117
|
else
|
|
119
|
-
block.native.removeAttribute("
|
|
118
|
+
block.native.removeAttribute("floating");
|
|
120
119
|
}
|
|
121
120
|
render(block) {
|
|
122
121
|
if (block.driver.layout < LayoutKind.Row)
|
|
123
|
-
VBlock.claim(
|
|
122
|
+
VBlock.claim(VerstakTags.row, {});
|
|
124
123
|
return super.render(block);
|
|
125
124
|
}
|
|
126
125
|
}
|
|
@@ -131,6 +130,5 @@ const VerstakTags = {
|
|
|
131
130
|
row: new VerstakDriver("v-row", LayoutKind.Row),
|
|
132
131
|
group: new VerstakDriver("v-group", LayoutKind.Group),
|
|
133
132
|
};
|
|
134
|
-
const EMPTY_BLOCK_BODY = { render() { } };
|
|
135
133
|
const AlignToCss = ["stretch", "start", "center", "end"];
|
|
136
134
|
const TextAlignCss = ["justify", "left", "center", "right"];
|