verstak 0.23.107 → 0.23.109
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/README.md +38 -17
- package/build/dist/source/core/Interfaces.d.ts +134 -0
- package/build/dist/source/core/Interfaces.js +34 -0
- package/build/dist/source/core/Utils.d.ts +6 -0
- package/build/dist/source/core/Utils.js +176 -0
- package/build/dist/source/core/Verstak.d.ts +69 -0
- package/build/dist/source/core/Verstak.js +877 -0
- package/build/dist/source/core/api.d.ts +2 -3
- package/build/dist/source/core/api.js +2 -3
- package/build/dist/source/html/Blocks.d.ts +24 -22
- package/build/dist/source/html/Blocks.js +116 -102
- package/build/dist/source/html/HtmlBlocks.d.ts +175 -175
- package/build/dist/source/html/HtmlBlocks.js +349 -349
- package/build/dist/source/html/HtmlDriver.d.ts +14 -13
- package/build/dist/source/html/HtmlDriver.js +32 -37
- package/build/dist/source/html/ReactingFocuser.d.ts +1 -1
- package/build/dist/source/html/ReactingFocuser.js +4 -3
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +2 -2
- package/package.json +1 -1
- package/build/dist/source/core/CellRange.d.ts +0 -11
- package/build/dist/source/core/CellRange.js +0 -176
- package/build/dist/source/core/Cursor.d.ts +0 -50
- package/build/dist/source/core/Cursor.js +0 -121
- package/build/dist/source/core/VBlock.d.ts +0 -116
- package/build/dist/source/core/VBlock.js +0 -745
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
import { Item } from "reactronic";
|
|
2
|
-
import {
|
|
3
|
-
export declare abstract class BaseHtmlDriver<T extends Element, C = unknown> extends
|
|
4
|
-
create(block:
|
|
2
|
+
import { Block, BaseDriver } from "../core/api";
|
|
3
|
+
export declare abstract class BaseHtmlDriver<T extends Element, C = unknown> extends BaseDriver<T, C> {
|
|
4
|
+
create(block: Block<T, unknown, C, void>, b: {
|
|
5
5
|
native?: T;
|
|
6
6
|
controller?: C;
|
|
7
7
|
}): void;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
static
|
|
14
|
-
static
|
|
15
|
-
static
|
|
8
|
+
initialize(block: Block<T, unknown, C, void>): void;
|
|
9
|
+
finalize(block: Block<T, unknown, C>, isLeader: boolean): boolean;
|
|
10
|
+
mount(block: Block<T, unknown, C>): void;
|
|
11
|
+
relocate(block: Block<T, unknown, C>): void;
|
|
12
|
+
render(block: Block<T, unknown, C>): void | Promise<void>;
|
|
13
|
+
static get blinkingEffectMarker(): string | undefined;
|
|
14
|
+
static set blinkingEffectMarker(value: string | undefined);
|
|
15
|
+
static findEffectiveHtmlBlockHost(block: Block<any>): Block<HTMLElement | SVGElement>;
|
|
16
|
+
static findPrevSiblingHtmlBlock(item: Item<Block<any>>): Item<Block<HTMLElement | SVGElement>> | undefined;
|
|
16
17
|
}
|
|
17
18
|
export declare class HtmlDriver<T extends HTMLElement, C = unknown> extends BaseHtmlDriver<T, C> {
|
|
18
|
-
create(block:
|
|
19
|
+
create(block: Block<T, unknown, C, void>, b: {
|
|
19
20
|
native?: T | undefined;
|
|
20
21
|
controller?: C | undefined;
|
|
21
22
|
}): void;
|
|
22
23
|
}
|
|
23
24
|
export declare class SvgDriver<T extends SVGElement, C = unknown> extends BaseHtmlDriver<T, C> {
|
|
24
|
-
create(block:
|
|
25
|
+
create(block: Block<T, unknown, C, void>, b: {
|
|
25
26
|
native?: T | undefined;
|
|
26
27
|
controller?: C | undefined;
|
|
27
28
|
}): void;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Rx } from "reactronic";
|
|
2
|
-
import {
|
|
3
|
-
export class BaseHtmlDriver extends
|
|
2
|
+
import { Verstak, BaseDriver } from "../core/api";
|
|
3
|
+
export class BaseHtmlDriver extends BaseDriver {
|
|
4
4
|
create(block, b) {
|
|
5
|
-
if (Rx.isLogging && !block.driver.isRow)
|
|
6
|
-
block.native.setAttribute("key", block.key);
|
|
7
5
|
super.create(block, b);
|
|
8
6
|
}
|
|
7
|
+
initialize(block) {
|
|
8
|
+
if (Rx.isLogging && !block.descriptor.driver.isRow)
|
|
9
|
+
block.native.setAttribute("key", block.descriptor.key);
|
|
10
|
+
super.initialize(block);
|
|
11
|
+
}
|
|
9
12
|
finalize(block, isLeader) {
|
|
10
13
|
var _a;
|
|
11
14
|
const e = block.native;
|
|
@@ -17,15 +20,16 @@ export class BaseHtmlDriver extends Driver {
|
|
|
17
20
|
super.finalize(block, isLeader);
|
|
18
21
|
return false;
|
|
19
22
|
}
|
|
20
|
-
|
|
23
|
+
mount(block) {
|
|
21
24
|
const e = block.native;
|
|
22
25
|
if (e) {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
26
|
+
const bNode = block.descriptor;
|
|
27
|
+
const sequential = bNode.owner.descriptor.children.isStrict;
|
|
28
|
+
const nativeParent = BaseHtmlDriver.findEffectiveHtmlBlockHost(block).native;
|
|
25
29
|
if (nativeParent) {
|
|
26
|
-
if (sequential && !
|
|
27
|
-
const after = BaseHtmlDriver.findPrevSiblingHtmlBlock(block.item);
|
|
28
|
-
if (after === undefined || after.instance.driver.isRow) {
|
|
30
|
+
if (sequential && !bNode.driver.isRow) {
|
|
31
|
+
const after = BaseHtmlDriver.findPrevSiblingHtmlBlock(block.descriptor.item);
|
|
32
|
+
if (after === undefined || after.instance.descriptor.driver.isRow) {
|
|
29
33
|
if (nativeParent !== e.parentNode || !e.previousSibling)
|
|
30
34
|
nativeParent.prepend(e);
|
|
31
35
|
}
|
|
@@ -46,48 +50,39 @@ export class BaseHtmlDriver extends Driver {
|
|
|
46
50
|
}
|
|
47
51
|
render(block) {
|
|
48
52
|
const result = super.render(block);
|
|
49
|
-
if (
|
|
50
|
-
blink(block.native,
|
|
53
|
+
if (gBlinkingEffectMarker)
|
|
54
|
+
blink(block.native, Verstak.currentRenderingPriority, block.descriptor.stamp);
|
|
51
55
|
return result;
|
|
52
56
|
}
|
|
53
|
-
static get
|
|
54
|
-
return
|
|
57
|
+
static get blinkingEffectMarker() {
|
|
58
|
+
return gBlinkingEffectMarker;
|
|
55
59
|
}
|
|
56
|
-
static set
|
|
57
|
-
|
|
58
|
-
const effect = gBlinkingEffect;
|
|
59
|
-
VBlock.runForAllBlocks((e) => {
|
|
60
|
-
if (e instanceof HTMLElement) {
|
|
61
|
-
e.classList.remove(`${effect}-0-0`, `${effect}-0-1`);
|
|
62
|
-
e.classList.remove(`${effect}-1-0`, `${effect}-1-1`);
|
|
63
|
-
e.classList.remove(`${effect}-2-0`, `${effect}-2-1`);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
gBlinkingEffect = value;
|
|
60
|
+
static set blinkingEffectMarker(value) {
|
|
61
|
+
gBlinkingEffectMarker = value;
|
|
68
62
|
}
|
|
69
|
-
static
|
|
70
|
-
let p = block.host;
|
|
71
|
-
while (p.native instanceof HTMLElement === false &&
|
|
72
|
-
p
|
|
63
|
+
static findEffectiveHtmlBlockHost(block) {
|
|
64
|
+
let p = block.descriptor.host;
|
|
65
|
+
while (p.native instanceof HTMLElement === false &&
|
|
66
|
+
p.native instanceof SVGElement === false && p !== block)
|
|
67
|
+
p = p.descriptor.host;
|
|
73
68
|
return p;
|
|
74
69
|
}
|
|
75
70
|
static findPrevSiblingHtmlBlock(item) {
|
|
76
71
|
let p = item.prev;
|
|
77
|
-
while (p && !(p.instance.native instanceof HTMLElement))
|
|
72
|
+
while (p && !(p.instance.native instanceof HTMLElement) && !(p.instance.native instanceof SVGElement))
|
|
78
73
|
p = p.prev;
|
|
79
74
|
return p;
|
|
80
75
|
}
|
|
81
76
|
}
|
|
82
77
|
export class HtmlDriver extends BaseHtmlDriver {
|
|
83
78
|
create(block, b) {
|
|
84
|
-
b.native = document.createElement(block.driver.name);
|
|
79
|
+
b.native = document.createElement(block.descriptor.driver.name);
|
|
85
80
|
super.create(block, b);
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
export class SvgDriver extends BaseHtmlDriver {
|
|
89
84
|
create(block, b) {
|
|
90
|
-
b.native = document.createElementNS("http://www.w3.org/2000/svg", block.driver.name);
|
|
85
|
+
b.native = document.createElementNS("http://www.w3.org/2000/svg", block.descriptor.driver.name);
|
|
91
86
|
super.create(block, b);
|
|
92
87
|
}
|
|
93
88
|
}
|
|
@@ -95,9 +90,9 @@ function blink(e, priority, revision) {
|
|
|
95
90
|
if (e !== undefined) {
|
|
96
91
|
const n1 = revision % 2;
|
|
97
92
|
const n2 = 1 >> n1;
|
|
98
|
-
const
|
|
99
|
-
e.classList.toggle(`${
|
|
100
|
-
e.classList.toggle(`${
|
|
93
|
+
const bem = gBlinkingEffectMarker;
|
|
94
|
+
e.classList.toggle(`${bem}${priority}${n1}`, true);
|
|
95
|
+
e.classList.toggle(`${bem}${priority}${n2}`, false);
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
|
-
let
|
|
98
|
+
let gBlinkingEffectMarker = undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FocusModel } from "./sensors/FocusSensor";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function FocuserReaction(key: string, target: HTMLElement, model: FocusModel, switchEditMode?: ((model?: FocusModel) => void) | undefined): void;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Mode } from "../core/api";
|
|
2
|
+
import { Fragment } from "./Blocks";
|
|
3
|
+
export function FocuserReaction(key, target, model, switchEditMode = undefined) {
|
|
3
4
|
Fragment({
|
|
4
5
|
key,
|
|
5
|
-
|
|
6
|
+
mode: Mode.PinpointRefresh,
|
|
6
7
|
triggers: { target, model },
|
|
7
8
|
initialize(b) {
|
|
8
9
|
b.configureReactronic({ throttling: 0 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Block } from "../../core/api";
|
|
2
2
|
import { Sensor } from "./Sensor";
|
|
3
3
|
export interface ResizedElement {
|
|
4
4
|
readonly borderBoxSize: ReadonlyArray<ResizeObserverSize>;
|
|
@@ -11,7 +11,7 @@ export declare class ResizeSensor extends Sensor {
|
|
|
11
11
|
resizedElements: Array<ResizedElement>;
|
|
12
12
|
constructor();
|
|
13
13
|
reset(): void;
|
|
14
|
-
observeResizing(block:
|
|
14
|
+
observeResizing(block: Block<any, any, any>, value: boolean, boxSizing?: ResizeObserverBoxOptions): void;
|
|
15
15
|
protected onResize(entries: Array<ResizeObserverEntry>): void;
|
|
16
16
|
protected resize(entries: Array<ResizeObserverEntry>): void;
|
|
17
17
|
protected doReset(): void;
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface CellRange {
|
|
2
|
-
x1: number;
|
|
3
|
-
y1: number;
|
|
4
|
-
x2: number;
|
|
5
|
-
y2: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function parseCellRange(text: string, result: CellRange): CellRange;
|
|
8
|
-
export declare function emitCellRange(value: CellRange): string;
|
|
9
|
-
export declare function emitLetters(n: number): string;
|
|
10
|
-
export declare function emitCellPosition(x: number, y: number): string;
|
|
11
|
-
export declare function equalCellRanges(a: CellRange, b: CellRange): boolean;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
export function parseCellRange(text, result) {
|
|
2
|
-
let i = 0;
|
|
3
|
-
let value = 0;
|
|
4
|
-
let sign = 1;
|
|
5
|
-
let component = 0;
|
|
6
|
-
while (i < text.length) {
|
|
7
|
-
const charCode = text.charCodeAt(i);
|
|
8
|
-
if (isCapitalLetter(charCode)) {
|
|
9
|
-
if (component % 2 === 0)
|
|
10
|
-
value = value * 26 + charCode - 64;
|
|
11
|
-
else
|
|
12
|
-
console.error(`Digit is expected, but letter ('${text[i]}') was read`);
|
|
13
|
-
}
|
|
14
|
-
else if (isLowercaseLetter(charCode)) {
|
|
15
|
-
if (component % 2 === 0) {
|
|
16
|
-
value = value * 26 + charCode - 96;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
console.error(`Digit is expected, but letter ('${text[i]}') was read`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else if (isDigit(charCode)) {
|
|
23
|
-
if (component % 2 === 0) {
|
|
24
|
-
if (value !== 0) {
|
|
25
|
-
if (component === 0)
|
|
26
|
-
result.x1 = value * sign;
|
|
27
|
-
else
|
|
28
|
-
result.x2 = value * sign;
|
|
29
|
-
value = 0;
|
|
30
|
-
}
|
|
31
|
-
component++;
|
|
32
|
-
}
|
|
33
|
-
value = value * 10 + charCode - 48;
|
|
34
|
-
}
|
|
35
|
-
else if (charCode === 40) {
|
|
36
|
-
if (component === 0)
|
|
37
|
-
result.x1 = value * sign;
|
|
38
|
-
else if (component === 2)
|
|
39
|
-
result.x2 = value * sign;
|
|
40
|
-
if (sign > 0) {
|
|
41
|
-
sign = -1;
|
|
42
|
-
component &= ~1;
|
|
43
|
-
value = 0;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.error("Sign must not be negative");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (charCode === 41) {
|
|
50
|
-
if (sign > 0) {
|
|
51
|
-
console.error("Sign must be negative");
|
|
52
|
-
}
|
|
53
|
-
switch (component) {
|
|
54
|
-
case 0:
|
|
55
|
-
result.x1 = value * sign;
|
|
56
|
-
break;
|
|
57
|
-
case 1:
|
|
58
|
-
result.y1 = value * sign;
|
|
59
|
-
break;
|
|
60
|
-
case 2:
|
|
61
|
-
result.x2 = value * sign;
|
|
62
|
-
break;
|
|
63
|
-
case 3:
|
|
64
|
-
result.y2 = value * sign;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
sign = 1;
|
|
68
|
-
value = 0;
|
|
69
|
-
component++;
|
|
70
|
-
}
|
|
71
|
-
else if (charCode === 58) {
|
|
72
|
-
if (sign < 0)
|
|
73
|
-
console.error(`area '${text}': e1`);
|
|
74
|
-
if (component === 1)
|
|
75
|
-
result.y1 = value * sign;
|
|
76
|
-
else if (component !== 2)
|
|
77
|
-
console.error(`area '${text}': [e2] component = ${component}`);
|
|
78
|
-
component = 2;
|
|
79
|
-
value = 0;
|
|
80
|
-
}
|
|
81
|
-
else if (isWhitespace(charCode)) {
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
console.error(`Unknown symbol '${text[i]}' in '${text}'`);
|
|
85
|
-
}
|
|
86
|
-
i++;
|
|
87
|
-
}
|
|
88
|
-
if (value !== 0) {
|
|
89
|
-
switch (component) {
|
|
90
|
-
case 0: {
|
|
91
|
-
result.x1 = value * sign;
|
|
92
|
-
if (sign < 0 && result.y1 === 0)
|
|
93
|
-
result.y1 = sign;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
case 1: {
|
|
97
|
-
if (sign < 0 && result.x1 === 0)
|
|
98
|
-
result.x1 = sign;
|
|
99
|
-
result.y1 = value * sign;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case 2: {
|
|
103
|
-
result.x2 = value * sign;
|
|
104
|
-
if (sign < 0 && result.y2 === 0)
|
|
105
|
-
result.y2 = sign;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case 3: {
|
|
109
|
-
if (sign < 0 && result.x2 === 0)
|
|
110
|
-
result.x2 = sign;
|
|
111
|
-
result.y2 = value * sign;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else if (sign < 0) {
|
|
117
|
-
if (component === 0) {
|
|
118
|
-
if (result.x1 === 0)
|
|
119
|
-
result.x1 = sign;
|
|
120
|
-
if (result.y1 === 0)
|
|
121
|
-
result.y1 = sign;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
if (result.x2 === 0)
|
|
125
|
-
result.x2 = sign;
|
|
126
|
-
if (result.y2 === 0)
|
|
127
|
-
result.y2 = sign;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
export function emitCellRange(value) {
|
|
133
|
-
const p1 = emitCellPosition(value.x1, value.y1);
|
|
134
|
-
const p2 = emitCellPosition(value.x2, value.y2);
|
|
135
|
-
return `${p1}${p2 !== "" ? `:${p2}` : ""}`;
|
|
136
|
-
}
|
|
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
|
-
export function emitCellPosition(x, y) {
|
|
149
|
-
let result = "";
|
|
150
|
-
if (x > 0 && y > 0)
|
|
151
|
-
result = `${emitLetters(x - 1)}${y}`;
|
|
152
|
-
else if (x > 0 && y < 0)
|
|
153
|
-
result = `${emitLetters(x - 1)}(${-y})`;
|
|
154
|
-
else if (x < 0 && y > 0)
|
|
155
|
-
result = `(${emitLetters(-x - 1)})${y}`;
|
|
156
|
-
else if (x < 0 && y < 0)
|
|
157
|
-
result = `(${emitLetters(-x - 1)}${-y})`;
|
|
158
|
-
else
|
|
159
|
-
result = "";
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
export function equalCellRanges(a, b) {
|
|
163
|
-
return a.x1 === b.x1 && a.y1 === b.y1 && a.x2 === b.x2 && a.y1 === b.y2;
|
|
164
|
-
}
|
|
165
|
-
function isWhitespace(char) {
|
|
166
|
-
return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
|
|
167
|
-
}
|
|
168
|
-
function isDigit(input, index) {
|
|
169
|
-
return 48 <= input && input <= 57;
|
|
170
|
-
}
|
|
171
|
-
function isCapitalLetter(ch) {
|
|
172
|
-
return 65 <= ch && ch <= 90;
|
|
173
|
-
}
|
|
174
|
-
function isLowercaseLetter(ch) {
|
|
175
|
-
return 97 <= ch && ch <= 122;
|
|
176
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { CellRange } from "./CellRange";
|
|
2
|
-
export declare enum Align {
|
|
3
|
-
Stretch = 0,
|
|
4
|
-
Left = 1,
|
|
5
|
-
CenterX = 2,
|
|
6
|
-
Right = 3,
|
|
7
|
-
Top = 4,
|
|
8
|
-
CenterY = 8,
|
|
9
|
-
Bottom = 12,
|
|
10
|
-
Default = 16,
|
|
11
|
-
Center = 10
|
|
12
|
-
}
|
|
13
|
-
export interface ElasticSize {
|
|
14
|
-
cells?: number;
|
|
15
|
-
min?: string;
|
|
16
|
-
max?: string;
|
|
17
|
-
growth?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface TrackSize extends ElasticSize {
|
|
20
|
-
track?: string | number;
|
|
21
|
-
}
|
|
22
|
-
export type Placement = undefined | string | {
|
|
23
|
-
widthInCells?: number;
|
|
24
|
-
heightInCells?: number;
|
|
25
|
-
widthOverlap?: boolean;
|
|
26
|
-
heightOverlap?: boolean;
|
|
27
|
-
};
|
|
28
|
-
export declare class Cursor {
|
|
29
|
-
static readonly UndefinedCellRange: Readonly<{
|
|
30
|
-
x1: 0;
|
|
31
|
-
y1: 0;
|
|
32
|
-
x2: 0;
|
|
33
|
-
y2: 0;
|
|
34
|
-
}>;
|
|
35
|
-
reset(): void;
|
|
36
|
-
onwards(placement: Placement): CellRange;
|
|
37
|
-
rowBreak(): void;
|
|
38
|
-
}
|
|
39
|
-
export declare class TableCursor extends Cursor {
|
|
40
|
-
private maxColumnCount;
|
|
41
|
-
private maxRowCount;
|
|
42
|
-
private actualColumnCount;
|
|
43
|
-
private actualRowCount;
|
|
44
|
-
private columnCursor;
|
|
45
|
-
private rowCursor;
|
|
46
|
-
private newRowCursor;
|
|
47
|
-
reset(): void;
|
|
48
|
-
onwards(placement: Placement): CellRange;
|
|
49
|
-
rowBreak(): void;
|
|
50
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { parseCellRange } from "./CellRange";
|
|
2
|
-
export var Align;
|
|
3
|
-
(function (Align) {
|
|
4
|
-
Align[Align["Stretch"] = 0] = "Stretch";
|
|
5
|
-
Align[Align["Left"] = 1] = "Left";
|
|
6
|
-
Align[Align["CenterX"] = 2] = "CenterX";
|
|
7
|
-
Align[Align["Right"] = 3] = "Right";
|
|
8
|
-
Align[Align["Top"] = 4] = "Top";
|
|
9
|
-
Align[Align["CenterY"] = 8] = "CenterY";
|
|
10
|
-
Align[Align["Bottom"] = 12] = "Bottom";
|
|
11
|
-
Align[Align["Default"] = 16] = "Default";
|
|
12
|
-
Align[Align["Center"] = 10] = "Center";
|
|
13
|
-
})(Align || (Align = {}));
|
|
14
|
-
export class Cursor {
|
|
15
|
-
reset() { }
|
|
16
|
-
onwards(placement) { return Cursor.UndefinedCellRange; }
|
|
17
|
-
rowBreak() { }
|
|
18
|
-
}
|
|
19
|
-
Cursor.UndefinedCellRange = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
20
|
-
export class TableCursor extends Cursor {
|
|
21
|
-
constructor() {
|
|
22
|
-
super(...arguments);
|
|
23
|
-
this.maxColumnCount = 0;
|
|
24
|
-
this.maxRowCount = 0;
|
|
25
|
-
this.actualColumnCount = 0;
|
|
26
|
-
this.actualRowCount = 0;
|
|
27
|
-
this.columnCursor = 0;
|
|
28
|
-
this.rowCursor = 0;
|
|
29
|
-
this.newRowCursor = 0;
|
|
30
|
-
}
|
|
31
|
-
reset() {
|
|
32
|
-
this.maxColumnCount = 0;
|
|
33
|
-
this.maxRowCount = 0;
|
|
34
|
-
this.actualColumnCount = 0;
|
|
35
|
-
this.actualRowCount = 0;
|
|
36
|
-
this.columnCursor = 0;
|
|
37
|
-
this.rowCursor = 0;
|
|
38
|
-
this.newRowCursor = 0;
|
|
39
|
-
}
|
|
40
|
-
onwards(placement) {
|
|
41
|
-
var _a, _b, _c, _d;
|
|
42
|
-
let result;
|
|
43
|
-
if (typeof (placement) === "string") {
|
|
44
|
-
result = parseCellRange(placement, { x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
45
|
-
absolutizeCellRange(result, this.columnCursor + 1, this.rowCursor + 1, this.maxColumnCount || Infinity, this.maxRowCount || Infinity, result);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
let w;
|
|
49
|
-
let h;
|
|
50
|
-
let wOverlap;
|
|
51
|
-
let hOverlap;
|
|
52
|
-
if (placement) {
|
|
53
|
-
w = (_a = placement.widthInCells) !== null && _a !== void 0 ? _a : 1;
|
|
54
|
-
h = (_b = placement.heightInCells) !== null && _b !== void 0 ? _b : 1;
|
|
55
|
-
wOverlap = (_c = placement.widthOverlap) !== null && _c !== void 0 ? _c : false;
|
|
56
|
-
hOverlap = (_d = placement.heightOverlap) !== null && _d !== void 0 ? _d : false;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
w = 1;
|
|
60
|
-
h = 1;
|
|
61
|
-
wOverlap = hOverlap = false;
|
|
62
|
-
}
|
|
63
|
-
const totalColumnCount = this.maxColumnCount !== 0 ? this.maxColumnCount : this.actualColumnCount;
|
|
64
|
-
const totalRowCount = this.maxRowCount !== 0 ? this.maxRowCount : this.actualRowCount;
|
|
65
|
-
result = { x1: 0, y1: 0, x2: 0, y2: 0 };
|
|
66
|
-
if (w === 0)
|
|
67
|
-
w = totalColumnCount || 1;
|
|
68
|
-
if (w >= 0) {
|
|
69
|
-
result.x1 = this.columnCursor + 1;
|
|
70
|
-
result.x2 = absolutizePosition(result.x1 + w - 1, 0, this.maxColumnCount || Infinity);
|
|
71
|
-
if (!wOverlap)
|
|
72
|
-
this.columnCursor = result.x2;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
result.x1 = Math.max(this.columnCursor + w, 1);
|
|
76
|
-
result.x2 = this.columnCursor;
|
|
77
|
-
}
|
|
78
|
-
if (h === 0)
|
|
79
|
-
h = totalRowCount || 1;
|
|
80
|
-
if (h >= 0) {
|
|
81
|
-
result.y1 = this.rowCursor + 1;
|
|
82
|
-
result.y2 = absolutizePosition(result.y1 + h - 1, 0, this.maxRowCount || Infinity);
|
|
83
|
-
if (!hOverlap && result.y2 > this.newRowCursor)
|
|
84
|
-
this.newRowCursor = result.y2;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
result.y1 = Math.max(this.rowCursor + h, 1);
|
|
88
|
-
result.y2 = this.rowCursor;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
rowBreak() {
|
|
94
|
-
this.columnCursor = 0;
|
|
95
|
-
this.rowCursor = this.newRowCursor;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function absolutizeCellRange(area, cursorX, cursorY, maxWidth, maxHeight, result) {
|
|
99
|
-
const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
|
|
100
|
-
const x2 = absolutizePosition(area.x2, x1, maxWidth);
|
|
101
|
-
if (x1 <= x2)
|
|
102
|
-
result.x1 = x1, result.x2 = x2;
|
|
103
|
-
else
|
|
104
|
-
result.x1 = x2, result.x2 = x1;
|
|
105
|
-
const y1 = absolutizePosition(area.y1, cursorY, maxHeight);
|
|
106
|
-
const y2 = absolutizePosition(area.y2, y1, maxHeight);
|
|
107
|
-
if (y1 <= y2)
|
|
108
|
-
result.y1 = y1, result.y2 = y2;
|
|
109
|
-
else
|
|
110
|
-
result.y1 = y2, result.y2 = y1;
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
function absolutizePosition(pos, cursor, max) {
|
|
114
|
-
if (pos === 0)
|
|
115
|
-
pos = cursor;
|
|
116
|
-
else if (pos < 0)
|
|
117
|
-
pos = Math.max(max + pos, 1);
|
|
118
|
-
else
|
|
119
|
-
pos = Math.min(pos, max);
|
|
120
|
-
return pos;
|
|
121
|
-
}
|