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.
@@ -1,5 +1,4 @@
1
+ export * from "./Interfaces";
1
2
  export * from "./Utils";
2
- export * from "./CellRange";
3
- export * from "./Cursor";
4
3
  export * from "./Restyler";
5
- export * from "./VBlock";
4
+ export * from "./Verstak";
@@ -1,5 +1,4 @@
1
+ export * from "./Interfaces";
1
2
  export * from "./Utils";
2
- export * from "./CellRange";
3
- export * from "./Cursor";
4
3
  export * from "./Restyler";
5
- export * from "./VBlock";
4
+ export * from "./Verstak";
@@ -1,25 +1,27 @@
1
- import { VBlock, Layout, BlockBuilder, Align, CellRange } from "../core/api";
1
+ import { Block, BlockKind, BlockBuilder, Align, BlockCoords, BlockArea } from "../core/api";
2
2
  import { HtmlDriver } from "./HtmlDriver";
3
- export declare function VSection<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
4
- export declare function VTable<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
5
- export declare function row<T = void>(builder?: (block: void) => T, key?: string): void;
6
- export declare function fromNewRow(key?: string): void;
7
- export declare function VNote(content: string, builder?: BlockBuilder<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
8
- export declare function VHtmlNote(content: string, builder?: BlockBuilder<HTMLElement, void, void>): VBlock<HTMLElement, void, void>;
9
- export declare function VGroup<M = unknown, R = void>(builder?: BlockBuilder<HTMLElement, M, R>, base?: BlockBuilder<HTMLElement, M, R>): VBlock<HTMLElement, M, R>;
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
- applyChildrenLayout(block: VBlock<T, any, any>, value: Layout): void;
12
- applyCellRange(block: VBlock<T>, value: CellRange | undefined): void;
13
- applyWidthGrowth(block: VBlock<T>, value: number): void;
14
- applyMinWidth(block: VBlock<T>, value: string): void;
15
- applyMaxWidth(block: VBlock<T>, value: string): void;
16
- applyHeightGrowth(block: VBlock<T>, value: number): void;
17
- applyMinHeight(block: VBlock<T>, value: string): void;
18
- applyMaxHeight(block: VBlock<T>, value: string): void;
19
- applyContentAlignment(block: VBlock<T>, value: Align): void;
20
- applyBlockAlignment(block: VBlock<T>, value: Align): void;
21
- applyContentWrapping(block: VBlock<T>, value: boolean): void;
22
- applyOverlayVisible(block: VBlock<T>, value: boolean | undefined): void;
23
- applyStyle(block: VBlock<T, any, any>, secondary: boolean, styleName: string, enabled?: boolean): void;
24
- render(block: VBlock<T>): void | Promise<void>;
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 { VBlock, Layout, Align } from "../core/api";
1
+ import { Verstak, BlockKind, Align, CursorCommandDriver, BaseDriver } from "../core/api";
2
2
  import { HtmlDriver } from "./HtmlDriver";
3
- export function VSection(builder, base) {
4
- return VBlock.claim(Drivers.section, builder, base);
3
+ export function Band(builder, base) {
4
+ return Verstak.claim(Drivers.band, builder, base);
5
5
  }
6
- export function VTable(builder, base) {
7
- return VBlock.claim(Drivers.table, builder, base);
6
+ export function Table(builder, base) {
7
+ return Verstak.claim(Drivers.table, builder, base);
8
8
  }
9
- export function row(builder, key) {
10
- fromNewRow(key);
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(key) {
14
- VBlock.claim(Drivers.row, { key });
13
+ export function fromNewRow(shiftCursorDown) {
14
+ Verstak.claim(Drivers.row);
15
15
  }
16
- export function VNote(content, builder) {
17
- return VBlock.claim(Drivers.note, builder, {
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 VHtmlNote(content, builder) {
24
- return VBlock.claim(Drivers.note, builder, {
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 VGroup(builder, base) {
31
- return VBlock.claim(Drivers.group, builder, base);
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
- applyChildrenLayout(block, value) {
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.applyChildrenLayout(block, value);
48
+ super.applyKind(block, value);
39
49
  }
40
- applyCellRange(block, value) {
41
- const css = block.native.style;
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
- css.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
57
+ s.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
48
58
  }
49
59
  else
50
- css.gridArea = "";
51
- super.applyCellRange(block, value);
60
+ s.gridArea = "";
61
+ super.applyCoords(block, value);
52
62
  }
53
63
  applyWidthGrowth(block, value) {
54
- const css = block.native.style;
64
+ const s = block.native.style;
55
65
  if (value > 0) {
56
- css.flexGrow = `${value}`;
57
- css.flexBasis = "0";
66
+ s.flexGrow = `${value}`;
67
+ s.flexBasis = "0";
58
68
  }
59
69
  else {
60
- css.flexGrow = "";
61
- css.flexBasis = "";
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
- if (block.driver.isRow) {
72
- const css = block.native.style;
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
- css.flexGrow = `${value}`;
86
+ s.flexGrow = `${value}`;
75
87
  else
76
- css.flexGrow = "";
88
+ s.flexGrow = "";
77
89
  }
78
- else if (block.host.driver.isRow) {
79
- block.driver.applyBlockAlignment(block, Align.Stretch);
80
- block.host.driver.applyHeightGrowth(block.host, value);
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 css = block.native.style;
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
- css.justifyContent = v;
96
- css.alignItems = h;
97
- css.textAlign = t;
110
+ s.justifyContent = v;
111
+ s.alignItems = h;
112
+ s.textAlign = t;
98
113
  }
99
114
  else
100
- css.justifyContent = css.alignContent = css.textAlign = "";
115
+ s.justifyContent = s.alignContent = s.textAlign = "";
101
116
  }
102
117
  applyBlockAlignment(block, value) {
103
- const css = block.native.style;
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
- css.alignSelf = v;
108
- css.justifySelf = h;
122
+ s.alignSelf = v;
123
+ s.justifySelf = h;
109
124
  }
110
125
  else
111
- css.alignSelf = css.justifySelf = "";
126
+ s.alignSelf = s.justifySelf = "";
112
127
  }
113
128
  applyContentWrapping(block, value) {
114
- const css = block.native.style;
129
+ const s = block.native.style;
115
130
  if (value) {
116
- css.flexFlow = "wrap";
117
- css.overflow = "";
118
- css.textOverflow = "";
119
- css.whiteSpace = "";
131
+ s.flexFlow = "wrap";
132
+ s.overflow = "";
133
+ s.textOverflow = "";
134
+ s.whiteSpace = "";
120
135
  }
121
136
  else {
122
- css.flexFlow = "";
123
- css.overflow = "hidden";
124
- css.textOverflow = "ellipsis";
125
- css.whiteSpace = "nowrap";
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 css = e.style;
131
- const parent = HtmlDriver.findNearestParentHtmlBlock(block).native;
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 = parent.getBoundingClientRect();
149
+ const rect = host.getBoundingClientRect();
135
150
  if (doc.offsetWidth - rect.left > rect.right)
136
- css.left = "0", css.right = "";
151
+ s.left = "0", s.right = "";
137
152
  else
138
- css.left = "", css.right = "0";
153
+ s.left = "", s.right = "0";
139
154
  if (doc.clientHeight - rect.top > rect.bottom)
140
- css.top = "100%", css.bottom = "";
155
+ s.top = "100%", s.bottom = "";
141
156
  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";
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
- parent.style.position = "";
165
+ host.style.position = "";
151
166
  if (value === false)
152
- css.display = "none";
167
+ s.display = "none";
153
168
  else
154
- css.position = css.display = css.left = css.right = css.top = css.bottom = "";
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.childrenLayout < Layout.Row)
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: ["section", "table", "", "group", "note"],
189
+ layouts: ["band", "table", "note", "group", "", ""],
175
190
  attribute: "kind",
176
191
  };
177
192
  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),
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 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";
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 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";
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 css = b.native.style;
206
- css.display = "flex";
207
- css.flexDirection = "row";
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 css = b.native.style;
211
- css.alignSelf = "center";
212
- css.display = "contents";
229
+ const s = b.native.style;
230
+ s.display = "contents";
213
231
  },
214
232
  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 = "";
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"];