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