verstak 0.23.124 → 0.24.104
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/build/dist/source/core/api.d.ts +0 -3
- package/build/dist/source/core/api.js +0 -3
- package/build/dist/source/html/El.d.ts +163 -0
- package/build/dist/source/html/El.js +508 -0
- package/build/dist/source/{core/Utils.d.ts → html/ElUtils.d.ts} +3 -4
- package/build/dist/source/{core/Utils.js → html/ElUtils.js} +14 -46
- package/build/dist/source/html/Elements.d.ts +8 -20
- package/build/dist/source/html/Elements.js +22 -200
- package/build/dist/source/html/HtmlDriver.d.ts +18 -15
- package/build/dist/source/html/HtmlDriver.js +31 -31
- package/build/dist/source/html/HtmlElements.d.ts +176 -175
- package/build/dist/source/html/HtmlElements.js +178 -177
- package/build/dist/source/html/ReactingFocuser.js +2 -2
- package/build/dist/source/html/api.d.ts +1 -0
- package/build/dist/source/html/api.js +1 -0
- package/build/dist/source/html/sensors/FocusSensor.js +1 -1
- package/build/dist/source/html/sensors/ResizeSensor.d.ts +1 -1
- package/build/dist/source/html/sensors/WindowSensor.js +1 -1
- package/package.json +2 -2
- package/build/dist/source/core/Interfaces.d.ts +0 -132
- package/build/dist/source/core/Interfaces.js +0 -34
- package/build/dist/source/core/Verstak.d.ts +0 -61
- package/build/dist/source/core/Verstak.js +0 -887
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { RxNode, BaseDriver } from "reactronic";
|
|
2
|
+
export declare class ElDriver<T extends Element, M = unknown, C = unknown> extends BaseDriver<El<T, M, C, void>> {
|
|
3
|
+
allocate(node: RxNode<El<T, M, C, void>>): El<T, M, C, void>;
|
|
4
|
+
}
|
|
5
|
+
export interface BaseEl<T = any, M = any, C = any, R = void> {
|
|
6
|
+
readonly node: RxNode<El<T, M, C, R>>;
|
|
7
|
+
model: M;
|
|
8
|
+
controller: C;
|
|
9
|
+
}
|
|
10
|
+
export interface El<T = any, M = any, C = any, R = void> extends BaseEl<T, M, C, R> {
|
|
11
|
+
native: T;
|
|
12
|
+
kind: ElKind;
|
|
13
|
+
area: ElArea;
|
|
14
|
+
widthGrowth: number;
|
|
15
|
+
minWidth: string;
|
|
16
|
+
maxWidth: string;
|
|
17
|
+
heightGrowth: number;
|
|
18
|
+
minHeight: string;
|
|
19
|
+
maxHeight: string;
|
|
20
|
+
contentAlignment: Align;
|
|
21
|
+
elementAlignment: Align;
|
|
22
|
+
contentWrapping: boolean;
|
|
23
|
+
overlayVisible: boolean | undefined;
|
|
24
|
+
useStyle(styleName: string, enabled?: boolean): void;
|
|
25
|
+
}
|
|
26
|
+
export declare enum ElKind {
|
|
27
|
+
Section = 0,
|
|
28
|
+
Table = 1,
|
|
29
|
+
Note = 2,
|
|
30
|
+
Group = 3,
|
|
31
|
+
Part = 4,
|
|
32
|
+
Cursor = 5,
|
|
33
|
+
Native = 6
|
|
34
|
+
}
|
|
35
|
+
export interface ElCoords {
|
|
36
|
+
x1: number;
|
|
37
|
+
y1: number;
|
|
38
|
+
x2: number;
|
|
39
|
+
y2: number;
|
|
40
|
+
}
|
|
41
|
+
export declare enum Align {
|
|
42
|
+
Default = 16,
|
|
43
|
+
ToBounds = 0,
|
|
44
|
+
ToLeft = 1,
|
|
45
|
+
ToCenterX = 2,
|
|
46
|
+
ToRight = 3,
|
|
47
|
+
ToTop = 4,
|
|
48
|
+
ToCenterY = 8,
|
|
49
|
+
ToBottom = 12,
|
|
50
|
+
ToCenter = 10
|
|
51
|
+
}
|
|
52
|
+
export interface ElasticSize {
|
|
53
|
+
cells?: number;
|
|
54
|
+
min?: string;
|
|
55
|
+
max?: string;
|
|
56
|
+
growth?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface TrackSize extends ElasticSize {
|
|
59
|
+
track?: string | number;
|
|
60
|
+
}
|
|
61
|
+
export type ElArea = undefined | string | {
|
|
62
|
+
cellsOverWidth?: number;
|
|
63
|
+
cellsOverHeight?: number;
|
|
64
|
+
};
|
|
65
|
+
export declare class ElImpl<T extends Element = any, M = any, C = any, R = any> implements El<T, M, C, R> {
|
|
66
|
+
readonly node: RxNode<El<T, M, C, R>>;
|
|
67
|
+
maxColumnCount: number;
|
|
68
|
+
maxRowCount: number;
|
|
69
|
+
cursorPosition?: CursorPosition;
|
|
70
|
+
native: T;
|
|
71
|
+
model: M;
|
|
72
|
+
controller: C;
|
|
73
|
+
private _kind;
|
|
74
|
+
private _area;
|
|
75
|
+
private _coords;
|
|
76
|
+
private _widthGrowth;
|
|
77
|
+
private _minWidth;
|
|
78
|
+
private _maxWidth;
|
|
79
|
+
private _heightGrowth;
|
|
80
|
+
private _minHeight;
|
|
81
|
+
private _maxHeight;
|
|
82
|
+
private _contentAlignment;
|
|
83
|
+
private _elementAlignment;
|
|
84
|
+
private _contentWrapping;
|
|
85
|
+
private _overlayVisible;
|
|
86
|
+
private _hasStyles;
|
|
87
|
+
constructor(node: RxNode<El<T, M, C, R>>);
|
|
88
|
+
prepareForUpdate(): void;
|
|
89
|
+
get isSection(): boolean;
|
|
90
|
+
get isTable(): boolean;
|
|
91
|
+
get isAuxiliary(): boolean;
|
|
92
|
+
get kind(): ElKind;
|
|
93
|
+
set kind(value: ElKind);
|
|
94
|
+
get area(): ElArea;
|
|
95
|
+
set area(value: ElArea);
|
|
96
|
+
get widthGrowth(): number;
|
|
97
|
+
set widthGrowth(value: number);
|
|
98
|
+
get minWidth(): string;
|
|
99
|
+
set minWidth(value: string);
|
|
100
|
+
get maxWidth(): string;
|
|
101
|
+
set maxWidth(value: string);
|
|
102
|
+
get heightGrowth(): number;
|
|
103
|
+
set heightGrowth(value: number);
|
|
104
|
+
get minHeight(): string;
|
|
105
|
+
set minHeight(value: string);
|
|
106
|
+
get maxHeight(): string;
|
|
107
|
+
set maxHeight(value: string);
|
|
108
|
+
get contentAlignment(): Align;
|
|
109
|
+
set contentAlignment(value: Align);
|
|
110
|
+
get elementAlignment(): Align;
|
|
111
|
+
set elementAlignment(value: Align);
|
|
112
|
+
get contentWrapping(): boolean;
|
|
113
|
+
set contentWrapping(value: boolean);
|
|
114
|
+
get overlayVisible(): boolean | undefined;
|
|
115
|
+
set overlayVisible(value: boolean | undefined);
|
|
116
|
+
useStyle(styleName: string, enabled?: boolean): void;
|
|
117
|
+
private rowBreak;
|
|
118
|
+
}
|
|
119
|
+
declare class CursorPosition {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
runningMaxX: number;
|
|
123
|
+
runningMaxY: number;
|
|
124
|
+
flags: CursorFlags;
|
|
125
|
+
constructor(prev: CursorPosition);
|
|
126
|
+
}
|
|
127
|
+
declare enum CursorFlags {
|
|
128
|
+
None = 0,
|
|
129
|
+
OwnCursorPosition = 1,
|
|
130
|
+
UsesRunningColumnCount = 2,
|
|
131
|
+
UsesRunningRowCount = 4
|
|
132
|
+
}
|
|
133
|
+
export declare class CursorCommand {
|
|
134
|
+
absolute?: string;
|
|
135
|
+
columnShift?: number;
|
|
136
|
+
rowShift?: number;
|
|
137
|
+
}
|
|
138
|
+
export declare class CursorCommandDriver extends ElDriver<Element, unknown, void> {
|
|
139
|
+
constructor();
|
|
140
|
+
}
|
|
141
|
+
export declare class Apply {
|
|
142
|
+
static kind<T extends Element>(element: El<T, any, any, any>, value: ElKind): void;
|
|
143
|
+
static coords<T extends Element>(element: El<T, any, any, any>, value: ElCoords | undefined): void;
|
|
144
|
+
static widthGrowth<T extends Element>(element: El<T, any, any, any>, value: number): void;
|
|
145
|
+
static minWidth<T extends Element>(element: El<T, any, any, any>, value: string): void;
|
|
146
|
+
static applyMaxWidth<T extends Element>(element: El<T, any, any, any>, value: string): void;
|
|
147
|
+
static heightGrowth<T extends Element>(element: El<T, any, any, any>, value: number): void;
|
|
148
|
+
static minHeight<T extends Element>(element: El<T, any, any, any>, value: string): void;
|
|
149
|
+
static maxHeight<T extends Element>(element: El<T, any, any, any>, value: string): void;
|
|
150
|
+
static contentAlignment<T extends Element>(element: El<T, any, any, any>, value: Align): void;
|
|
151
|
+
static elementAlignment<T extends Element>(element: El<T, any, any, any>, value: Align): void;
|
|
152
|
+
static contentWrapping<T extends Element>(element: El<T, any, any, any>, value: boolean): void;
|
|
153
|
+
static overlayVisible<T extends Element>(element: El<T, any, any, any>, value: boolean | undefined): void;
|
|
154
|
+
static style<T extends Element>(element: El<T, any, any, any>, secondary: boolean, styleName: string, enabled?: boolean): void;
|
|
155
|
+
}
|
|
156
|
+
export declare const Constants: {
|
|
157
|
+
element: string;
|
|
158
|
+
partition: string;
|
|
159
|
+
layouts: string[];
|
|
160
|
+
keyAttrName: string;
|
|
161
|
+
kindAttrName: string;
|
|
162
|
+
};
|
|
163
|
+
export {};
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { RxTree, BaseDriver } from "reactronic";
|
|
2
|
+
import { equalElCoords, parseElCoords } from "./ElUtils.js";
|
|
3
|
+
export class ElDriver extends BaseDriver {
|
|
4
|
+
allocate(node) {
|
|
5
|
+
return new ElImpl(node);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export var ElKind;
|
|
9
|
+
(function (ElKind) {
|
|
10
|
+
ElKind[ElKind["Section"] = 0] = "Section";
|
|
11
|
+
ElKind[ElKind["Table"] = 1] = "Table";
|
|
12
|
+
ElKind[ElKind["Note"] = 2] = "Note";
|
|
13
|
+
ElKind[ElKind["Group"] = 3] = "Group";
|
|
14
|
+
ElKind[ElKind["Part"] = 4] = "Part";
|
|
15
|
+
ElKind[ElKind["Cursor"] = 5] = "Cursor";
|
|
16
|
+
ElKind[ElKind["Native"] = 6] = "Native";
|
|
17
|
+
})(ElKind || (ElKind = {}));
|
|
18
|
+
export var Align;
|
|
19
|
+
(function (Align) {
|
|
20
|
+
Align[Align["Default"] = 16] = "Default";
|
|
21
|
+
Align[Align["ToBounds"] = 0] = "ToBounds";
|
|
22
|
+
Align[Align["ToLeft"] = 1] = "ToLeft";
|
|
23
|
+
Align[Align["ToCenterX"] = 2] = "ToCenterX";
|
|
24
|
+
Align[Align["ToRight"] = 3] = "ToRight";
|
|
25
|
+
Align[Align["ToTop"] = 4] = "ToTop";
|
|
26
|
+
Align[Align["ToCenterY"] = 8] = "ToCenterY";
|
|
27
|
+
Align[Align["ToBottom"] = 12] = "ToBottom";
|
|
28
|
+
Align[Align["ToCenter"] = 10] = "ToCenter";
|
|
29
|
+
})(Align || (Align = {}));
|
|
30
|
+
export class ElImpl {
|
|
31
|
+
constructor(node) {
|
|
32
|
+
this.node = node;
|
|
33
|
+
this.maxColumnCount = 0;
|
|
34
|
+
this.maxRowCount = 0;
|
|
35
|
+
this.cursorPosition = undefined;
|
|
36
|
+
this.native = undefined;
|
|
37
|
+
this.model = undefined;
|
|
38
|
+
this.controller = undefined;
|
|
39
|
+
this._kind = ElKind.Part;
|
|
40
|
+
this._area = undefined;
|
|
41
|
+
this._coords = UndefinedElCoords;
|
|
42
|
+
this._widthGrowth = 0;
|
|
43
|
+
this._minWidth = "";
|
|
44
|
+
this._maxWidth = "";
|
|
45
|
+
this._heightGrowth = 0;
|
|
46
|
+
this._minHeight = "";
|
|
47
|
+
this._maxHeight = "";
|
|
48
|
+
this._contentAlignment = Align.Default;
|
|
49
|
+
this._elementAlignment = Align.Default;
|
|
50
|
+
this._contentWrapping = true;
|
|
51
|
+
this._overlayVisible = undefined;
|
|
52
|
+
this._hasStyles = false;
|
|
53
|
+
}
|
|
54
|
+
prepareForUpdate() {
|
|
55
|
+
this._area = undefined;
|
|
56
|
+
this._hasStyles = false;
|
|
57
|
+
}
|
|
58
|
+
get isSection() { return this.kind === ElKind.Section; }
|
|
59
|
+
get isTable() { return this.kind === ElKind.Table; }
|
|
60
|
+
get isAuxiliary() { return this.kind > ElKind.Note; }
|
|
61
|
+
get kind() { return this._kind; }
|
|
62
|
+
set kind(value) {
|
|
63
|
+
if (value !== this._kind || this.node.stamp >= Number.MAX_SAFE_INTEGER - 1) {
|
|
64
|
+
if (this.native !== undefined)
|
|
65
|
+
Apply.kind(this, value);
|
|
66
|
+
this._kind = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
get area() { return this._area; }
|
|
70
|
+
set area(value) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
const node = this.node;
|
|
73
|
+
const driver = node.driver;
|
|
74
|
+
if (!driver.isPartitionSeparator) {
|
|
75
|
+
const owner = node.owner;
|
|
76
|
+
const ownerEl = owner.element;
|
|
77
|
+
const prevEl = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.element;
|
|
78
|
+
const cursorPosition = (_b = prevEl === null || prevEl === void 0 ? void 0 : prevEl.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
|
|
79
|
+
const newCursorPosition = this.cursorPosition = owner.children.isStrict ? new CursorPosition(cursorPosition) : undefined;
|
|
80
|
+
const isCursorElement = driver instanceof CursorCommandDriver;
|
|
81
|
+
const coords = getEffectiveElCoords(!isCursorElement, value, ownerEl.maxColumnCount, ownerEl.maxRowCount, cursorPosition, newCursorPosition);
|
|
82
|
+
if (!equalElCoords(coords, this._coords)) {
|
|
83
|
+
if (this.native !== undefined)
|
|
84
|
+
Apply.coords(this, coords);
|
|
85
|
+
this._coords = coords;
|
|
86
|
+
}
|
|
87
|
+
this._area = value !== null && value !== void 0 ? value : {};
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
this.rowBreak();
|
|
91
|
+
}
|
|
92
|
+
get widthGrowth() { return this._widthGrowth; }
|
|
93
|
+
set widthGrowth(value) {
|
|
94
|
+
if (value !== this._widthGrowth) {
|
|
95
|
+
Apply.widthGrowth(this, value);
|
|
96
|
+
this._widthGrowth = value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
get minWidth() { return this._minWidth; }
|
|
100
|
+
set minWidth(value) {
|
|
101
|
+
if (value !== this._minWidth) {
|
|
102
|
+
Apply.minWidth(this, value);
|
|
103
|
+
this._minWidth = value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
get maxWidth() { return this._maxWidth; }
|
|
107
|
+
set maxWidth(value) {
|
|
108
|
+
if (value !== this._maxWidth) {
|
|
109
|
+
Apply.applyMaxWidth(this, value);
|
|
110
|
+
this._maxWidth = value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
get heightGrowth() { return this._heightGrowth; }
|
|
114
|
+
set heightGrowth(value) {
|
|
115
|
+
if (value !== this._heightGrowth) {
|
|
116
|
+
Apply.heightGrowth(this, value);
|
|
117
|
+
this._heightGrowth = value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
get minHeight() { return this._minHeight; }
|
|
121
|
+
set minHeight(value) {
|
|
122
|
+
if (value !== this._minHeight) {
|
|
123
|
+
Apply.minHeight(this, value);
|
|
124
|
+
this._minHeight = value;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get maxHeight() { return this._maxHeight; }
|
|
128
|
+
set maxHeight(value) {
|
|
129
|
+
if (value !== this._maxHeight) {
|
|
130
|
+
Apply.maxHeight(this, value);
|
|
131
|
+
this._maxHeight = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
get contentAlignment() { return this._contentAlignment; }
|
|
135
|
+
set contentAlignment(value) {
|
|
136
|
+
if (value !== this._contentAlignment) {
|
|
137
|
+
Apply.contentAlignment(this, value);
|
|
138
|
+
this._contentAlignment = value;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
get elementAlignment() { return this._elementAlignment; }
|
|
142
|
+
set elementAlignment(value) {
|
|
143
|
+
if (value !== this._elementAlignment) {
|
|
144
|
+
Apply.elementAlignment(this, value);
|
|
145
|
+
this._elementAlignment = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
get contentWrapping() { return this._contentWrapping; }
|
|
149
|
+
set contentWrapping(value) {
|
|
150
|
+
if (value !== this._contentWrapping) {
|
|
151
|
+
Apply.contentWrapping(this, value);
|
|
152
|
+
this._contentWrapping = value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
get overlayVisible() { return this._overlayVisible; }
|
|
156
|
+
set overlayVisible(value) {
|
|
157
|
+
if (value !== this._overlayVisible) {
|
|
158
|
+
Apply.overlayVisible(this, value);
|
|
159
|
+
this._overlayVisible = value;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
useStyle(styleName, enabled) {
|
|
163
|
+
Apply.style(this, this._hasStyles, styleName, enabled);
|
|
164
|
+
this._hasStyles = true;
|
|
165
|
+
}
|
|
166
|
+
rowBreak() {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
const node = this.node;
|
|
169
|
+
const prevEl = (_a = node.slot.prev) === null || _a === void 0 ? void 0 : _a.instance.element;
|
|
170
|
+
const cursorPosition = (_b = prevEl === null || prevEl === void 0 ? void 0 : prevEl.cursorPosition) !== null && _b !== void 0 ? _b : InitialCursorPosition;
|
|
171
|
+
const newCursorPosition = this.cursorPosition = new CursorPosition(cursorPosition);
|
|
172
|
+
newCursorPosition.x = 1;
|
|
173
|
+
newCursorPosition.y = newCursorPosition.runningMaxY + 1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class CursorPosition {
|
|
177
|
+
constructor(prev) {
|
|
178
|
+
this.x = prev.x;
|
|
179
|
+
this.y = prev.y;
|
|
180
|
+
this.runningMaxX = prev.runningMaxX;
|
|
181
|
+
this.runningMaxY = prev.runningMaxY;
|
|
182
|
+
this.flags = prev.flags & ~CursorFlags.OwnCursorPosition;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
var CursorFlags;
|
|
186
|
+
(function (CursorFlags) {
|
|
187
|
+
CursorFlags[CursorFlags["None"] = 0] = "None";
|
|
188
|
+
CursorFlags[CursorFlags["OwnCursorPosition"] = 1] = "OwnCursorPosition";
|
|
189
|
+
CursorFlags[CursorFlags["UsesRunningColumnCount"] = 2] = "UsesRunningColumnCount";
|
|
190
|
+
CursorFlags[CursorFlags["UsesRunningRowCount"] = 4] = "UsesRunningRowCount";
|
|
191
|
+
})(CursorFlags || (CursorFlags = {}));
|
|
192
|
+
const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
193
|
+
const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
|
|
194
|
+
function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition, newCursorPosition) {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
let result;
|
|
197
|
+
if (typeof (area) === "string") {
|
|
198
|
+
result = parseElCoords(area, { x1: 0, y1: 0, x2: 0, y2: 0 });
|
|
199
|
+
absolutizeElCoords(result, cursorPosition.x, cursorPosition.y, maxX || Infinity, maxY || Infinity, result);
|
|
200
|
+
if (newCursorPosition) {
|
|
201
|
+
newCursorPosition.x = isRegularElement ? result.x2 + 1 : result.x1;
|
|
202
|
+
newCursorPosition.y = result.y1;
|
|
203
|
+
newCursorPosition.flags = CursorFlags.OwnCursorPosition;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (newCursorPosition) {
|
|
207
|
+
let dx;
|
|
208
|
+
let dy;
|
|
209
|
+
if (area) {
|
|
210
|
+
dx = (_a = area.cellsOverWidth) !== null && _a !== void 0 ? _a : 1;
|
|
211
|
+
dy = (_b = area.cellsOverHeight) !== null && _b !== void 0 ? _b : 1;
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
dx = dy = 1;
|
|
215
|
+
const runningX = maxX !== 0 ? maxX : cursorPosition.runningMaxX;
|
|
216
|
+
const runningY = maxY !== 0 ? maxY : cursorPosition.runningMaxY;
|
|
217
|
+
result = { x1: 0, y1: 0, x2: 0, y2: 0 };
|
|
218
|
+
if (dx === 0 && isRegularElement) {
|
|
219
|
+
dx = runningX || 1;
|
|
220
|
+
newCursorPosition.flags = CursorFlags.UsesRunningColumnCount;
|
|
221
|
+
}
|
|
222
|
+
if (dx >= 0) {
|
|
223
|
+
if (isRegularElement) {
|
|
224
|
+
result.x1 = cursorPosition.x;
|
|
225
|
+
result.x2 = absolutizePosition(result.x1 + dx - 1, 0, maxX || Infinity);
|
|
226
|
+
newCursorPosition.x = result.x2 + 1;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
result.x1 = result.x2 = cursorPosition.x + dx;
|
|
230
|
+
newCursorPosition.x = result.x2;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
if (isRegularElement) {
|
|
235
|
+
result.x1 = Math.max(cursorPosition.x + dx, 1);
|
|
236
|
+
result.x2 = cursorPosition.x;
|
|
237
|
+
newCursorPosition.x = result.x2 + 1;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
result.x1 = result.x2 = cursorPosition.x + dx;
|
|
241
|
+
newCursorPosition.x = result.x2;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (dy === 0 && isRegularElement) {
|
|
245
|
+
dy = runningY || 1;
|
|
246
|
+
newCursorPosition.flags |= CursorFlags.UsesRunningRowCount;
|
|
247
|
+
}
|
|
248
|
+
if (dy >= 0) {
|
|
249
|
+
if (isRegularElement) {
|
|
250
|
+
result.y1 = cursorPosition.y;
|
|
251
|
+
result.y2 = absolutizePosition(result.y1 + dy - 1, 0, maxY || Infinity);
|
|
252
|
+
if (result.y2 > newCursorPosition.runningMaxY)
|
|
253
|
+
newCursorPosition.runningMaxY = result.y2;
|
|
254
|
+
}
|
|
255
|
+
else
|
|
256
|
+
result.y1 = result.y2 = cursorPosition.y + dy;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
if (isRegularElement) {
|
|
260
|
+
result.y1 = Math.max(cursorPosition.y + dy, 1);
|
|
261
|
+
result.y2 = cursorPosition.y;
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
result.y1 = result.y2 = cursorPosition.y + dy;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else
|
|
268
|
+
throw new Error("relative layout requires sequential children");
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
function absolutizeElCoords(area, cursorX, cursorY, maxWidth, maxHeight, result) {
|
|
272
|
+
const x1 = absolutizePosition(area.x1, cursorX, maxWidth);
|
|
273
|
+
const x2 = absolutizePosition(area.x2, x1, maxWidth);
|
|
274
|
+
if (x1 <= x2)
|
|
275
|
+
result.x1 = x1, result.x2 = x2;
|
|
276
|
+
else
|
|
277
|
+
result.x1 = x2, result.x2 = x1;
|
|
278
|
+
const y1 = absolutizePosition(area.y1, cursorY, maxHeight);
|
|
279
|
+
const y2 = absolutizePosition(area.y2, y1, maxHeight);
|
|
280
|
+
if (y1 <= y2)
|
|
281
|
+
result.y1 = y1, result.y2 = y2;
|
|
282
|
+
else
|
|
283
|
+
result.y1 = y2, result.y2 = y1;
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
function absolutizePosition(pos, cursor, max) {
|
|
287
|
+
if (pos === 0)
|
|
288
|
+
pos = cursor;
|
|
289
|
+
else if (pos < 0)
|
|
290
|
+
pos = Math.max(max + pos, 1);
|
|
291
|
+
else
|
|
292
|
+
pos = Math.min(pos, max);
|
|
293
|
+
return pos;
|
|
294
|
+
}
|
|
295
|
+
export class CursorCommand {
|
|
296
|
+
}
|
|
297
|
+
export class CursorCommandDriver extends ElDriver {
|
|
298
|
+
constructor() {
|
|
299
|
+
super("cursor", false, el => el.kind = ElKind.Cursor);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
export class Apply {
|
|
303
|
+
static kind(element, value) {
|
|
304
|
+
const kind = Constants.layouts[value];
|
|
305
|
+
kind && element.native.setAttribute(Constants.kindAttrName, kind);
|
|
306
|
+
VerstakDriversByLayout[value](element);
|
|
307
|
+
}
|
|
308
|
+
static coords(element, value) {
|
|
309
|
+
if (element.native instanceof HTMLElement) {
|
|
310
|
+
const s = element.native.style;
|
|
311
|
+
if (value) {
|
|
312
|
+
const x1 = value.x1 || 1;
|
|
313
|
+
const y1 = value.y1 || 1;
|
|
314
|
+
const x2 = value.x2 || x1;
|
|
315
|
+
const y2 = value.y2 || y1;
|
|
316
|
+
s.gridArea = `${y1} / ${x1} / span ${y2 - y1 + 1} / span ${x2 - x1 + 1}`;
|
|
317
|
+
}
|
|
318
|
+
else
|
|
319
|
+
s.gridArea = "";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
static widthGrowth(element, value) {
|
|
323
|
+
if (element.native instanceof HTMLElement) {
|
|
324
|
+
const s = element.native.style;
|
|
325
|
+
if (value > 0) {
|
|
326
|
+
s.flexGrow = `${value}`;
|
|
327
|
+
s.flexBasis = "0";
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
s.flexGrow = "";
|
|
331
|
+
s.flexBasis = "";
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
static minWidth(element, value) {
|
|
336
|
+
if (element.native instanceof HTMLElement)
|
|
337
|
+
element.native.style.minWidth = `${value}`;
|
|
338
|
+
}
|
|
339
|
+
static applyMaxWidth(element, value) {
|
|
340
|
+
if (element.native instanceof HTMLElement)
|
|
341
|
+
element.native.style.maxWidth = `${value}`;
|
|
342
|
+
}
|
|
343
|
+
static heightGrowth(element, value) {
|
|
344
|
+
const bNode = element.node;
|
|
345
|
+
const driver = bNode.driver;
|
|
346
|
+
if (driver.isPartitionSeparator) {
|
|
347
|
+
if (element.native instanceof HTMLElement) {
|
|
348
|
+
const s = element.native.style;
|
|
349
|
+
if (value > 0)
|
|
350
|
+
s.flexGrow = `${value}`;
|
|
351
|
+
else
|
|
352
|
+
s.flexGrow = "";
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
const hostDriver = bNode.host.driver;
|
|
357
|
+
if (hostDriver.isPartitionSeparator) {
|
|
358
|
+
Apply.elementAlignment(element, Align.ToBounds);
|
|
359
|
+
Apply.heightGrowth(bNode.host.slot.instance.element, value);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
static minHeight(element, value) {
|
|
364
|
+
if (element.native instanceof HTMLElement)
|
|
365
|
+
element.native.style.minHeight = `${value}`;
|
|
366
|
+
}
|
|
367
|
+
static maxHeight(element, value) {
|
|
368
|
+
if (element.native instanceof HTMLElement)
|
|
369
|
+
element.native.style.maxHeight = `${value}`;
|
|
370
|
+
}
|
|
371
|
+
static contentAlignment(element, value) {
|
|
372
|
+
if (element.native instanceof HTMLElement) {
|
|
373
|
+
const s = element.native.style;
|
|
374
|
+
if ((value & Align.Default) === 0) {
|
|
375
|
+
const v = AlignToCss[(value >> 2) & 0b11];
|
|
376
|
+
const h = AlignToCss[value & 0b11];
|
|
377
|
+
const t = TextAlignCss[value & 0b11];
|
|
378
|
+
s.justifyContent = v;
|
|
379
|
+
s.alignItems = h;
|
|
380
|
+
s.textAlign = t;
|
|
381
|
+
}
|
|
382
|
+
else
|
|
383
|
+
s.justifyContent = s.alignContent = s.textAlign = "";
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
static elementAlignment(element, value) {
|
|
387
|
+
if (element.native instanceof HTMLElement) {
|
|
388
|
+
const s = element.native.style;
|
|
389
|
+
if ((value & Align.Default) === 0) {
|
|
390
|
+
const v = AlignToCss[(value >> 2) & 0b11];
|
|
391
|
+
const h = AlignToCss[value & 0b11];
|
|
392
|
+
s.alignSelf = v;
|
|
393
|
+
s.justifySelf = h;
|
|
394
|
+
}
|
|
395
|
+
else
|
|
396
|
+
s.alignSelf = s.justifySelf = "";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
static contentWrapping(element, value) {
|
|
400
|
+
if (element.native instanceof HTMLElement) {
|
|
401
|
+
const s = element.native.style;
|
|
402
|
+
if (value) {
|
|
403
|
+
s.flexFlow = "wrap";
|
|
404
|
+
s.overflow = "";
|
|
405
|
+
s.textOverflow = "";
|
|
406
|
+
s.whiteSpace = "";
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
s.flexFlow = "";
|
|
410
|
+
s.overflow = "hidden";
|
|
411
|
+
s.textOverflow = "ellipsis";
|
|
412
|
+
s.whiteSpace = "nowrap";
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
static overlayVisible(element, value) {
|
|
417
|
+
const e = element.native;
|
|
418
|
+
if (e instanceof HTMLElement) {
|
|
419
|
+
const s = e.style;
|
|
420
|
+
const host = RxTree.findMatchingHost(element.node, n => n.element.native instanceof HTMLElement || n.element.native instanceof SVGElement);
|
|
421
|
+
const nativeHost = host === null || host === void 0 ? void 0 : host.element.native;
|
|
422
|
+
if (value === true) {
|
|
423
|
+
const doc = document.body;
|
|
424
|
+
const rect = nativeHost.getBoundingClientRect();
|
|
425
|
+
if (doc.offsetWidth - rect.left > rect.right)
|
|
426
|
+
s.left = "0", s.right = "";
|
|
427
|
+
else
|
|
428
|
+
s.left = "", s.right = "0";
|
|
429
|
+
if (doc.clientHeight - rect.top > rect.bottom)
|
|
430
|
+
s.top = "100%", s.bottom = "";
|
|
431
|
+
else
|
|
432
|
+
s.top = "", s.bottom = "100%";
|
|
433
|
+
s.display = "";
|
|
434
|
+
s.position = "absolute";
|
|
435
|
+
s.minWidth = "100%";
|
|
436
|
+
s.boxSizing = "border-box";
|
|
437
|
+
nativeHost.style.position = "relative";
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
nativeHost.style.position = "";
|
|
441
|
+
if (value === false)
|
|
442
|
+
s.display = "none";
|
|
443
|
+
else
|
|
444
|
+
s.position = s.display = s.left = s.right = s.top = s.bottom = "";
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
static style(element, secondary, styleName, enabled) {
|
|
449
|
+
const native = element.native;
|
|
450
|
+
enabled !== null && enabled !== void 0 ? enabled : (enabled = true);
|
|
451
|
+
if (secondary)
|
|
452
|
+
native.classList.toggle(styleName, enabled);
|
|
453
|
+
else
|
|
454
|
+
native.className = enabled ? styleName : "";
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
export const Constants = {
|
|
458
|
+
element: "element",
|
|
459
|
+
partition: "partition",
|
|
460
|
+
layouts: ["section", "table", "note", "group", "", ""],
|
|
461
|
+
keyAttrName: "key",
|
|
462
|
+
kindAttrName: "kind",
|
|
463
|
+
};
|
|
464
|
+
const VerstakDriversByLayout = [
|
|
465
|
+
el => {
|
|
466
|
+
const owner = el.node.owner.element;
|
|
467
|
+
const s = el.native.style;
|
|
468
|
+
s.display = "flex";
|
|
469
|
+
s.flexDirection = "column";
|
|
470
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
471
|
+
s.textAlign = "initial";
|
|
472
|
+
s.flexShrink = "1";
|
|
473
|
+
s.minWidth = "0";
|
|
474
|
+
},
|
|
475
|
+
el => {
|
|
476
|
+
const owner = el.node.owner.element;
|
|
477
|
+
const s = el.native.style;
|
|
478
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
479
|
+
s.display = "grid";
|
|
480
|
+
s.flexBasis = "0";
|
|
481
|
+
s.gridAutoRows = "minmax(min-content, 1fr)";
|
|
482
|
+
s.gridAutoColumns = "minmax(min-content, 1fr)";
|
|
483
|
+
s.textAlign = "initial";
|
|
484
|
+
},
|
|
485
|
+
el => {
|
|
486
|
+
const owner = el.node.owner.element;
|
|
487
|
+
const s = el.native.style;
|
|
488
|
+
s.alignSelf = owner.isTable ? "stretch" : "center";
|
|
489
|
+
s.display = "inline-grid";
|
|
490
|
+
s.flexShrink = "1";
|
|
491
|
+
},
|
|
492
|
+
el => {
|
|
493
|
+
const s = el.native.style;
|
|
494
|
+
s.display = "contents";
|
|
495
|
+
},
|
|
496
|
+
el => {
|
|
497
|
+
const owner = el.node.owner.element;
|
|
498
|
+
const s = el.native.style;
|
|
499
|
+
s.display = owner.isTable ? "contents" : "flex";
|
|
500
|
+
s.flexDirection = "row";
|
|
501
|
+
},
|
|
502
|
+
el => {
|
|
503
|
+
},
|
|
504
|
+
el => {
|
|
505
|
+
},
|
|
506
|
+
];
|
|
507
|
+
const AlignToCss = ["stretch", "start", "center", "end"];
|
|
508
|
+
const TextAlignCss = ["justify", "left", "center", "right"];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ElCoords } from "./
|
|
1
|
+
import { ElCoords } from "./El.js";
|
|
2
|
+
export declare function objectHasMember<T>(obj: any, member: string): obj is T;
|
|
3
|
+
export declare function emitLetters(n: number): string;
|
|
2
4
|
export declare function parseElCoords(text: string, result: ElCoords): ElCoords;
|
|
3
5
|
export declare function emitElCoords(value: ElCoords): string;
|
|
4
|
-
export declare function emitLetters(n: number): string;
|
|
5
6
|
export declare function emitCellPosition(x: number, y: number): string;
|
|
6
7
|
export declare function equalElCoords(a: ElCoords, b: ElCoords): boolean;
|
|
7
|
-
export declare function objectHasMember<T>(obj: any, member: string): obj is T;
|
|
8
|
-
export declare function getCallerInfo(prefix: string): string;
|