verstak 0.24.270 → 0.24.271
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 +46 -20
- package/build/dist/source/html/El.js +170 -87
- package/build/dist/source/html/Elements.js +113 -65
- package/build/dist/source/html/Handlers.d.ts +1 -1
- package/build/dist/source/html/SplitViewMath.d.ts +15 -6
- package/build/dist/source/html/SplitViewMath.js +190 -123
- 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/KeyboardSensor.d.ts +1 -0
- package/build/dist/source/html/sensors/KeyboardSensor.js +5 -0
- package/package.json +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RxNode, Mode } from "reactronic";
|
|
1
|
+
import { RxNode, Mode, unobs } from "reactronic";
|
|
2
2
|
import { Constants, CursorCommandDriver, ElKind, ElDriver, SplitView, ElLayoutInfo, InitialElLayoutInfo } from "./El.js";
|
|
3
|
-
import { getPrioritiesForEmptySpaceDistribution, relayout, relayoutUsingSplitter } from "./SplitViewMath.js";
|
|
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
|
-
import { OnResize } from "./Handlers.js";
|
|
7
6
|
import { clamp } from "./ElUtils.js";
|
|
8
7
|
export function Section(declaration, preset) {
|
|
9
8
|
return RxNode.declare(Drivers.section, declaration, preset);
|
|
@@ -35,6 +34,7 @@ export function declareSplitter(index, splitViewNode) {
|
|
|
35
34
|
return (Splitter({
|
|
36
35
|
key,
|
|
37
36
|
mode: Mode.independentUpdate,
|
|
37
|
+
onCreate: el => el.native.className = `splitter ${key}`,
|
|
38
38
|
onChange: b => {
|
|
39
39
|
const e = b.native;
|
|
40
40
|
const model = b.model;
|
|
@@ -55,7 +55,7 @@ export function declareSplitter(index, splitViewNode) {
|
|
|
55
55
|
for (const item of initialSizesPx) {
|
|
56
56
|
clonedSizesPx.push({ node: item.node, sizePx: item.sizePx });
|
|
57
57
|
}
|
|
58
|
-
relayoutUsingSplitter(splitViewNode, deltaPx, index, clonedSizesPx);
|
|
58
|
+
unobs(() => relayoutUsingSplitter(splitViewNode, deltaPx, index, clonedSizesPx));
|
|
59
59
|
if (pointer.dropped) {
|
|
60
60
|
(_a = model === null || model === void 0 ? void 0 : model.droppedAction) === null || _a === void 0 ? void 0 : _a.call(model, pointer);
|
|
61
61
|
}
|
|
@@ -70,7 +70,6 @@ export function declareSplitter(index, splitViewNode) {
|
|
|
70
70
|
initialSizesPx.push({ node: child, sizePx });
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
console.log("initial", initialSizesPx.map(x => x.sizePx).join(", "));
|
|
74
73
|
pointer.setData(initialSizesPx);
|
|
75
74
|
}
|
|
76
75
|
if (pointer.dragFinished) {
|
|
@@ -115,54 +114,97 @@ export class SectionDriver extends HtmlDriver {
|
|
|
115
114
|
const result = super.update(node);
|
|
116
115
|
const el = node.element;
|
|
117
116
|
if (el.splitView !== undefined) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
wrapperEl
|
|
117
|
+
Handling(h => {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
const native = el.native;
|
|
120
|
+
const resize = native.sensors.resize;
|
|
121
|
+
for (const x of resize.resizedElements) {
|
|
122
|
+
if (el.layoutInfo === undefined)
|
|
123
|
+
el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
124
|
+
const rect = x.contentRect;
|
|
125
|
+
const contentBoxPx = x.contentBoxSize[0];
|
|
126
|
+
const containerSizeXpx = contentBoxPx.inlineSize;
|
|
127
|
+
const containerSizeYpx = contentBoxPx.blockSize;
|
|
128
|
+
el.layoutInfo.offsetXpx = rect.left;
|
|
129
|
+
el.layoutInfo.offsetYpx = rect.top;
|
|
130
|
+
el.layoutInfo.contentSizeXpx = containerSizeXpx;
|
|
131
|
+
el.layoutInfo.contentSizeYpx = containerSizeYpx;
|
|
132
|
+
el.layoutInfo.borderSizeXpx = x.borderBoxSize[0].inlineSize;
|
|
133
|
+
el.layoutInfo.borderSizeYpx = x.borderBoxSize[0].blockSize;
|
|
134
|
+
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
135
|
+
const wrapper = (_a = node.children.firstMergedItem()) === null || _a === void 0 ? void 0 : _a.instance;
|
|
136
|
+
if (wrapper !== undefined) {
|
|
137
|
+
const wrapperEl = wrapper.element;
|
|
138
|
+
el.layoutInfo.isConstrained = true;
|
|
139
|
+
if (isHorizontal)
|
|
140
|
+
wrapperEl.style.width = wrapperEl.style.maxWidth = `${containerSizeXpx}px`;
|
|
141
|
+
else
|
|
142
|
+
wrapperEl.style.height = wrapperEl.style.maxHeight = `${containerSizeYpx}px`;
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (isSplitViewPartition(child.instance.driver) && partEl !== undefined) {
|
|
147
|
-
const size = isHorizontal ? partEl.width : partEl.height;
|
|
148
|
-
const options = {
|
|
149
|
-
axis: isHorizontal ? Axis.X : Axis.Y, lineSizePx: Dimension.lineSizePx, fontSizePx: BodyFontSize,
|
|
150
|
-
containerSizeXpx: native.scrollWidth - surroundingXpx, containerSizeYpx: native.scrollHeight - surroundingYpx,
|
|
151
|
-
};
|
|
152
|
-
const minPx = size.min ? toPx(Dimension.parse(size.min), options) : 0;
|
|
153
|
-
let maxPx = size.max ? toPx(Dimension.parse(size.max), options) : Number.POSITIVE_INFINITY;
|
|
154
|
-
maxPx = Math.max(minPx, maxPx);
|
|
155
|
-
if (partEl.layoutInfo === undefined)
|
|
156
|
-
partEl.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
145
|
+
if (h.node.stamp === 1) {
|
|
146
|
+
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
147
|
+
const wrapper = (_b = node.children.firstMergedItem()) === null || _b === void 0 ? void 0 : _b.instance;
|
|
148
|
+
if (wrapper !== undefined) {
|
|
149
|
+
const wrapperEl = wrapper.element;
|
|
157
150
|
if (isHorizontal)
|
|
158
|
-
|
|
151
|
+
wrapperEl.style.width = wrapperEl.style.maxWidth = "0px";
|
|
159
152
|
else
|
|
160
|
-
|
|
161
|
-
const sizePx = partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx);
|
|
162
|
-
sizesPx.push({ node: child.instance, sizePx });
|
|
153
|
+
wrapperEl.style.height = wrapperEl.style.maxHeight = "0px";
|
|
163
154
|
}
|
|
164
155
|
}
|
|
165
|
-
|
|
156
|
+
});
|
|
157
|
+
Handling(() => {
|
|
158
|
+
const native = el.native;
|
|
159
|
+
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
160
|
+
if (el.layoutInfo === undefined)
|
|
161
|
+
el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
162
|
+
if (el.layoutInfo.isConstrained) {
|
|
163
|
+
const surroundingXpx = el.layoutInfo.borderSizeXpx - el.layoutInfo.contentSizeXpx;
|
|
164
|
+
const surroundingYpx = el.layoutInfo.borderSizeYpx - el.layoutInfo.contentSizeYpx;
|
|
165
|
+
let i = 0;
|
|
166
|
+
const preferred = [];
|
|
167
|
+
const sizesPx = [];
|
|
168
|
+
for (const child of node.children.items()) {
|
|
169
|
+
const partEl = child.instance.element;
|
|
170
|
+
if (isSplitViewPartition(child.instance.driver) && partEl !== undefined) {
|
|
171
|
+
const size = isHorizontal ? partEl.width : partEl.height;
|
|
172
|
+
const options = {
|
|
173
|
+
axis: isHorizontal ? Axis.X : Axis.Y, lineSizePx: Dimension.lineSizePx, fontSizePx: BodyFontSize,
|
|
174
|
+
containerSizeXpx: native.scrollWidth - surroundingXpx, containerSizeYpx: native.scrollHeight - surroundingYpx,
|
|
175
|
+
};
|
|
176
|
+
const minPx = size.min ? toPx(Dimension.parse(size.min), options) : 0;
|
|
177
|
+
let maxPx = size.max ? toPx(Dimension.parse(size.max), options) : Number.POSITIVE_INFINITY;
|
|
178
|
+
maxPx = Math.max(minPx, maxPx);
|
|
179
|
+
if (partEl.layoutInfo === undefined)
|
|
180
|
+
partEl.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
|
|
181
|
+
if (isHorizontal)
|
|
182
|
+
partEl.widthPx = { minPx, maxPx };
|
|
183
|
+
else
|
|
184
|
+
partEl.heightPx = { minPx, maxPx };
|
|
185
|
+
const preferredUsed = isHorizontal ? partEl.preferredWidthUsed : partEl.preferredHeightUsed;
|
|
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
|
+
}
|
|
193
|
+
if (isHorizontal)
|
|
194
|
+
partEl.preferredWidthUsed = true;
|
|
195
|
+
else
|
|
196
|
+
partEl.preferredHeightUsed = true;
|
|
197
|
+
}
|
|
198
|
+
const sizePx = partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx);
|
|
199
|
+
sizesPx.push({ node: child.instance, sizePx });
|
|
200
|
+
i++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const priorities = preferred.length > 0
|
|
204
|
+
? getPrioritiesForSizeChanging(isHorizontal, node.children, preferred)
|
|
205
|
+
: getPrioritiesForEmptySpaceDistribution(isHorizontal, node.children);
|
|
206
|
+
unobs(() => relayout(node, priorities.resizable, priorities.manuallyResizable, sizesPx));
|
|
207
|
+
}
|
|
166
208
|
});
|
|
167
209
|
}
|
|
168
210
|
return result;
|
|
@@ -171,25 +213,25 @@ export class SectionDriver extends HtmlDriver {
|
|
|
171
213
|
var _a;
|
|
172
214
|
let result = undefined;
|
|
173
215
|
const el = ownerNode.element;
|
|
174
|
-
if (el.splitView !== undefined
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
216
|
+
if (el.splitView !== undefined) {
|
|
217
|
+
if (isSplitViewPartition(childDriver)) {
|
|
218
|
+
let partCount = 0;
|
|
219
|
+
for (const child of ownerNode.children.items()) {
|
|
220
|
+
if (isSplitViewPartition(child.instance.driver))
|
|
221
|
+
partCount++;
|
|
222
|
+
}
|
|
223
|
+
const isHorizontal = el.splitView === SplitView.horizontal;
|
|
224
|
+
if (childDeclaration !== undefined) {
|
|
225
|
+
overrideOnCreate(childDeclaration, el => {
|
|
226
|
+
if (isHorizontal)
|
|
227
|
+
el.style.gridColumn = `${partCount + 1}`;
|
|
228
|
+
else
|
|
229
|
+
el.style.gridRow = `${partCount + 1}`;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (partCount > 0)
|
|
233
|
+
declareSplitter(partCount - 1, ownerNode);
|
|
190
234
|
}
|
|
191
|
-
if (partCount > 0)
|
|
192
|
-
declareSplitter(partCount - 1, ownerNode);
|
|
193
235
|
}
|
|
194
236
|
else {
|
|
195
237
|
if (childDriver.isPartition) {
|
|
@@ -204,6 +246,12 @@ export class SectionDriver extends HtmlDriver {
|
|
|
204
246
|
export function isSplitViewPartition(childDriver) {
|
|
205
247
|
return !childDriver.isPartition && childDriver !== Drivers.splitter && childDriver !== Drivers.synthetic;
|
|
206
248
|
}
|
|
249
|
+
function overrideOnCreate(declaration, func) {
|
|
250
|
+
const baseOnCreate = declaration.onCreate;
|
|
251
|
+
declaration.onCreate = baseOnCreate !== undefined
|
|
252
|
+
? (el, base) => { baseOnCreate(el, base); func(el); }
|
|
253
|
+
: (el, base) => { base(); func(el); };
|
|
254
|
+
}
|
|
207
255
|
export const Drivers = {
|
|
208
256
|
section: new SectionDriver(Constants.element, false, el => el.kind = ElKind.section),
|
|
209
257
|
table: new HtmlDriver(Constants.element, false, el => el.kind = ElKind.table),
|
|
@@ -3,4 +3,4 @@ import { FocusModel } from "./sensors/FocusSensor.js";
|
|
|
3
3
|
import { ResizedElement } from "./sensors/ResizeSensor.js";
|
|
4
4
|
export declare function OnClick(target: HTMLElement, action: (() => void) | ToggleRef | undefined, key?: string): void;
|
|
5
5
|
export declare function OnResize(target: HTMLElement, action: ((element: ResizedElement) => void) | undefined, key?: string): void;
|
|
6
|
-
export declare function OnFocus(target: HTMLElement, model: FocusModel, switchEditMode?: ((model
|
|
6
|
+
export declare function OnFocus(target: HTMLElement, model: FocusModel, switchEditMode?: ((model: FocusModel) => void) | undefined, key?: string): void;
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import { MergeList,
|
|
1
|
+
import { MergeList, RxNode } from "reactronic";
|
|
2
2
|
import { ElImpl } from "./El.js";
|
|
3
|
+
export declare function equal(a: number, b: number): boolean;
|
|
4
|
+
export declare function less(a: number, b: number): boolean;
|
|
5
|
+
export declare function greater(a: number, b: number): boolean;
|
|
3
6
|
export declare function relayoutUsingSplitter(splitViewNode: RxNode<ElImpl>, deltaPx: number, index: number, initialSizesPx: Array<{
|
|
4
7
|
node: RxNode<ElImpl>;
|
|
5
8
|
sizePx: number;
|
|
6
9
|
}>, priorities?: ReadonlyArray<number>): void;
|
|
7
|
-
export declare function relayout(splitViewNode: RxNode<ElImpl>, priorities: ReadonlyArray<number>, sizesPx: Array<{
|
|
10
|
+
export declare function relayout(splitViewNode: RxNode<ElImpl>, priorities: ReadonlyArray<number>, manuallyResizablePriorities: ReadonlyArray<number>, sizesPx: Array<{
|
|
8
11
|
node: RxNode<ElImpl>;
|
|
9
12
|
sizePx: number;
|
|
10
13
|
}>): void;
|
|
11
|
-
export declare function resizeUsingDelta(splitViewNode: RxNode<ElImpl>,
|
|
14
|
+
export declare function resizeUsingDelta(splitViewNode: RxNode<ElImpl>, deltaPx: number, index: number, priorities: ReadonlyArray<number>, sizesPx: Array<{
|
|
12
15
|
node: RxNode<ElImpl>;
|
|
13
16
|
sizePx: number;
|
|
14
|
-
}>, force?: boolean):
|
|
17
|
+
}>, force?: boolean): number;
|
|
15
18
|
export declare function layout(splitViewNode: RxNode<ElImpl>): void;
|
|
16
19
|
export declare function getPrioritiesForSplitter(index: number, size: number): ReadonlyArray<number>;
|
|
17
|
-
export declare function getPrioritiesForSizeChanging(
|
|
18
|
-
|
|
20
|
+
export declare function getPrioritiesForSizeChanging(isHorizontal: boolean, children: MergeList<RxNode>, indexes: Array<number>): {
|
|
21
|
+
resizable: ReadonlyArray<number>;
|
|
22
|
+
manuallyResizable: ReadonlyArray<number>;
|
|
23
|
+
};
|
|
24
|
+
export declare function getPrioritiesForEmptySpaceDistribution(isHorizontal: boolean, children: MergeList<RxNode>): {
|
|
25
|
+
resizable: ReadonlyArray<number>;
|
|
26
|
+
manuallyResizable: ReadonlyArray<number>;
|
|
27
|
+
};
|