verstak 0.24.271 → 0.24.273
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/html/El.d.ts +42 -37
- package/build/dist/source/html/El.js +122 -125
- package/build/dist/source/html/ElUtils.d.ts +14 -0
- package/build/dist/source/html/ElUtils.js +38 -9
- package/build/dist/source/html/Elements.d.ts +3 -3
- package/build/dist/source/html/Elements.js +69 -61
- package/build/dist/source/html/Handlers.d.ts +2 -1
- package/build/dist/source/html/Handlers.js +4 -2
- package/build/dist/source/html/HtmlElements.js +1 -1
- package/build/dist/source/html/SplitViewMath.js +20 -16
- package/build/dist/source/html/sensors/BasePointerSensor.d.ts +1 -2
- package/build/dist/source/html/sensors/BasePointerSensor.js +2 -2
- package/build/dist/source/html/sensors/ButtonSensor.d.ts +1 -2
- package/build/dist/source/html/sensors/ButtonSensor.js +2 -2
- package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
- package/build/dist/source/html/sensors/DataForSensor.js +3 -3
- package/build/dist/source/html/sensors/FocusSensor.js +1 -1
- package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +1 -2
- package/build/dist/source/html/sensors/HtmlDragSensor.js +2 -2
- package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +1 -2
- package/build/dist/source/html/sensors/HtmlElementSensor.js +1 -6
- package/build/dist/source/html/sensors/HtmlSensors.js +3 -3
- package/build/dist/source/html/sensors/PointerSensor.d.ts +1 -2
- package/build/dist/source/html/sensors/PointerSensor.js +2 -2
- package/package.json +2 -2
|
@@ -4,6 +4,9 @@ export function objectHasMember(obj, member) {
|
|
|
4
4
|
export function clamp(value, min, max) {
|
|
5
5
|
return Math.min(max, Math.max(min, value));
|
|
6
6
|
}
|
|
7
|
+
export function parseLetters(value) {
|
|
8
|
+
return value.split("").reduce((p, c) => p * 26 + parseInt(c, 36) - 9, 0);
|
|
9
|
+
}
|
|
7
10
|
export function emitLetters(n) {
|
|
8
11
|
if (n < 0)
|
|
9
12
|
throw new Error(`emitLetters: argument (${n}) should not be negative or zero`);
|
|
@@ -15,6 +18,32 @@ export function emitLetters(n) {
|
|
|
15
18
|
}
|
|
16
19
|
return result;
|
|
17
20
|
}
|
|
21
|
+
export function parseSignedLetters(letters) {
|
|
22
|
+
const { sign, value } = parseSign(letters);
|
|
23
|
+
return sign * parseLetters(value);
|
|
24
|
+
}
|
|
25
|
+
export function emitSignedLetters(num) {
|
|
26
|
+
const letters = emitLetters(Math.abs(num) - 1);
|
|
27
|
+
return emitSign(Math.sign(num), letters);
|
|
28
|
+
}
|
|
29
|
+
export function parseSignedNumber(number) {
|
|
30
|
+
const { sign, value } = parseSign(number);
|
|
31
|
+
return sign * Number.parseInt(value);
|
|
32
|
+
}
|
|
33
|
+
export function emitSignedNumber(num) {
|
|
34
|
+
return emitSign(Math.sign(num), Math.abs(num));
|
|
35
|
+
}
|
|
36
|
+
export function parseSign(value) {
|
|
37
|
+
const openBraceIndex = value.indexOf("(");
|
|
38
|
+
const closeBraceIndex = value.indexOf(")");
|
|
39
|
+
const sign = ~openBraceIndex && ~closeBraceIndex ? -1 : 1;
|
|
40
|
+
if (sign < 0)
|
|
41
|
+
value = value.substring(openBraceIndex + 1, closeBraceIndex);
|
|
42
|
+
return { sign, value };
|
|
43
|
+
}
|
|
44
|
+
export function emitSign(sign, num) {
|
|
45
|
+
return sign < 0 ? `(${num})` : `${num}`;
|
|
46
|
+
}
|
|
18
47
|
export function parseElCoords(text, result) {
|
|
19
48
|
let i = 0;
|
|
20
49
|
let value = 0;
|
|
@@ -26,14 +55,14 @@ export function parseElCoords(text, result) {
|
|
|
26
55
|
if (component % 2 === 0)
|
|
27
56
|
value = value * 26 + charCode - 64;
|
|
28
57
|
else
|
|
29
|
-
console.error(`Digit is expected, but letter (
|
|
58
|
+
console.error(`Digit is expected, but letter ("${text[i]}") was read`);
|
|
30
59
|
}
|
|
31
60
|
else if (isLowercaseLetter(charCode)) {
|
|
32
61
|
if (component % 2 === 0) {
|
|
33
62
|
value = value * 26 + charCode - 96;
|
|
34
63
|
}
|
|
35
64
|
else {
|
|
36
|
-
console.error(`Digit is expected, but letter (
|
|
65
|
+
console.error(`Digit is expected, but letter ("${text[i]}") was read`);
|
|
37
66
|
}
|
|
38
67
|
}
|
|
39
68
|
else if (isDigit(charCode)) {
|
|
@@ -87,18 +116,18 @@ export function parseElCoords(text, result) {
|
|
|
87
116
|
}
|
|
88
117
|
else if (charCode === 58) {
|
|
89
118
|
if (sign < 0)
|
|
90
|
-
console.error(`area
|
|
119
|
+
console.error(`area "${text}": e1`);
|
|
91
120
|
if (component === 1)
|
|
92
121
|
result.y1 = value * sign;
|
|
93
122
|
else if (component !== 2)
|
|
94
|
-
console.error(`area
|
|
123
|
+
console.error(`area "${text}": [e2] component = ${component}`);
|
|
95
124
|
component = 2;
|
|
96
125
|
value = 0;
|
|
97
126
|
}
|
|
98
127
|
else if (isWhitespace(charCode)) {
|
|
99
128
|
}
|
|
100
129
|
else {
|
|
101
|
-
console.error(`Unknown symbol
|
|
130
|
+
console.error(`Unknown symbol "${text[i]}" in "${text}"`);
|
|
102
131
|
}
|
|
103
132
|
i++;
|
|
104
133
|
}
|
|
@@ -168,15 +197,15 @@ export function emitCellPosition(x, y) {
|
|
|
168
197
|
export function equalElCoords(a, b) {
|
|
169
198
|
return a.x1 === b.x1 && a.y1 === b.y1 && a.x2 === b.x2 && a.y1 === b.y2;
|
|
170
199
|
}
|
|
171
|
-
function isWhitespace(char) {
|
|
200
|
+
export function isWhitespace(char) {
|
|
172
201
|
return char === 32 || (char >= 9 && char <= 13) || char === 133 || char === 160;
|
|
173
202
|
}
|
|
174
|
-
function isDigit(input, index) {
|
|
203
|
+
export function isDigit(input, index) {
|
|
175
204
|
return 48 <= input && input <= 57;
|
|
176
205
|
}
|
|
177
|
-
function isCapitalLetter(ch) {
|
|
206
|
+
export function isCapitalLetter(ch) {
|
|
178
207
|
return 65 <= ch && ch <= 90;
|
|
179
208
|
}
|
|
180
|
-
function isLowercaseLetter(ch) {
|
|
209
|
+
export function isLowercaseLetter(ch) {
|
|
181
210
|
return 97 <= ch && ch <= 122;
|
|
182
211
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RxNodeDecl, RxNodeDriver, RxNode, Delegate, MergedItem } from "reactronic";
|
|
2
2
|
import { CursorCommandDriver, El, ElArea } from "./El.js";
|
|
3
3
|
import { HtmlDriver } from "./HtmlDriver.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function Panel<M = unknown>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
5
5
|
export declare function Table<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
6
6
|
export declare function row<T = void>(builder?: (element: void) => T, shiftCursorDown?: number): void;
|
|
7
7
|
export declare function Splitter<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
@@ -12,13 +12,13 @@ export declare function Note(content: string, formatted?: boolean, declaration?:
|
|
|
12
12
|
export declare function Group<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
|
|
13
13
|
export declare function Handling<M = unknown>(onChange: Delegate<El<void, M>>): RxNode<El<void, M>>;
|
|
14
14
|
export declare function SyntheticElement<M = unknown>(declaration?: RxNodeDecl<El<void, M>>, preset?: RxNodeDecl<El<void, M>>): RxNode<El<void, M>>;
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class PanelDriver<T extends HTMLElement> extends HtmlDriver<T> {
|
|
16
16
|
update(node: RxNode<El<T>>): void | Promise<void>;
|
|
17
17
|
child(ownerNode: RxNode<El<T, any>>, childDriver: RxNodeDriver<any>, childDeclaration?: RxNodeDecl<any> | undefined, childPreset?: RxNodeDecl<any> | undefined): MergedItem<RxNode> | undefined;
|
|
18
18
|
}
|
|
19
19
|
export declare function isSplitViewPartition(childDriver: RxNodeDriver): boolean;
|
|
20
20
|
export declare const Drivers: {
|
|
21
|
-
|
|
21
|
+
panel: PanelDriver<HTMLElement>;
|
|
22
22
|
table: HtmlDriver<HTMLElement, any>;
|
|
23
23
|
note: HtmlDriver<HTMLElement, any>;
|
|
24
24
|
group: HtmlDriver<HTMLElement, any>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RxNode, Mode, unobs } from "reactronic";
|
|
2
|
-
import { Constants, CursorCommandDriver, ElKind, ElDriver,
|
|
2
|
+
import { Constants, CursorCommandDriver, ElKind, ElDriver, Direction, ElLayoutInfo, InitialElLayoutInfo } from "./El.js";
|
|
3
3
|
import { getPrioritiesForEmptySpaceDistribution, getPrioritiesForSizeChanging, relayout, relayoutUsingSplitter } from "./SplitViewMath.js";
|
|
4
4
|
import { Axis, BodyFontSize, Dimension, toPx } from "./Sizes.js";
|
|
5
5
|
import { HtmlDriver } from "./HtmlDriver.js";
|
|
6
6
|
import { clamp } from "./ElUtils.js";
|
|
7
|
-
export function
|
|
8
|
-
return RxNode.declare(Drivers.
|
|
7
|
+
export function Panel(declaration, preset) {
|
|
8
|
+
return RxNode.declare(Drivers.panel, declaration, preset);
|
|
9
9
|
}
|
|
10
10
|
export function Table(declaration, preset) {
|
|
11
11
|
return RxNode.declare(Drivers.table, declaration, preset);
|
|
@@ -49,7 +49,7 @@ export function declareSplitter(index, splitViewNode) {
|
|
|
49
49
|
if (pointer.draggingOver) {
|
|
50
50
|
pointer.dropAllowed = true;
|
|
51
51
|
const initialSizesPx = pointer.getData();
|
|
52
|
-
const deltaPx = Math.floor(splitViewNode.element.splitView ===
|
|
52
|
+
const deltaPx = Math.floor(splitViewNode.element.splitView === Direction.horizontal
|
|
53
53
|
? pointer.positionX - pointer.startX : pointer.positionY - pointer.startY);
|
|
54
54
|
const clonedSizesPx = [];
|
|
55
55
|
for (const item of initialSizesPx) {
|
|
@@ -108,16 +108,17 @@ export function Handling(onChange) {
|
|
|
108
108
|
export function SyntheticElement(declaration, preset) {
|
|
109
109
|
return RxNode.declare(Drivers.synthetic, declaration, preset);
|
|
110
110
|
}
|
|
111
|
-
export class
|
|
111
|
+
export class PanelDriver extends HtmlDriver {
|
|
112
112
|
update(node) {
|
|
113
113
|
rowBreak();
|
|
114
114
|
const result = super.update(node);
|
|
115
115
|
const el = node.element;
|
|
116
|
-
if (el.
|
|
116
|
+
if (el.sealed !== undefined) {
|
|
117
117
|
Handling(h => {
|
|
118
118
|
var _a, _b;
|
|
119
119
|
const native = el.native;
|
|
120
120
|
const resize = native.sensors.resize;
|
|
121
|
+
const isHorizontal = el.sealed === Direction.horizontal;
|
|
121
122
|
for (const x of resize.resizedElements) {
|
|
122
123
|
if (el.layoutInfo === undefined)
|
|
123
124
|
el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
@@ -131,7 +132,6 @@ export class SectionDriver extends HtmlDriver {
|
|
|
131
132
|
el.layoutInfo.contentSizeYpx = containerSizeYpx;
|
|
132
133
|
el.layoutInfo.borderSizeXpx = x.borderBoxSize[0].inlineSize;
|
|
133
134
|
el.layoutInfo.borderSizeYpx = x.borderBoxSize[0].blockSize;
|
|
134
|
-
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
135
135
|
const wrapper = (_a = node.children.firstMergedItem()) === null || _a === void 0 ? void 0 : _a.instance;
|
|
136
136
|
if (wrapper !== undefined) {
|
|
137
137
|
const wrapperEl = wrapper.element;
|
|
@@ -143,7 +143,6 @@ export class SectionDriver extends HtmlDriver {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
if (h.node.stamp === 1) {
|
|
146
|
-
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
147
146
|
const wrapper = (_b = node.children.firstMergedItem()) === null || _b === void 0 ? void 0 : _b.instance;
|
|
148
147
|
if (wrapper !== undefined) {
|
|
149
148
|
const wrapperEl = wrapper.element;
|
|
@@ -154,57 +153,63 @@ export class SectionDriver extends HtmlDriver {
|
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
155
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
partEl.
|
|
185
|
-
|
|
186
|
-
let preferredPx = 0;
|
|
187
|
-
if (!preferredUsed) {
|
|
188
|
-
preferredPx = size.preferred ? toPx(Dimension.parse(size.preferred), options) : 0;
|
|
189
|
-
if (preferredPx > 0) {
|
|
190
|
-
partEl.layoutInfo.effectiveSizePx = preferredPx;
|
|
191
|
-
preferred.push(i);
|
|
192
|
-
}
|
|
156
|
+
}
|
|
157
|
+
if (el.splitView !== undefined) {
|
|
158
|
+
SyntheticElement({
|
|
159
|
+
mode: Mode.independentUpdate,
|
|
160
|
+
triggers: { stamp: el.node.stamp },
|
|
161
|
+
onChange: () => {
|
|
162
|
+
const native = el.native;
|
|
163
|
+
const isHorizontal = el.splitView === Direction.horizontal;
|
|
164
|
+
if (el.layoutInfo === undefined)
|
|
165
|
+
el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
166
|
+
if (el.layoutInfo.isConstrained) {
|
|
167
|
+
const surroundingXpx = el.layoutInfo.borderSizeXpx - el.layoutInfo.contentSizeXpx;
|
|
168
|
+
const surroundingYpx = el.layoutInfo.borderSizeYpx - el.layoutInfo.contentSizeYpx;
|
|
169
|
+
let i = 0;
|
|
170
|
+
const preferred = [];
|
|
171
|
+
const sizesPx = [];
|
|
172
|
+
for (const child of node.children.items()) {
|
|
173
|
+
const partEl = child.instance.element;
|
|
174
|
+
if (isSplitViewPartition(child.instance.driver) && partEl !== undefined) {
|
|
175
|
+
const size = isHorizontal ? partEl.width : partEl.height;
|
|
176
|
+
const options = {
|
|
177
|
+
axis: isHorizontal ? Axis.X : Axis.Y, lineSizePx: BodyFontSize, fontSizePx: BodyFontSize,
|
|
178
|
+
containerSizeXpx: native.scrollWidth - surroundingXpx, containerSizeYpx: native.scrollHeight - surroundingYpx,
|
|
179
|
+
};
|
|
180
|
+
const minPx = size.min ? toPx(Dimension.parse(size.min), options) : 0;
|
|
181
|
+
let maxPx = size.max ? toPx(Dimension.parse(size.max), options) : Number.POSITIVE_INFINITY;
|
|
182
|
+
maxPx = Math.max(minPx, maxPx);
|
|
183
|
+
if (partEl.layoutInfo === undefined)
|
|
184
|
+
partEl.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
193
185
|
if (isHorizontal)
|
|
194
|
-
partEl.
|
|
186
|
+
partEl.widthPx = { minPx, maxPx };
|
|
195
187
|
else
|
|
196
|
-
partEl.
|
|
188
|
+
partEl.heightPx = { minPx, maxPx };
|
|
189
|
+
const preferredUsed = isHorizontal ? partEl.preferredWidthUsed : partEl.preferredHeightUsed;
|
|
190
|
+
let preferredPx = 0;
|
|
191
|
+
if (!preferredUsed) {
|
|
192
|
+
preferredPx = size.preferred ? toPx(Dimension.parse(size.preferred), options) : 0;
|
|
193
|
+
if (preferredPx > 0) {
|
|
194
|
+
partEl.layoutInfo.effectiveSizePx = preferredPx;
|
|
195
|
+
preferred.push(i);
|
|
196
|
+
}
|
|
197
|
+
if (isHorizontal)
|
|
198
|
+
partEl.preferredWidthUsed = true;
|
|
199
|
+
else
|
|
200
|
+
partEl.preferredHeightUsed = true;
|
|
201
|
+
}
|
|
202
|
+
const sizePx = partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx);
|
|
203
|
+
sizesPx.push({ node: child.instance, sizePx });
|
|
204
|
+
i++;
|
|
197
205
|
}
|
|
198
|
-
const sizePx = partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx);
|
|
199
|
-
sizesPx.push({ node: child.instance, sizePx });
|
|
200
|
-
i++;
|
|
201
206
|
}
|
|
207
|
+
const priorities = preferred.length > 0
|
|
208
|
+
? getPrioritiesForSizeChanging(isHorizontal, node.children, preferred)
|
|
209
|
+
: getPrioritiesForEmptySpaceDistribution(isHorizontal, node.children);
|
|
210
|
+
unobs(() => relayout(node, priorities.resizable, priorities.manuallyResizable, sizesPx));
|
|
202
211
|
}
|
|
203
|
-
|
|
204
|
-
? getPrioritiesForSizeChanging(isHorizontal, node.children, preferred)
|
|
205
|
-
: getPrioritiesForEmptySpaceDistribution(isHorizontal, node.children);
|
|
206
|
-
unobs(() => relayout(node, priorities.resizable, priorities.manuallyResizable, sizesPx));
|
|
207
|
-
}
|
|
212
|
+
},
|
|
208
213
|
});
|
|
209
214
|
}
|
|
210
215
|
return result;
|
|
@@ -220,9 +225,12 @@ export class SectionDriver extends HtmlDriver {
|
|
|
220
225
|
if (isSplitViewPartition(child.instance.driver))
|
|
221
226
|
partCount++;
|
|
222
227
|
}
|
|
223
|
-
const isHorizontal = el.splitView ===
|
|
228
|
+
const isHorizontal = el.splitView === Direction.horizontal;
|
|
224
229
|
if (childDeclaration !== undefined) {
|
|
225
|
-
|
|
230
|
+
if (childDeclaration.triggers === undefined)
|
|
231
|
+
childDeclaration.triggers = {};
|
|
232
|
+
Object.defineProperty(childDeclaration.triggers, "index", { value: partCount });
|
|
233
|
+
overrideMethod(childDeclaration, "onChange", el => {
|
|
226
234
|
if (isHorizontal)
|
|
227
235
|
el.style.gridColumn = `${partCount + 1}`;
|
|
228
236
|
else
|
|
@@ -246,14 +254,14 @@ export class SectionDriver extends HtmlDriver {
|
|
|
246
254
|
export function isSplitViewPartition(childDriver) {
|
|
247
255
|
return !childDriver.isPartition && childDriver !== Drivers.splitter && childDriver !== Drivers.synthetic;
|
|
248
256
|
}
|
|
249
|
-
function
|
|
250
|
-
const
|
|
251
|
-
declaration
|
|
252
|
-
? (el, base) => {
|
|
257
|
+
function overrideMethod(declaration, method, func) {
|
|
258
|
+
const baseOnChange = declaration[method];
|
|
259
|
+
declaration[method] = baseOnChange !== undefined
|
|
260
|
+
? (el, base) => { baseOnChange(el, base); func(el); }
|
|
253
261
|
: (el, base) => { base(); func(el); };
|
|
254
262
|
}
|
|
255
263
|
export const Drivers = {
|
|
256
|
-
|
|
264
|
+
panel: new PanelDriver(Constants.element, false, el => el.kind = ElKind.panel),
|
|
257
265
|
table: new HtmlDriver(Constants.element, false, el => el.kind = ElKind.table),
|
|
258
266
|
note: new HtmlDriver(Constants.element, false, el => el.kind = ElKind.note),
|
|
259
267
|
group: new HtmlDriver(Constants.group, false, el => el.kind = ElKind.group),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ToggleRef } from "reactronic";
|
|
2
2
|
import { FocusModel } from "./sensors/FocusSensor.js";
|
|
3
3
|
import { ResizedElement } from "./sensors/ResizeSensor.js";
|
|
4
|
-
|
|
4
|
+
import { PointerSensor } from "./sensors/PointerSensor.js";
|
|
5
|
+
export declare function OnClick(target: HTMLElement, action: ((pointer: PointerSensor) => void) | ToggleRef | undefined, key?: string): void;
|
|
5
6
|
export declare function OnResize(target: HTMLElement, action: ((element: ResizedElement) => void) | undefined, key?: string): void;
|
|
6
7
|
export declare function OnFocus(target: HTMLElement, model: FocusModel, switchEditMode?: ((model: FocusModel) => void) | undefined, key?: string): void;
|
|
@@ -8,9 +8,9 @@ export function OnClick(target, action, key) {
|
|
|
8
8
|
triggers: { target },
|
|
9
9
|
onChange: el => {
|
|
10
10
|
const pointer = target.sensors.pointer;
|
|
11
|
-
if (pointer.clicked) {
|
|
11
|
+
if (target.dataForSensor.click !== undefined && pointer.clicked === target.dataForSensor.click || target.dataForSensor.click === undefined && pointer.clicked) {
|
|
12
12
|
if (action instanceof Function) {
|
|
13
|
-
unobs(() => action());
|
|
13
|
+
unobs(() => action(pointer));
|
|
14
14
|
}
|
|
15
15
|
else if (action instanceof ToggleRef) {
|
|
16
16
|
unobs(() => action.toggle());
|
|
@@ -44,6 +44,8 @@ export function OnFocus(target, model, switchEditMode = undefined, key) {
|
|
|
44
44
|
el.node.configureReactronic({ throttling: 0 });
|
|
45
45
|
},
|
|
46
46
|
onChange: el => {
|
|
47
|
+
if (switchEditMode === undefined && !(target instanceof HTMLInputElement || target.hasAttribute("tabindex")))
|
|
48
|
+
console.warn(`"${key !== null && key !== void 0 ? key : "noname"}" element must have "tabindex" attribute set in order to be focusable`);
|
|
47
49
|
if (switchEditMode !== undefined) {
|
|
48
50
|
switchEditMode(model);
|
|
49
51
|
}
|
|
@@ -2,7 +2,7 @@ import { RxNode } from "reactronic";
|
|
|
2
2
|
import { ElKind } from "./El.js";
|
|
3
3
|
import { StaticDriver, HtmlDriver, SvgDriver } from "./HtmlDriver.js";
|
|
4
4
|
export function Page(declaration, preset) {
|
|
5
|
-
const driver = new StaticDriver(global.document.body, "Page", false, el => el.kind = ElKind.
|
|
5
|
+
const driver = new StaticDriver(global.document.body, "Page", false, el => el.kind = ElKind.panel);
|
|
6
6
|
return RxNode.declare(driver, declaration, preset);
|
|
7
7
|
}
|
|
8
8
|
export function A(declaration, preset) { return RxNode.declare(HtmlTags.a, declaration, preset); }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElLayoutInfo, InitialElLayoutInfo,
|
|
1
|
+
import { ElLayoutInfo, InitialElLayoutInfo, Direction } from "./El.js";
|
|
2
2
|
import { Drivers, isSplitViewPartition } from "./Elements.js";
|
|
3
3
|
import { clamp } from "./ElUtils.js";
|
|
4
4
|
const DEBUG = false;
|
|
@@ -17,7 +17,7 @@ export function relayoutUsingSplitter(splitViewNode, deltaPx, index, initialSize
|
|
|
17
17
|
if (priorities === undefined) {
|
|
18
18
|
priorities = getPrioritiesForSplitter(index + 1, initialSizesPx.length);
|
|
19
19
|
}
|
|
20
|
-
const containerSizePx = splitViewNode.element.splitView ===
|
|
20
|
+
const containerSizePx = splitViewNode.element.splitView === Direction.horizontal
|
|
21
21
|
? (_b = (_a = splitViewNode.element.layoutInfo) === null || _a === void 0 ? void 0 : _a.contentSizeXpx) !== null && _b !== void 0 ? _b : 0
|
|
22
22
|
: (_d = (_c = splitViewNode.element.layoutInfo) === null || _c === void 0 ? void 0 : _c.contentSizeYpx) !== null && _d !== void 0 ? _d : 0;
|
|
23
23
|
DEBUG && console.log(`(splitter) delta = ${deltaPx}, container = ${containerSizePx}, size = ${initialSizesPx.reduce((p, c) => p + c.sizePx, 0)}, index = ${index}`);
|
|
@@ -26,7 +26,7 @@ export function relayoutUsingSplitter(splitViewNode, deltaPx, index, initialSize
|
|
|
26
26
|
}
|
|
27
27
|
export function relayout(splitViewNode, priorities, manuallyResizablePriorities, sizesPx) {
|
|
28
28
|
var _a, _b, _c, _d;
|
|
29
|
-
const containerSizePx = splitViewNode.element.splitView ===
|
|
29
|
+
const containerSizePx = splitViewNode.element.splitView === Direction.horizontal
|
|
30
30
|
? (_b = (_a = splitViewNode.element.layoutInfo) === null || _a === void 0 ? void 0 : _a.contentSizeXpx) !== null && _b !== void 0 ? _b : 0
|
|
31
31
|
: (_d = (_c = splitViewNode.element.layoutInfo) === null || _c === void 0 ? void 0 : _c.contentSizeYpx) !== null && _d !== void 0 ? _d : 0;
|
|
32
32
|
const totalSizePx = sizesPx.reduce((p, c) => p + c.sizePx, 0);
|
|
@@ -42,7 +42,7 @@ export function relayout(splitViewNode, priorities, manuallyResizablePriorities,
|
|
|
42
42
|
layout(splitViewNode);
|
|
43
43
|
}
|
|
44
44
|
export function resizeUsingDelta(splitViewNode, deltaPx, index, priorities, sizesPx, force = false) {
|
|
45
|
-
const isHorizontal = splitViewNode.element.splitView ===
|
|
45
|
+
const isHorizontal = splitViewNode.element.splitView === Direction.horizontal;
|
|
46
46
|
let beforeDeltaPx = 0;
|
|
47
47
|
if (sizesPx.length > 0 && deltaPx !== 0) {
|
|
48
48
|
let minBeforeDeltaPx = 0;
|
|
@@ -86,7 +86,7 @@ export function resizeUsingDelta(splitViewNode, deltaPx, index, priorities, size
|
|
|
86
86
|
}
|
|
87
87
|
export function layout(splitViewNode) {
|
|
88
88
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
89
|
-
const isHorizontal = splitViewNode.element.splitView ===
|
|
89
|
+
const isHorizontal = splitViewNode.element.splitView === Direction.horizontal;
|
|
90
90
|
let posPx = 0;
|
|
91
91
|
let shrinkBefore = false;
|
|
92
92
|
let growBefore = false;
|
|
@@ -181,9 +181,8 @@ export function getPrioritiesForSizeChanging(isHorizontal, children, indexes) {
|
|
|
181
181
|
const manuallyResizable = [];
|
|
182
182
|
const items = Array.from(children.items()).filter(x => isSplitViewPartition(x.instance.driver));
|
|
183
183
|
for (let i = items.length - 1; i >= 0; i--) {
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
const strength = (_a = (isHorizontal ? el.stretchingStrengthX : el.stretchingStrengthY)) !== null && _a !== void 0 ? _a : 1;
|
|
184
|
+
const el = items[i].instance.element;
|
|
185
|
+
const strength = (_a = (isHorizontal ? el.stretchingStrengthH : el.stretchingStrengthV)) !== null && _a !== void 0 ? _a : 1;
|
|
187
186
|
if (!indexes.includes(i)) {
|
|
188
187
|
if (strength > 0)
|
|
189
188
|
resizable.push(1 << i);
|
|
@@ -191,15 +190,20 @@ export function getPrioritiesForSizeChanging(isHorizontal, children, indexes) {
|
|
|
191
190
|
manuallyResizable.push(1 << i);
|
|
192
191
|
}
|
|
193
192
|
}
|
|
193
|
+
let r = 0;
|
|
194
|
+
let mr = 0;
|
|
194
195
|
for (const i of indexes) {
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const strength = (_b = (isHorizontal ? el.stretchingStrengthX : el.stretchingStrengthY)) !== null && _b !== void 0 ? _b : 1;
|
|
196
|
+
const el = items[i].instance.element;
|
|
197
|
+
const strength = (_b = (isHorizontal ? el.stretchingStrengthH : el.stretchingStrengthV)) !== null && _b !== void 0 ? _b : 1;
|
|
198
198
|
if (strength > 0)
|
|
199
|
-
|
|
199
|
+
r |= 1 << i;
|
|
200
200
|
else
|
|
201
|
-
|
|
201
|
+
mr |= 1 << i;
|
|
202
202
|
}
|
|
203
|
+
if (r > 0)
|
|
204
|
+
resizable.push(r);
|
|
205
|
+
if (mr > 0)
|
|
206
|
+
manuallyResizable.push(mr);
|
|
203
207
|
return { resizable, manuallyResizable };
|
|
204
208
|
}
|
|
205
209
|
export function getPrioritiesForEmptySpaceDistribution(isHorizontal, children) {
|
|
@@ -210,7 +214,7 @@ export function getPrioritiesForEmptySpaceDistribution(isHorizontal, children) {
|
|
|
210
214
|
for (const child of children.items()) {
|
|
211
215
|
if (isSplitViewPartition(child.instance.driver)) {
|
|
212
216
|
const el = child.instance.element;
|
|
213
|
-
const strength = (_a = (isHorizontal ? el.
|
|
217
|
+
const strength = (_a = (isHorizontal ? el.stretchingStrengthH : el.stretchingStrengthV)) !== null && _a !== void 0 ? _a : 1;
|
|
214
218
|
if (strength > 0)
|
|
215
219
|
r |= 1 << i;
|
|
216
220
|
else
|
|
@@ -224,7 +228,7 @@ function getFractionCount(isHorizontal, children, vector, index, force = false)
|
|
|
224
228
|
var _a;
|
|
225
229
|
let result = 0;
|
|
226
230
|
for (const i of indexes(vector, index)) {
|
|
227
|
-
const growth = (_a = (isHorizontal ? children[i].element.
|
|
231
|
+
const growth = (_a = (isHorizontal ? children[i].element.stretchingStrengthH : children[i].element.stretchingStrengthV)) !== null && _a !== void 0 ? _a : 1;
|
|
228
232
|
result += growth > 0 ? growth : (force ? 1 : 0);
|
|
229
233
|
}
|
|
230
234
|
return result;
|
|
@@ -269,7 +273,7 @@ function distribute(sign, deltaPx, index, priorities, sizesPx, isHorizontal, for
|
|
|
269
273
|
for (const i of indexes(vector, sign * index)) {
|
|
270
274
|
const child = sizesPx[i].node;
|
|
271
275
|
const initialSizePx = sizesPx[i].sizePx;
|
|
272
|
-
const strength = isHorizontal ? ((_a = child.element.
|
|
276
|
+
const strength = isHorizontal ? ((_a = child.element.stretchingStrengthH) !== null && _a !== void 0 ? _a : 1) : ((_b = child.element.stretchingStrengthV) !== null && _b !== void 0 ? _b : 1);
|
|
273
277
|
const growth = strength > 0 ? strength : (force ? 1 : 0);
|
|
274
278
|
const newSizePx = initialSizePx + sign * (growth * fractionSizePx);
|
|
275
279
|
const size = isHorizontal ? sizesPx[i].node.element.widthPx : sizesPx[i].node.element.heightPx;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FocusSensor } from "./FocusSensor.js";
|
|
2
1
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
3
2
|
import { KeyboardModifiers } from "./KeyboardSensor.js";
|
|
4
3
|
import { WindowSensor } from "./WindowSensor.js";
|
|
@@ -12,7 +11,7 @@ export declare class BasePointerSensor extends HtmlElementSensor {
|
|
|
12
11
|
positionX: number;
|
|
13
12
|
positionY: number;
|
|
14
13
|
modifiers: KeyboardModifiers;
|
|
15
|
-
constructor(element: HTMLElement | SVGElement,
|
|
14
|
+
constructor(element: HTMLElement | SVGElement, windowSensor?: WindowSensor);
|
|
16
15
|
}
|
|
17
16
|
export declare function extractPointerButton(e: MouseEvent): PointerButton;
|
|
18
17
|
export declare function isPointerButtonDown(button: PointerButton, buttonsMask: number): boolean;
|
|
@@ -8,8 +8,8 @@ export var PointerButton;
|
|
|
8
8
|
PointerButton[PointerButton["middle"] = 4] = "middle";
|
|
9
9
|
})(PointerButton || (PointerButton = {}));
|
|
10
10
|
export class BasePointerSensor extends HtmlElementSensor {
|
|
11
|
-
constructor(element,
|
|
12
|
-
super(element,
|
|
11
|
+
constructor(element, windowSensor) {
|
|
12
|
+
super(element, windowSensor);
|
|
13
13
|
this.positionX = Infinity;
|
|
14
14
|
this.positionY = Infinity;
|
|
15
15
|
this.modifiers = KeyboardModifiers.none;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PointerButton, BasePointerSensor } from "./BasePointerSensor.js";
|
|
2
|
-
import { FocusSensor } from "./FocusSensor.js";
|
|
3
2
|
import { WindowSensor } from "./WindowSensor.js";
|
|
4
3
|
export declare enum ButtonState {
|
|
5
4
|
pressed = 0,
|
|
@@ -15,7 +14,7 @@ export declare class ButtonSensor extends BasePointerSensor {
|
|
|
15
14
|
selectedX: number;
|
|
16
15
|
selectedY: number;
|
|
17
16
|
selected: boolean;
|
|
18
|
-
constructor(element: HTMLElement | SVGElement,
|
|
17
|
+
constructor(element: HTMLElement | SVGElement, windowSensor: WindowSensor);
|
|
19
18
|
listen(enabled?: boolean): void;
|
|
20
19
|
protected onPointerDown(e: PointerEvent): void;
|
|
21
20
|
protected onPointerMove(e: PointerEvent): void;
|
|
@@ -19,8 +19,8 @@ export var ButtonState;
|
|
|
19
19
|
ButtonState[ButtonState["released"] = 3] = "released";
|
|
20
20
|
})(ButtonState || (ButtonState = {}));
|
|
21
21
|
export class ButtonSensor extends BasePointerSensor {
|
|
22
|
-
constructor(element,
|
|
23
|
-
super(element,
|
|
22
|
+
constructor(element, windowSensor) {
|
|
23
|
+
super(element, windowSensor);
|
|
24
24
|
this.state = ButtonState.released;
|
|
25
25
|
this.pointerButton = PointerButton.none;
|
|
26
26
|
this.originData = undefined;
|
|
@@ -43,8 +43,8 @@ export function grabElementDataList(targetPath, sym, payloadKey, existing, ignor
|
|
|
43
43
|
if (candidateData !== undefined) {
|
|
44
44
|
if (!ignoreWindow) {
|
|
45
45
|
if (window === undefined)
|
|
46
|
-
window = candidateData
|
|
47
|
-
else if (window !== candidateData
|
|
46
|
+
window = candidateData.window;
|
|
47
|
+
else if (window !== candidateData.window)
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
payload = candidateData[payloadKey];
|
|
@@ -62,7 +62,7 @@ export function grabElementDataList(targetPath, sym, payloadKey, existing, ignor
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
if (activeData === undefined && predicate(candidate)) {
|
|
65
|
+
if (payloadKey === "focus" && activeData === undefined && (predicate(candidate) || (candidateData === null || candidateData === void 0 ? void 0 : candidateData.catchChildrenFocus))) {
|
|
66
66
|
activeData = payload;
|
|
67
67
|
}
|
|
68
68
|
i++;
|
|
@@ -13,7 +13,7 @@ import { grabElementDataList, SymDataForSensor } from "./DataForSensor.js";
|
|
|
13
13
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
14
14
|
export class FocusSensor extends HtmlElementSensor {
|
|
15
15
|
constructor(element, windowSensor) {
|
|
16
|
-
super(element,
|
|
16
|
+
super(element, windowSensor);
|
|
17
17
|
this.activeData = undefined;
|
|
18
18
|
this.oldActiveData = undefined;
|
|
19
19
|
this.contextElementDataList = [];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FocusSensor } from "./FocusSensor.js";
|
|
2
1
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
3
2
|
import { KeyboardModifiers } from "./KeyboardSensor.js";
|
|
4
3
|
import { WindowSensor } from "./WindowSensor.js";
|
|
@@ -33,7 +32,7 @@ export declare class HtmlDragSensor extends HtmlElementSensor {
|
|
|
33
32
|
immediatePositionX: number;
|
|
34
33
|
immediatePositionY: number;
|
|
35
34
|
immediateModifiers: KeyboardModifiers;
|
|
36
|
-
constructor(element: HTMLElement | SVGElement,
|
|
35
|
+
constructor(element: HTMLElement | SVGElement, windowSensor: WindowSensor);
|
|
37
36
|
getData(format: string): unknown;
|
|
38
37
|
setData(format: string, value: unknown): void;
|
|
39
38
|
clearData(format?: string): void;
|
|
@@ -12,8 +12,8 @@ import { findTargetElementData, SymDataForSensor } from "./DataForSensor.js";
|
|
|
12
12
|
import { HtmlElementSensor } from "./HtmlElementSensor.js";
|
|
13
13
|
import { extractModifierKeys, KeyboardModifiers } from "./KeyboardSensor.js";
|
|
14
14
|
export class HtmlDragSensor extends HtmlElementSensor {
|
|
15
|
-
constructor(element,
|
|
16
|
-
super(element,
|
|
15
|
+
constructor(element, windowSensor) {
|
|
16
|
+
super(element, windowSensor);
|
|
17
17
|
this.draggable = undefined;
|
|
18
18
|
this.dragSource = undefined;
|
|
19
19
|
this.dragTarget = undefined;
|
|
@@ -3,11 +3,10 @@ import { Sensor } from "./Sensor.js";
|
|
|
3
3
|
import { WindowSensor } from "./WindowSensor.js";
|
|
4
4
|
export declare class HtmlElementSensor extends Sensor {
|
|
5
5
|
readonly sourceElement: HTMLElement | SVGElement;
|
|
6
|
-
readonly focusSensor?: any;
|
|
7
6
|
readonly windowSensor?: WindowSensor;
|
|
8
7
|
preventDefault: boolean;
|
|
9
8
|
stopPropagation: boolean;
|
|
10
|
-
constructor(sourceElement: HTMLElement | SVGElement,
|
|
9
|
+
constructor(sourceElement: HTMLElement | SVGElement, windowSensor?: WindowSensor);
|
|
11
10
|
protected getDefaultSensorData(): DataForSensor;
|
|
12
11
|
protected setPreventDefaultAndStopPropagation(e: Event): void;
|
|
13
12
|
}
|