verstak 0.22.412 → 0.22.500

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,4 +1,64 @@
1
- export class CellRangeUtils {
1
+ export class Layout {
2
+ constructor() {
3
+ this.maxColumnCount = 0;
4
+ this.maxRowCount = 0;
5
+ this.actualColumnCount = 0;
6
+ this.actualRowCount = 0;
7
+ this.columnCursor = 0;
8
+ this.rowCursor = 0;
9
+ this.newRowCursor = 0;
10
+ }
11
+ reset(maxColumnCount, maxRowCount) {
12
+ this.maxColumnCount = maxColumnCount;
13
+ this.maxRowCount = maxRowCount;
14
+ this.actualColumnCount = 0;
15
+ this.actualRowCount = 0;
16
+ this.columnCursor = 0;
17
+ this.rowCursor = 0;
18
+ this.newRowCursor = 0;
19
+ }
20
+ claim(p, result) {
21
+ var _a, _b;
22
+ const maxColumnCount = this.maxColumnCount !== 0 ? this.maxColumnCount : this.actualColumnCount;
23
+ const maxRowCount = this.maxRowCount !== 0 ? this.maxRowCount : this.actualRowCount;
24
+ if (p.area) {
25
+ Layout.parseCellRange(p.area, result);
26
+ absolutizeCellRange(result, this.columnCursor + 1, this.rowCursor + 1, maxColumnCount, maxRowCount, result);
27
+ }
28
+ else {
29
+ if (p.lineBegin) {
30
+ this.columnCursor = 0;
31
+ this.rowCursor = this.newRowCursor;
32
+ }
33
+ let w = (_a = p.columns) !== null && _a !== void 0 ? _a : 1;
34
+ if (w === 0)
35
+ w = maxColumnCount;
36
+ if (w >= 0) {
37
+ result.x1 = this.columnCursor + 1;
38
+ result.x2 = absolutizePosition(result.x1 + w, 0, maxColumnCount);
39
+ if (p.cursorRight !== false)
40
+ this.columnCursor = result.x2;
41
+ }
42
+ else {
43
+ result.x1 = Math.max(this.columnCursor + w, 1);
44
+ result.x2 = this.columnCursor;
45
+ }
46
+ let h = (_b = p.rows) !== null && _b !== void 0 ? _b : 1;
47
+ if (h === 0)
48
+ h = maxRowCount;
49
+ if (h >= 0) {
50
+ result.y1 = this.rowCursor + 1;
51
+ result.y2 = absolutizePosition(result.y1 + h, 0, maxRowCount);
52
+ if (p.cursorDown !== false && result.y2 > this.newRowCursor)
53
+ this.newRowCursor = result.y2;
54
+ }
55
+ else {
56
+ result.y1 = Math.max(this.rowCursor + h, 1);
57
+ result.y2 = this.rowCursor;
58
+ }
59
+ }
60
+ return result;
61
+ }
2
62
  static parseCellRange(text, result) {
3
63
  let i = 0;
4
64
  let value = 0;
@@ -131,24 +191,10 @@ export class CellRangeUtils {
131
191
  return result;
132
192
  }
133
193
  static emitCellRange(value) {
134
- const p1 = CellRangeUtils.emitCellPos(value.x1, value.y1);
135
- const p2 = CellRangeUtils.emitCellPos(value.x2, value.y2);
194
+ const p1 = emitCellPosition(value.x1, value.y1);
195
+ const p2 = emitCellPosition(value.x2, value.y2);
136
196
  return `${p1}${p2 !== '' ? `:${p2}` : ''}`;
137
197
  }
138
- static emitCellPos(x, y) {
139
- let result = '';
140
- if (x > 0 && y > 0)
141
- result = `${emitLetters(x - 1)}${y}`;
142
- else if (x > 0 && y < 0)
143
- result = `${emitLetters(x - 1)}(${-y})`;
144
- else if (x < 0 && y > 0)
145
- result = `(${emitLetters(-x - 1)})${y}`;
146
- else if (x < 0 && y < 0)
147
- result = `(${emitLetters(-x - 1)}${-y})`;
148
- else
149
- result = '';
150
- return result;
151
- }
152
198
  }
153
199
  function isWhitespace(char) {
154
200
  return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
@@ -173,3 +219,41 @@ function emitLetters(n) {
173
219
  }
174
220
  return result;
175
221
  }
222
+ function emitCellPosition(x, y) {
223
+ let result = '';
224
+ if (x > 0 && y > 0)
225
+ result = `${emitLetters(x - 1)}${y}`;
226
+ else if (x > 0 && y < 0)
227
+ result = `${emitLetters(x - 1)}(${-y})`;
228
+ else if (x < 0 && y > 0)
229
+ result = `(${emitLetters(-x - 1)})${y}`;
230
+ else if (x < 0 && y < 0)
231
+ result = `(${emitLetters(-x - 1)}${-y})`;
232
+ else
233
+ result = '';
234
+ return result;
235
+ }
236
+ function absolutizeCellRange(area, cursorX, cursorY, maxWidth, maxHeight, result) {
237
+ const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
238
+ const x2 = absolutizePosition(area.x2, cursorX, maxWidth);
239
+ if (x1 <= x2)
240
+ result.x1 = x1, result.x2 = x2;
241
+ else
242
+ result.x1 = x2, result.x2 = x1;
243
+ const y1 = absolutizePosition(area.y1, cursorY, maxHeight);
244
+ const y2 = absolutizePosition(area.y2, cursorY, maxHeight);
245
+ if (y1 <= y2)
246
+ result.y1 = y1, result.y2 = y2;
247
+ else
248
+ result.y1 = y2, result.y2 = y1;
249
+ return result;
250
+ }
251
+ function absolutizePosition(pos, cursor, max) {
252
+ if (pos === 0)
253
+ pos = cursor;
254
+ else if (pos < 0)
255
+ pos = Math.max(max + pos, 1);
256
+ else
257
+ pos = Math.min(pos, max);
258
+ return pos;
259
+ }
@@ -1,5 +1,5 @@
1
- export declare function restyler<T>(restyle: () => T): RxStyler<T>;
2
- export declare class RxStyler<T> {
1
+ export declare function restyler<T>(restyle: () => T): ObservablesStyles<T>;
2
+ export declare class ObservablesStyles<T> {
3
3
  private readonly restyle;
4
4
  constructor(restyle: () => T);
5
5
  protected cache(): T;
@@ -9,9 +9,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { cached, Transaction } from 'reactronic';
11
11
  export function restyler(restyle) {
12
- return Transaction.run(null, () => new RxStyler(restyle));
12
+ return Transaction.run(null, () => new ObservablesStyles(restyle));
13
13
  }
14
- export class RxStyler {
14
+ export class ObservablesStyles {
15
15
  constructor(restyle) {
16
16
  this.restyle = restyle;
17
17
  }
@@ -27,4 +27,4 @@ __decorate([
27
27
  __metadata("design:type", Function),
28
28
  __metadata("design:paramtypes", []),
29
29
  __metadata("design:returntype", Object)
30
- ], RxStyler.prototype, "cache", null);
30
+ ], ObservablesStyles.prototype, "cache", null);
@@ -1,4 +1,5 @@
1
- export * from './RxNode';
1
+ export * from './Utils';
2
+ export * from './Layout';
3
+ export * from './Block';
2
4
  export * from './Elements';
3
5
  export * from './Restyler';
4
- export * from './Utils';
@@ -1,4 +1,5 @@
1
- export * from './RxNode';
1
+ export * from './Utils';
2
+ export * from './Layout';
3
+ export * from './Block';
2
4
  export * from './Elements';
3
5
  export * from './Restyler';
4
- export * from './Utils';
@@ -0,0 +1,11 @@
1
+ import { Block, Render, Place, BlockOptions } from '../core/api';
2
+ export interface ElasticSize {
3
+ line: string | number;
4
+ min?: string;
5
+ max?: string;
6
+ growth?: number;
7
+ }
8
+ export declare function InlBlock<M = unknown, R = void>(name: string, options: BlockOptions<Place> | undefined, renderer: Render<HTMLDivElement, M, Place, R>): Block<HTMLDivElement, M, Place, R>;
9
+ export declare function RxBlock<M = unknown, R = void>(name: string, options: BlockOptions<Place> | undefined, renderer: Render<HTMLDivElement, M, Place, R>): Block<HTMLDivElement, M, Place, R>;
10
+ export declare function InlCluster<M = unknown, R = void>(name: string, options: BlockOptions | undefined, renderer: Render<HTMLDivElement, M, void, R>): Block<HTMLDivElement, M, void, R>;
11
+ export declare function RxCluster<M = unknown, R = void>(name: string, options: BlockOptions | undefined, renderer: Render<HTMLDivElement, M, void, R>): Block<HTMLDivElement, M, void, R>;
@@ -0,0 +1,14 @@
1
+ import { Reaction, Inline } from '../core/api';
2
+ import { Div, RxDiv } from './HtmlElements';
3
+ export function InlBlock(name, options, renderer) {
4
+ return Div(name, options, renderer);
5
+ }
6
+ export function RxBlock(name, options, renderer) {
7
+ return RxDiv(name, options, renderer);
8
+ }
9
+ export function InlCluster(name, options, renderer) {
10
+ return Inline(name, options, renderer);
11
+ }
12
+ export function RxCluster(name, options, renderer) {
13
+ return Reaction(name, options, renderer);
14
+ }