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,25 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Block, BlockKind, BlockBuilder, Align, BlockCoords, BlockArea } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function row<T = void>(builder?: (block: void) => T,
|
|
6
|
-
export declare function fromNewRow(
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
3
|
+
export declare function Band<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): Block<HTMLElement, M, R>;
|
|
4
|
+
export declare function Table<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): Block<HTMLElement, M, R>;
|
|
5
|
+
export declare function row<T = void>(builder?: (block: void) => T, shiftCursorDown?: number): void;
|
|
6
|
+
export declare function fromNewRow(shiftCursorDown?: number): void;
|
|
7
|
+
export declare function cursor(areaParams: BlockArea): void;
|
|
8
|
+
export declare function Note(content: string, builder?: BlockBuilder<HTMLElement, void, void>): Block<HTMLElement, void, void>;
|
|
9
|
+
export declare function HtmlNote(content: string, builder?: BlockBuilder<HTMLElement, void, void>): Block<HTMLElement, void, void>;
|
|
10
|
+
export declare function Group<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): Block<HTMLElement, M, R>;
|
|
11
|
+
export declare function Fragment<M = unknown, R = void>(builder?: BlockBuilder<void, M, R>, base?: BlockBuilder<void, M, R>): Block<void, M, R>;
|
|
10
12
|
export declare class VerstakHtmlDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
applyWidthGrowth(block:
|
|
14
|
-
applyMinWidth(block:
|
|
15
|
-
applyMaxWidth(block:
|
|
16
|
-
applyHeightGrowth(block:
|
|
17
|
-
applyMinHeight(block:
|
|
18
|
-
applyMaxHeight(block:
|
|
19
|
-
applyContentAlignment(block:
|
|
20
|
-
applyBlockAlignment(block:
|
|
21
|
-
applyContentWrapping(block:
|
|
22
|
-
applyOverlayVisible(block:
|
|
23
|
-
applyStyle(block:
|
|
24
|
-
render(block:
|
|
13
|
+
applyKind(block: Block<T, any, any>, value: BlockKind): void;
|
|
14
|
+
applyCoords(block: Block<T>, value: BlockCoords | undefined): void;
|
|
15
|
+
applyWidthGrowth(block: Block<T>, value: number): void;
|
|
16
|
+
applyMinWidth(block: Block<T>, value: string): void;
|
|
17
|
+
applyMaxWidth(block: Block<T>, value: string): void;
|
|
18
|
+
applyHeightGrowth(block: Block<T>, value: number): void;
|
|
19
|
+
applyMinHeight(block: Block<T>, value: string): void;
|
|
20
|
+
applyMaxHeight(block: Block<T>, value: string): void;
|
|
21
|
+
applyContentAlignment(block: Block<T>, value: Align): void;
|
|
22
|
+
applyBlockAlignment(block: Block<T>, value: Align): void;
|
|
23
|
+
applyContentWrapping(block: Block<T>, value: boolean): void;
|
|
24
|
+
applyOverlayVisible(block: Block<T>, value: boolean | undefined): void;
|
|
25
|
+
applyStyle(block: Block<T, any, any>, secondary: boolean, styleName: string, enabled?: boolean): void;
|
|
26
|
+
render(block: Block<T>): void | Promise<void>;
|
|
25
27
|
}
|
|
@@ -1,64 +1,74 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Verstak, BlockKind, Align, CursorCommandDriver, BaseDriver } from "../core/api";
|
|
2
2
|
import { HtmlDriver } from "./HtmlDriver";
|
|
3
|
-
export function
|
|
4
|
-
return
|
|
3
|
+
export function Band(builder, base) {
|
|
4
|
+
return Verstak.claim(Drivers.band, builder, base);
|
|
5
5
|
}
|
|
6
|
-
export function
|
|
7
|
-
return
|
|
6
|
+
export function Table(builder, base) {
|
|
7
|
+
return Verstak.claim(Drivers.table, builder, base);
|
|
8
8
|
}
|
|
9
|
-
export function row(builder,
|
|
10
|
-
fromNewRow(
|
|
9
|
+
export function row(builder, shiftCursorDown) {
|
|
10
|
+
fromNewRow(shiftCursorDown);
|
|
11
11
|
builder === null || builder === void 0 ? void 0 : builder();
|
|
12
12
|
}
|
|
13
|
-
export function fromNewRow(
|
|
14
|
-
|
|
13
|
+
export function fromNewRow(shiftCursorDown) {
|
|
14
|
+
Verstak.claim(Drivers.row);
|
|
15
15
|
}
|
|
16
|
-
export function
|
|
17
|
-
|
|
16
|
+
export function cursor(areaParams) {
|
|
17
|
+
Verstak.claim(Drivers.cursor, {
|
|
18
|
+
render(b) {
|
|
19
|
+
b.area = areaParams;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function Note(content, builder) {
|
|
24
|
+
return Verstak.claim(Drivers.note, builder, {
|
|
18
25
|
render(b) {
|
|
19
26
|
b.native.innerText = content;
|
|
20
27
|
}
|
|
21
28
|
});
|
|
22
29
|
}
|
|
23
|
-
export function
|
|
24
|
-
return
|
|
30
|
+
export function HtmlNote(content, builder) {
|
|
31
|
+
return Verstak.claim(Drivers.note, builder, {
|
|
25
32
|
render(b) {
|
|
26
33
|
b.native.innerHTML = content;
|
|
27
34
|
}
|
|
28
35
|
});
|
|
29
36
|
}
|
|
30
|
-
export function
|
|
31
|
-
return
|
|
37
|
+
export function Group(builder, base) {
|
|
38
|
+
return Verstak.claim(Drivers.group, builder, base);
|
|
39
|
+
}
|
|
40
|
+
export function Fragment(builder, base) {
|
|
41
|
+
return Verstak.claim(BaseDriver.fragment, builder, base);
|
|
32
42
|
}
|
|
33
43
|
export class VerstakHtmlDriver extends HtmlDriver {
|
|
34
|
-
|
|
44
|
+
applyKind(block, value) {
|
|
35
45
|
const kind = Constants.layouts[value];
|
|
36
46
|
kind && block.native.setAttribute(Constants.attribute, kind);
|
|
37
47
|
VerstakDriversByLayout[value](block);
|
|
38
|
-
super.
|
|
48
|
+
super.applyKind(block, value);
|
|
39
49
|
}
|
|
40
|
-
|
|
41
|
-
const
|
|
50
|
+
applyCoords(block, value) {
|
|
51
|
+
const s = block.native.style;
|
|
42
52
|
if (value) {
|
|
43
53
|
const x1 = value.x1 || 1;
|
|
44
54
|
const y1 = value.y1 || 1;
|
|
45
55
|
const x2 = value.x2 || x1;
|
|
46
56
|
const y2 = value.y2 || y1;
|
|
47
|
-
|
|
57
|
+
s.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
|
|
48
58
|
}
|
|
49
59
|
else
|
|
50
|
-
|
|
51
|
-
super.
|
|
60
|
+
s.gridArea = "";
|
|
61
|
+
super.applyCoords(block, value);
|
|
52
62
|
}
|
|
53
63
|
applyWidthGrowth(block, value) {
|
|
54
|
-
const
|
|
64
|
+
const s = block.native.style;
|
|
55
65
|
if (value > 0) {
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
s.flexGrow = `${value}`;
|
|
67
|
+
s.flexBasis = "0";
|
|
58
68
|
}
|
|
59
69
|
else {
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
s.flexGrow = "";
|
|
71
|
+
s.flexBasis = "";
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
applyMinWidth(block, value) {
|
|
@@ -68,16 +78,21 @@ export class VerstakHtmlDriver extends HtmlDriver {
|
|
|
68
78
|
block.native.style.maxWidth = `${value}`;
|
|
69
79
|
}
|
|
70
80
|
applyHeightGrowth(block, value) {
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
const bNode = block.descriptor;
|
|
82
|
+
const driver = bNode.driver;
|
|
83
|
+
if (driver.isRow) {
|
|
84
|
+
const s = block.native.style;
|
|
73
85
|
if (value > 0)
|
|
74
|
-
|
|
86
|
+
s.flexGrow = `${value}`;
|
|
75
87
|
else
|
|
76
|
-
|
|
88
|
+
s.flexGrow = "";
|
|
77
89
|
}
|
|
78
|
-
else
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
else {
|
|
91
|
+
const hostDriver = bNode.host.descriptor.driver;
|
|
92
|
+
if (hostDriver.isRow) {
|
|
93
|
+
driver.applyBlockAlignment(block, Align.Stretch);
|
|
94
|
+
hostDriver.applyHeightGrowth(bNode.host, value);
|
|
95
|
+
}
|
|
81
96
|
}
|
|
82
97
|
}
|
|
83
98
|
applyMinHeight(block, value) {
|
|
@@ -87,71 +102,71 @@ export class VerstakHtmlDriver extends HtmlDriver {
|
|
|
87
102
|
block.native.style.maxHeight = `${value}`;
|
|
88
103
|
}
|
|
89
104
|
applyContentAlignment(block, value) {
|
|
90
|
-
const
|
|
105
|
+
const s = block.native.style;
|
|
91
106
|
if ((value & Align.Default) === 0) {
|
|
92
107
|
const v = AlignToCss[(value >> 2) & 0b11];
|
|
93
108
|
const h = AlignToCss[value & 0b11];
|
|
94
109
|
const t = TextAlignCss[value & 0b11];
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
s.justifyContent = v;
|
|
111
|
+
s.alignItems = h;
|
|
112
|
+
s.textAlign = t;
|
|
98
113
|
}
|
|
99
114
|
else
|
|
100
|
-
|
|
115
|
+
s.justifyContent = s.alignContent = s.textAlign = "";
|
|
101
116
|
}
|
|
102
117
|
applyBlockAlignment(block, value) {
|
|
103
|
-
const
|
|
118
|
+
const s = block.native.style;
|
|
104
119
|
if ((value & Align.Default) === 0) {
|
|
105
120
|
const v = AlignToCss[(value >> 2) & 0b11];
|
|
106
121
|
const h = AlignToCss[value & 0b11];
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
s.alignSelf = v;
|
|
123
|
+
s.justifySelf = h;
|
|
109
124
|
}
|
|
110
125
|
else
|
|
111
|
-
|
|
126
|
+
s.alignSelf = s.justifySelf = "";
|
|
112
127
|
}
|
|
113
128
|
applyContentWrapping(block, value) {
|
|
114
|
-
const
|
|
129
|
+
const s = block.native.style;
|
|
115
130
|
if (value) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
s.flexFlow = "wrap";
|
|
132
|
+
s.overflow = "";
|
|
133
|
+
s.textOverflow = "";
|
|
134
|
+
s.whiteSpace = "";
|
|
120
135
|
}
|
|
121
136
|
else {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
s.flexFlow = "";
|
|
138
|
+
s.overflow = "hidden";
|
|
139
|
+
s.textOverflow = "ellipsis";
|
|
140
|
+
s.whiteSpace = "nowrap";
|
|
126
141
|
}
|
|
127
142
|
}
|
|
128
143
|
applyOverlayVisible(block, value) {
|
|
129
144
|
const e = block.native;
|
|
130
|
-
const
|
|
131
|
-
const
|
|
145
|
+
const s = e.style;
|
|
146
|
+
const host = HtmlDriver.findEffectiveHtmlBlockHost(block).native;
|
|
132
147
|
if (value === true) {
|
|
133
148
|
const doc = document.body;
|
|
134
|
-
const rect =
|
|
149
|
+
const rect = host.getBoundingClientRect();
|
|
135
150
|
if (doc.offsetWidth - rect.left > rect.right)
|
|
136
|
-
|
|
151
|
+
s.left = "0", s.right = "";
|
|
137
152
|
else
|
|
138
|
-
|
|
153
|
+
s.left = "", s.right = "0";
|
|
139
154
|
if (doc.clientHeight - rect.top > rect.bottom)
|
|
140
|
-
|
|
155
|
+
s.top = "100%", s.bottom = "";
|
|
141
156
|
else
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
s.top = "", s.bottom = "100%";
|
|
158
|
+
s.display = "";
|
|
159
|
+
s.position = "absolute";
|
|
160
|
+
s.minWidth = "100%";
|
|
161
|
+
s.boxSizing = "border-box";
|
|
162
|
+
host.style.position = "relative";
|
|
148
163
|
}
|
|
149
164
|
else {
|
|
150
|
-
|
|
165
|
+
host.style.position = "";
|
|
151
166
|
if (value === false)
|
|
152
|
-
|
|
167
|
+
s.display = "none";
|
|
153
168
|
else
|
|
154
|
-
|
|
169
|
+
s.position = s.display = s.left = s.right = s.top = s.bottom = "";
|
|
155
170
|
}
|
|
156
171
|
}
|
|
157
172
|
applyStyle(block, secondary, styleName, enabled) {
|
|
@@ -163,7 +178,7 @@ export class VerstakHtmlDriver extends HtmlDriver {
|
|
|
163
178
|
e.className = enabled ? styleName : "";
|
|
164
179
|
}
|
|
165
180
|
render(block) {
|
|
166
|
-
if (block.
|
|
181
|
+
if (block.kind <= BlockKind.Table)
|
|
167
182
|
fromNewRow();
|
|
168
183
|
return super.render(block);
|
|
169
184
|
}
|
|
@@ -171,54 +186,53 @@ export class VerstakHtmlDriver extends HtmlDriver {
|
|
|
171
186
|
const Constants = {
|
|
172
187
|
block: "block",
|
|
173
188
|
row: "row",
|
|
174
|
-
layouts: ["
|
|
189
|
+
layouts: ["band", "table", "note", "group", "", ""],
|
|
175
190
|
attribute: "kind",
|
|
176
191
|
};
|
|
177
192
|
const Drivers = {
|
|
178
|
-
|
|
179
|
-
table: new VerstakHtmlDriver(Constants.block, false, b => b.
|
|
180
|
-
|
|
181
|
-
group: new VerstakHtmlDriver(Constants.block, false, b => b.
|
|
182
|
-
|
|
193
|
+
band: new VerstakHtmlDriver(Constants.block, false, b => b.kind = BlockKind.Band),
|
|
194
|
+
table: new VerstakHtmlDriver(Constants.block, false, b => b.kind = BlockKind.Table),
|
|
195
|
+
note: new VerstakHtmlDriver(Constants.block, false, b => b.kind = BlockKind.Note),
|
|
196
|
+
group: new VerstakHtmlDriver(Constants.block, false, b => b.kind = BlockKind.Group),
|
|
197
|
+
row: new VerstakHtmlDriver(Constants.row, true, b => b.kind = BlockKind.Row),
|
|
198
|
+
cursor: new CursorCommandDriver(),
|
|
183
199
|
};
|
|
184
200
|
const VerstakDriversByLayout = [
|
|
185
201
|
b => {
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
css.minWidth = "0";
|
|
202
|
+
const s = b.native.style;
|
|
203
|
+
s.display = "flex";
|
|
204
|
+
s.flexDirection = "column";
|
|
205
|
+
s.alignSelf = b.descriptor.owner.isTable ? "stretch" : "center";
|
|
206
|
+
s.textAlign = "initial";
|
|
207
|
+
s.flexShrink = "1";
|
|
208
|
+
s.minWidth = "0";
|
|
194
209
|
},
|
|
195
210
|
b => {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
const s = b.native.style;
|
|
212
|
+
s.alignSelf = b.descriptor.owner.isTable ? "stretch" : "center";
|
|
213
|
+
s.display = "grid";
|
|
214
|
+
s.flexBasis = "0";
|
|
215
|
+
s.gridAutoRows = "minmax(min-content, 1fr)";
|
|
216
|
+
s.gridAutoColumns = "minmax(min-content, 1fr)";
|
|
217
|
+
s.textAlign = "initial";
|
|
203
218
|
},
|
|
204
219
|
b => {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
220
|
+
const s = b.native.style;
|
|
221
|
+
s.alignSelf = b.descriptor.owner.isTable ? "stretch" : "center";
|
|
222
|
+
s.display = "inline-grid";
|
|
223
|
+
s.flexShrink = "1";
|
|
224
|
+
s.overflow = "";
|
|
225
|
+
s.textOverflow = "";
|
|
226
|
+
s.whiteSpace = "";
|
|
208
227
|
},
|
|
209
228
|
b => {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
css.display = "contents";
|
|
229
|
+
const s = b.native.style;
|
|
230
|
+
s.display = "contents";
|
|
213
231
|
},
|
|
214
232
|
b => {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
css.flexShrink = "1";
|
|
219
|
-
css.overflow = "";
|
|
220
|
-
css.textOverflow = "";
|
|
221
|
-
css.whiteSpace = "";
|
|
233
|
+
const s = b.native.style;
|
|
234
|
+
s.display = b.descriptor.owner.isTable ? "none" : "flex";
|
|
235
|
+
s.flexDirection = "row";
|
|
222
236
|
},
|
|
223
237
|
];
|
|
224
238
|
const AlignToCss = ["stretch", "start", "center", "end"];
|