verstak 0.24.276 → 0.24.301

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.
@@ -56,7 +56,7 @@ export class BasicNodeType {
56
56
  if (inst) {
57
57
  inst.native = undefined;
58
58
  if (!node.inline && node.instance)
59
- Transaction.separate(() => RxSystem.dispose(node.instance));
59
+ Transaction.isolate(() => RxSystem.dispose(node.instance));
60
60
  for (const x of inst.children)
61
61
  tryToFinalize(x, initiator);
62
62
  for (const x of inst.guests)
@@ -4,7 +4,7 @@ import { Handling } from "./Elements.js";
4
4
  export function DraggableArea(draggingId, builder) {
5
5
  return (Div(builder, {
6
6
  mode: Mode.independentUpdate,
7
- onChange: b => {
7
+ script: b => {
8
8
  const e = b.native;
9
9
  const model = b.model;
10
10
  const dataForSensor = e.dataForSensor;
@@ -63,7 +63,7 @@ export declare enum PosV {
63
63
  export type Range = {
64
64
  readonly min?: string;
65
65
  readonly max?: string;
66
- readonly preferred?: string;
66
+ preferred?: string;
67
67
  };
68
68
  export type MarkedRange = Range & {
69
69
  readonly marker?: string;
@@ -122,8 +122,6 @@ export declare class ElImpl<T extends Element = any, M = any> implements El<T, M
122
122
  minPx: number;
123
123
  maxPx: number;
124
124
  });
125
- get preferredWidthUsed(): boolean;
126
- set preferredWidthUsed(value: boolean);
127
125
  get height(): Range;
128
126
  set height(value: Range);
129
127
  get heightPx(): {
@@ -134,8 +132,6 @@ export declare class ElImpl<T extends Element = any, M = any> implements El<T, M
134
132
  minPx: number;
135
133
  maxPx: number;
136
134
  });
137
- get preferredHeightUsed(): boolean;
138
- set preferredHeightUsed(value: boolean);
139
135
  get horizontal(): PosH | undefined;
140
136
  set horizontal(value: PosH | undefined);
141
137
  get vertical(): PosV | undefined;
@@ -185,13 +181,11 @@ export declare class ElLayoutInfo {
185
181
  alignerY?: ElImpl;
186
182
  flags: ElLayoutInfoFlags;
187
183
  effectiveSizePx: number;
188
- offsetXpx: number;
189
- offsetYpx: number;
190
184
  contentSizeXpx: number;
191
185
  contentSizeYpx: number;
192
186
  borderSizeYpx: number;
193
187
  borderSizeXpx: number;
194
- isConstrained: boolean;
188
+ isUpdateFinished: boolean;
195
189
  constructor(prev: ElLayoutInfo);
196
190
  }
197
191
  declare enum ElLayoutInfoFlags {
@@ -213,6 +207,7 @@ export declare class CursorCommandDriver extends ElDriver<Element, unknown> {
213
207
  export declare const Constants: {
214
208
  element: string;
215
209
  partition: string;
210
+ wrapper: string;
216
211
  splitter: string;
217
212
  group: string;
218
213
  layouts: string[];
@@ -47,7 +47,6 @@ class Size extends ObservableObject {
47
47
  this.raw = { min: "", max: "" };
48
48
  this.minPx = 0;
49
49
  this.maxPx = Number.POSITIVE_INFINITY;
50
- this.preferredUsed = false;
51
50
  }
52
51
  }
53
52
  export class ElDriver extends BaseDriver {
@@ -66,8 +65,8 @@ export class ElImpl {
66
65
  this._kind = ElKind.part;
67
66
  this._place = undefined;
68
67
  this._coords = UndefinedElCoords;
69
- this._width = Transaction.separate(() => new Size());
70
- this._height = Transaction.separate(() => new Size());
68
+ this._width = Transaction.isolate(() => new Size());
69
+ this._height = Transaction.isolate(() => new Size());
71
70
  this._horizontal = undefined;
72
71
  this._vertical = undefined;
73
72
  this._contentHorizontal = undefined;
@@ -125,7 +124,6 @@ export class ElImpl {
125
124
  if (value.min !== w.min || value.max !== w.max || value.preferred !== undefined) {
126
125
  ElImpl.applyWidth(this, value);
127
126
  this._width.raw = value;
128
- this._width.preferredUsed = false;
129
127
  }
130
128
  }
131
129
  get widthPx() { return this._width; }
@@ -136,19 +134,12 @@ export class ElImpl {
136
134
  if (value.maxPx !== w.maxPx)
137
135
  this._width.maxPx = value.maxPx;
138
136
  }
139
- get preferredWidthUsed() {
140
- return this._width.preferredUsed;
141
- }
142
- set preferredWidthUsed(value) {
143
- this._width.preferredUsed = value;
144
- }
145
137
  get height() { return this._height.raw; }
146
138
  set height(value) {
147
139
  const h = this._height.raw;
148
140
  if (value.min !== h.min || value.max !== h.max || value.preferred !== undefined) {
149
141
  ElImpl.applyHeight(this, value);
150
142
  this._height.raw = value;
151
- this._height.preferredUsed = false;
152
143
  }
153
144
  }
154
145
  get heightPx() { return this._height; }
@@ -159,12 +150,6 @@ export class ElImpl {
159
150
  if (value.maxPx !== w.maxPx)
160
151
  this._height.maxPx = value.maxPx;
161
152
  }
162
- get preferredHeightUsed() {
163
- return this._height.preferredUsed;
164
- }
165
- set preferredHeightUsed(value) {
166
- this._height.preferredUsed = value;
167
- }
168
153
  get horizontal() { return this._horizontal; }
169
154
  set horizontal(value) {
170
155
  const existing = this._horizontal;
@@ -566,14 +551,13 @@ export class ElImpl {
566
551
  static applySealed(element, value) {
567
552
  const e = element.native;
568
553
  if (e instanceof HTMLElement) {
569
- Transaction.separate(() => e.sensors.resize.observeResizing(element, value !== undefined));
570
554
  }
571
555
  }
572
556
  static applySplitView(element, value) {
573
557
  const e = element.native;
574
558
  if (e instanceof HTMLElement) {
575
559
  element.sealed = value;
576
- e.style.position = value !== undefined ? "relative" : "";
560
+ Transaction.isolate(() => e.sensors.resize.observeResizing(element, value !== undefined));
577
561
  }
578
562
  }
579
563
  static applyStylingPreset(element, secondary, styleName, enabled) {
@@ -595,27 +579,17 @@ export class ElLayoutInfo {
595
579
  this.alignerY = undefined;
596
580
  this.flags = prev.flags & ~ElLayoutInfoFlags.ownCursorPosition;
597
581
  this.effectiveSizePx = 0;
598
- this.offsetXpx = 0;
599
- this.offsetYpx = 0;
600
582
  this.contentSizeXpx = 0;
601
583
  this.contentSizeYpx = 0;
602
584
  this.borderSizeXpx = 0;
603
585
  this.borderSizeYpx = 0;
604
- this.isConstrained = false;
586
+ this.isUpdateFinished = false;
605
587
  }
606
588
  }
607
589
  __decorate([
608
590
  obs,
609
591
  __metadata("design:type", Number)
610
592
  ], ElLayoutInfo.prototype, "effectiveSizePx", void 0);
611
- __decorate([
612
- obs,
613
- __metadata("design:type", Number)
614
- ], ElLayoutInfo.prototype, "offsetXpx", void 0);
615
- __decorate([
616
- obs,
617
- __metadata("design:type", Number)
618
- ], ElLayoutInfo.prototype, "offsetYpx", void 0);
619
593
  __decorate([
620
594
  obs,
621
595
  __metadata("design:type", Number)
@@ -635,7 +609,7 @@ __decorate([
635
609
  __decorate([
636
610
  obs,
637
611
  __metadata("design:type", Boolean)
638
- ], ElLayoutInfo.prototype, "isConstrained", void 0);
612
+ ], ElLayoutInfo.prototype, "isUpdateFinished", void 0);
639
613
  var ElLayoutInfoFlags;
640
614
  (function (ElLayoutInfoFlags) {
641
615
  ElLayoutInfoFlags[ElLayoutInfoFlags["none"] = 0] = "none";
@@ -645,7 +619,7 @@ var ElLayoutInfoFlags;
645
619
  ElLayoutInfoFlags[ElLayoutInfoFlags["childrenRelayoutIsNeeded"] = 8] = "childrenRelayoutIsNeeded";
646
620
  })(ElLayoutInfoFlags || (ElLayoutInfoFlags = {}));
647
621
  const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
648
- export const InitialElLayoutInfo = Object.freeze(new ElLayoutInfo({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: ElLayoutInfoFlags.none, effectiveSizePx: 0, offsetXpx: 0, offsetYpx: 0, contentSizeXpx: 0, contentSizeYpx: 0, borderSizeXpx: 0, borderSizeYpx: 0, isConstrained: false }));
622
+ export const InitialElLayoutInfo = Object.freeze(new ElLayoutInfo({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: ElLayoutInfoFlags.none, effectiveSizePx: 0, contentSizeXpx: 0, contentSizeYpx: 0, borderSizeXpx: 0, borderSizeYpx: 0, isUpdateFinished: false }));
649
623
  function getElCoordsAndAdjustLayoutInfo(isRegularElement, place, maxX, maxY, prevElLayoutInfo, layoutInfo) {
650
624
  var _a, _b;
651
625
  let result;
@@ -757,6 +731,7 @@ export class CursorCommandDriver extends ElDriver {
757
731
  export const Constants = {
758
732
  element: "el",
759
733
  partition: "part",
734
+ wrapper: "wrapper",
760
735
  splitter: "splitter",
761
736
  group: "group",
762
737
  layouts: ["panel", "table", "note", "group", "", "", ""],
@@ -773,10 +748,6 @@ const VerstakDriversByLayout = [
773
748
  s.textAlign = "initial";
774
749
  s.flexShrink = "1";
775
750
  s.minWidth = "0";
776
- if (owner.splitView !== undefined) {
777
- s.overflow = "hidden";
778
- s.flexGrow = "1";
779
- }
780
751
  },
781
752
  el => {
782
753
  const owner = el.node.owner.element;
@@ -787,10 +758,6 @@ const VerstakDriversByLayout = [
787
758
  s.gridAutoRows = "minmax(min-content, 1fr)";
788
759
  s.gridAutoColumns = "minmax(min-content, 1fr)";
789
760
  s.textAlign = "initial";
790
- if (owner.splitView !== undefined) {
791
- s.overflow = "hidden";
792
- s.flexGrow = "1";
793
- }
794
761
  },
795
762
  el => {
796
763
  const owner = el.node.owner.element;
@@ -810,6 +777,7 @@ const VerstakDriversByLayout = [
810
777
  s.flexDirection = "row";
811
778
  s.alignItems = "center";
812
779
  s.gap = "inherit";
780
+ s.position = owner.sealed !== undefined ? "relative" : "";
813
781
  },
814
782
  el => {
815
783
  const s = el.style;
@@ -1,4 +1,4 @@
1
- import { RxNodeDecl, RxNodeDriver, RxNode, Delegate, MergedItem } from "reactronic";
1
+ import { RxNodeDecl, RxNodeDriver, RxNode, Script, MergedItem } from "reactronic";
2
2
  import { CursorCommandDriver, El, ElPlace } from "./El.js";
3
3
  import { HtmlDriver } from "./HtmlDriver.js";
4
4
  export declare function Panel<M = unknown>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
@@ -10,19 +10,24 @@ export declare function declareSplitter<T>(index: number, splitViewNode: RxNode<
10
10
  export declare function cursor(areaParams: ElPlace): void;
11
11
  export declare function Note(content: string, formatted?: boolean, declaration?: RxNodeDecl<El<HTMLElement, void>>): RxNode<El<HTMLElement, void>>;
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
- export declare function Handling<M = unknown>(onChange: Delegate<El<void, M>>): RxNode<El<void, M>>;
13
+ export declare function Handling<M = unknown>(script: Script<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
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
+ export declare class PartitionDriver<T extends HTMLElement> extends HtmlDriver<T> {
21
+ update(node: RxNode<El<T>>): void | Promise<void>;
22
+ getHost(node: RxNode<El<T, any>>): RxNode<El<T, any>>;
23
+ }
20
24
  export declare const Drivers: {
21
25
  panel: PanelDriver<HTMLElement>;
22
26
  table: HtmlDriver<HTMLElement, any>;
23
27
  note: HtmlDriver<HTMLElement, any>;
24
28
  group: HtmlDriver<HTMLElement, any>;
25
- partition: HtmlDriver<HTMLElement, any>;
29
+ partition: PartitionDriver<HTMLElement>;
30
+ wrapper: HtmlDriver<HTMLElement, any>;
26
31
  splitter: HtmlDriver<HTMLElement, any>;
27
32
  cursor: CursorCommandDriver;
28
33
  synthetic: RxNodeDriver<El<void, any>>;
@@ -18,24 +18,15 @@ export function Splitter(declaration, preset) {
18
18
  return RxNode.declare(Drivers.splitter, declaration, preset);
19
19
  }
20
20
  export function rowBreak(shiftCursorDown) {
21
- RxNode.declare(Drivers.partition, {
22
- onChange: el => {
23
- const ownerEl = el.node.owner.element;
24
- if (ownerEl.splitView !== undefined) {
25
- el.style.display = "grid";
26
- }
27
- else {
28
- }
29
- },
30
- });
21
+ RxNode.declare(Drivers.partition);
31
22
  }
32
23
  export function declareSplitter(index, splitViewNode) {
33
24
  const key = `splitter-${index}`;
34
25
  return (Splitter({
35
26
  key,
36
27
  mode: Mode.independentUpdate,
37
- onCreate: el => el.native.className = `splitter ${key}`,
38
- onChange: b => {
28
+ creation: el => el.native.className = `splitter ${key}`,
29
+ script: b => {
39
30
  const e = b.native;
40
31
  const model = b.model;
41
32
  const dataForSensor = e.dataForSensor;
@@ -84,14 +75,14 @@ export function declareSplitter(index, splitViewNode) {
84
75
  }
85
76
  export function cursor(areaParams) {
86
77
  RxNode.declare(Drivers.cursor, {
87
- onChange: el => {
78
+ script: el => {
88
79
  el.place = areaParams;
89
80
  },
90
81
  });
91
82
  }
92
83
  export function Note(content, formatted, declaration) {
93
84
  return RxNode.declare(Drivers.note, declaration, {
94
- onChange: el => {
85
+ script: el => {
95
86
  if (formatted)
96
87
  el.native.innerHTML = content;
97
88
  else
@@ -102,8 +93,8 @@ export function Note(content, formatted, declaration) {
102
93
  export function Group(declaration, preset) {
103
94
  return RxNode.declare(Drivers.group, declaration, preset);
104
95
  }
105
- export function Handling(onChange) {
106
- return SyntheticElement({ mode: Mode.independentUpdate, onChange });
96
+ export function Handling(script) {
97
+ return SyntheticElement({ mode: Mode.independentUpdate, script });
107
98
  }
108
99
  export function SyntheticElement(declaration, preset) {
109
100
  return RxNode.declare(Drivers.synthetic, declaration, preset);
@@ -111,61 +102,33 @@ export function SyntheticElement(declaration, preset) {
111
102
  export class PanelDriver extends HtmlDriver {
112
103
  update(node) {
113
104
  rowBreak();
114
- const result = super.update(node);
115
105
  const el = node.element;
116
- if (el.sealed !== undefined) {
106
+ const result = super.update(node);
107
+ if (el.splitView !== undefined) {
108
+ if (el.layoutInfo === undefined)
109
+ el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
110
+ const layoutInfo = el.layoutInfo;
111
+ layoutInfo.isUpdateFinished = false;
117
112
  Handling(h => {
118
- var _a, _b;
119
113
  const native = el.native;
120
114
  const resize = native.sensors.resize;
121
- const isHorizontal = el.sealed === Direction.horizontal;
122
115
  for (const x of resize.resizedElements) {
123
- if (el.layoutInfo === undefined)
124
- el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
125
- const rect = x.contentRect;
116
+ const borderBoxPx = x.borderBoxSize[0];
126
117
  const contentBoxPx = x.contentBoxSize[0];
127
- const containerSizeXpx = contentBoxPx.inlineSize;
128
- const containerSizeYpx = contentBoxPx.blockSize;
129
- el.layoutInfo.offsetXpx = rect.left;
130
- el.layoutInfo.offsetYpx = rect.top;
131
- el.layoutInfo.contentSizeXpx = containerSizeXpx;
132
- el.layoutInfo.contentSizeYpx = containerSizeYpx;
133
- el.layoutInfo.borderSizeXpx = x.borderBoxSize[0].inlineSize;
134
- el.layoutInfo.borderSizeYpx = x.borderBoxSize[0].blockSize;
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`;
143
- }
144
- }
145
- if (h.node.stamp === 1) {
146
- const wrapper = (_b = node.children.firstMergedItem()) === null || _b === void 0 ? void 0 : _b.instance;
147
- if (wrapper !== undefined) {
148
- const wrapperEl = wrapper.element;
149
- if (isHorizontal)
150
- wrapperEl.style.width = wrapperEl.style.maxWidth = "0px";
151
- else
152
- wrapperEl.style.height = wrapperEl.style.maxHeight = "0px";
153
- }
118
+ layoutInfo.borderSizeXpx = borderBoxPx.inlineSize;
119
+ layoutInfo.borderSizeYpx = borderBoxPx.blockSize;
120
+ layoutInfo.contentSizeXpx = contentBoxPx.inlineSize;
121
+ layoutInfo.contentSizeYpx = contentBoxPx.blockSize;
154
122
  }
155
123
  });
156
- }
157
- if (el.splitView !== undefined) {
158
124
  SyntheticElement({
159
125
  mode: Mode.independentUpdate,
160
- triggers: { stamp: el.node.stamp },
161
- onChange: () => {
126
+ script: () => {
162
127
  const native = el.native;
163
128
  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;
129
+ if (layoutInfo.isUpdateFinished) {
130
+ const surroundingXpx = layoutInfo.borderSizeXpx - layoutInfo.contentSizeXpx;
131
+ const surroundingYpx = layoutInfo.borderSizeYpx - layoutInfo.contentSizeYpx;
169
132
  let i = 0;
170
133
  const preferred = [];
171
134
  const sizesPx = [];
@@ -186,20 +149,13 @@ export class PanelDriver extends HtmlDriver {
186
149
  partEl.widthPx = { minPx, maxPx };
187
150
  else
188
151
  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;
152
+ const preferredPx = size.preferred ? toPx(Dimension.parse(size.preferred), options) : 0;
153
+ if (preferredPx > 0) {
154
+ partEl.layoutInfo.effectiveSizePx = preferredPx;
155
+ size.preferred = undefined;
156
+ preferred.push(i);
201
157
  }
202
- const sizePx = partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx);
158
+ const sizePx = unobs(() => partEl.layoutInfo.effectiveSizePx = clamp(partEl.layoutInfo.effectiveSizePx, minPx, maxPx));
203
159
  sizesPx.push({ node: child.instance, sizePx });
204
160
  i++;
205
161
  }
@@ -211,6 +167,9 @@ export class PanelDriver extends HtmlDriver {
211
167
  }
212
168
  },
213
169
  });
170
+ RxNode.updateNestedNodesThenDo(() => {
171
+ layoutInfo.isUpdateFinished = true;
172
+ });
214
173
  }
215
174
  return result;
216
175
  }
@@ -230,7 +189,7 @@ export class PanelDriver extends HtmlDriver {
230
189
  if (childDeclaration.triggers === undefined)
231
190
  childDeclaration.triggers = {};
232
191
  Object.defineProperty(childDeclaration.triggers, "index", { value: partCount });
233
- overrideMethod(childDeclaration, "onChange", el => {
192
+ overrideMethod(childDeclaration, "script", el => {
234
193
  if (isHorizontal)
235
194
  el.style.gridColumn = `${partCount + 1}`;
236
195
  else
@@ -255,17 +214,60 @@ export function isSplitViewPartition(childDriver) {
255
214
  return !childDriver.isPartition && childDriver !== Drivers.splitter && childDriver !== Drivers.synthetic;
256
215
  }
257
216
  function overrideMethod(declaration, method, func) {
258
- const baseOnChange = declaration[method];
259
- declaration[method] = baseOnChange !== undefined
260
- ? (el, base) => { baseOnChange(el, base); func(el); }
217
+ const baseScript = declaration[method];
218
+ declaration[method] = baseScript !== undefined
219
+ ? (el, base) => { baseScript(el, base); func(el); }
261
220
  : (el, base) => { base(); func(el); };
262
221
  }
222
+ export class PartitionDriver extends HtmlDriver {
223
+ update(node) {
224
+ const result = super.update(node);
225
+ const ownerEl = node.owner.element;
226
+ if (ownerEl.sealed !== undefined) {
227
+ node.element.style.flexGrow = "1";
228
+ RxNode.declare(Drivers.wrapper, {
229
+ script: el => {
230
+ const ownerEl = el.node.owner.owner.element;
231
+ if (ownerEl.splitView !== undefined) {
232
+ el.style.display = "grid";
233
+ el.style.flexDirection = "";
234
+ }
235
+ else {
236
+ if (ownerEl.isTable) {
237
+ el.style.display = "contents";
238
+ el.style.flexDirection = "";
239
+ }
240
+ else {
241
+ el.style.display = "flex";
242
+ el.style.flexDirection = "row";
243
+ }
244
+ }
245
+ el.style.position = "absolute";
246
+ el.style.inset = "0";
247
+ el.style.overflow = "auto";
248
+ el.style.gap = "inherit";
249
+ },
250
+ });
251
+ }
252
+ return result;
253
+ }
254
+ getHost(node) {
255
+ let host;
256
+ const ownerEl = node.owner.element;
257
+ if (ownerEl.sealed !== undefined)
258
+ host = node.children.firstMergedItem().instance;
259
+ else
260
+ host = node;
261
+ return host;
262
+ }
263
+ }
263
264
  export const Drivers = {
264
265
  panel: new PanelDriver(Constants.element, false, el => el.kind = ElKind.panel),
265
266
  table: new HtmlDriver(Constants.element, false, el => el.kind = ElKind.table),
266
267
  note: new HtmlDriver(Constants.element, false, el => el.kind = ElKind.note),
267
268
  group: new HtmlDriver(Constants.group, false, el => el.kind = ElKind.group),
268
- partition: new HtmlDriver(Constants.partition, true, el => el.kind = ElKind.part),
269
+ partition: new PartitionDriver(Constants.partition, true, el => el.kind = ElKind.part),
270
+ wrapper: new HtmlDriver(Constants.wrapper, false, el => el.kind = ElKind.native),
269
271
  splitter: new HtmlDriver(Constants.splitter, false, el => el.kind = ElKind.splitter),
270
272
  cursor: new CursorCommandDriver(),
271
273
  synthetic: new ElDriver("synthetic", false, el => el.kind = ElKind.group),
@@ -6,7 +6,7 @@ export function OnClick(target, action, key) {
6
6
  key,
7
7
  mode: Mode.independentUpdate,
8
8
  triggers: { target },
9
- onChange: el => {
9
+ script: el => {
10
10
  const pointer = target.sensors.pointer;
11
11
  if (target.dataForSensor.click !== undefined && pointer.clicked === target.dataForSensor.click || target.dataForSensor.click === undefined && pointer.clicked) {
12
12
  if (action instanceof Function) {
@@ -26,7 +26,7 @@ export function OnResize(target, action, key) {
26
26
  key,
27
27
  mode: Mode.independentUpdate,
28
28
  triggers: { target },
29
- onChange: el => {
29
+ script: el => {
30
30
  const resize = target.sensors.resize;
31
31
  resize.resizedElements.forEach(x => {
32
32
  action(x);
@@ -40,10 +40,10 @@ export function OnFocus(target, model, switchEditMode = undefined, key) {
40
40
  key,
41
41
  mode: Mode.independentUpdate,
42
42
  triggers: { target, model },
43
- onCreate: el => {
43
+ creation: el => {
44
44
  el.node.configureReactronic({ throttling: 0 });
45
45
  },
46
- onChange: el => {
46
+ script: el => {
47
47
  if (switchEditMode === undefined && !(target instanceof HTMLInputElement || target.hasAttribute("tabindex")))
48
48
  console.warn(`"${key !== null && key !== void 0 ? key : "noname"}" element must have "tabindex" attribute set in order to be focusable`);
49
49
  if (switchEditMode !== undefined) {
@@ -1,4 +1,4 @@
1
- import { RxNode, SimpleDelegate } from "reactronic";
1
+ import { RxNode, Handler } from "reactronic";
2
2
  import { El, ElDriver } from "./El.js";
3
3
  export declare class WebDriver<T extends Element, M = unknown> extends ElDriver<T, M> {
4
4
  setNativeElement(node: RxNode<El<T, M>>): void;
@@ -13,7 +13,7 @@ export declare class WebDriver<T extends Element, M = unknown> extends ElDriver<
13
13
  }
14
14
  export declare class StaticDriver<T extends HTMLElement> extends WebDriver<T> {
15
15
  readonly native: T;
16
- constructor(native: T, name: string, isRow: boolean, predefine?: SimpleDelegate<El<T>>);
16
+ constructor(native: T, name: string, isRow: boolean, initialize?: Handler<El<T>>);
17
17
  setNativeElement(node: RxNode<El<T>>): void;
18
18
  }
19
19
  export declare class HtmlDriver<T extends HTMLElement, M = any> extends WebDriver<T, M> {
@@ -31,7 +31,9 @@ export class WebDriver extends ElDriver {
31
31
  if (native) {
32
32
  const sequential = node.owner.children.isStrict;
33
33
  const automaticHost = RxNode.findMatchingHost(node, n => n.element.native instanceof HTMLElement || n.element.native instanceof SVGElement);
34
- const automaticNativeHost = automaticHost === null || automaticHost === void 0 ? void 0 : automaticHost.element.native;
34
+ const automaticNativeHost = automaticHost !== node.owner
35
+ ? automaticHost === null || automaticHost === void 0 ? void 0 : automaticHost.driver.getHost(automaticHost).element.native
36
+ : automaticHost === null || automaticHost === void 0 ? void 0 : automaticHost.element.native;
35
37
  if (automaticNativeHost) {
36
38
  if (sequential && !node.driver.isPartition) {
37
39
  const after = RxNode.findMatchingPrevSibling(node, n => n.element.native instanceof HTMLElement || n.element.native instanceof SVGElement);
@@ -80,8 +82,8 @@ export class WebDriver extends ElDriver {
80
82
  }
81
83
  }
82
84
  export class StaticDriver extends WebDriver {
83
- constructor(native, name, isRow, predefine) {
84
- super(name, isRow, predefine);
85
+ constructor(native, name, isRow, initialize) {
86
+ super(name, isRow, initialize);
85
87
  this.native = native;
86
88
  }
87
89
  setNativeElement(node) {
@@ -1,4 +1,4 @@
1
- import { ElLayoutInfo, InitialElLayoutInfo, Direction } from "./El.js";
1
+ import { Direction } from "./El.js";
2
2
  import { Drivers, isSplitViewPartition } from "./Elements.js";
3
3
  import { clamp } from "./ElUtils.js";
4
4
  const DEBUG = false;
@@ -20,26 +20,33 @@ export function relayoutUsingSplitter(splitViewNode, deltaPx, index, initialSize
20
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
- DEBUG && console.log(`(splitter) delta = ${deltaPx}, container = ${containerSizePx}, size = ${initialSizesPx.reduce((p, c) => p + c.sizePx, 0)}, index = ${index}`);
24
- resizeUsingDelta(splitViewNode, deltaPx, index + 1, priorities, initialSizesPx, true);
25
- layout(splitViewNode);
23
+ if (containerSizePx > 0) {
24
+ DEBUG && console.group(`(splitter) delta = ${deltaPx}, container = ${containerSizePx}, size = ${initialSizesPx.reduce((p, c) => p + c.sizePx, 0)}, index = ${index}`);
25
+ resizeUsingDelta(splitViewNode, deltaPx, index + 1, priorities, initialSizesPx, true);
26
+ DEBUG && console.groupEnd();
27
+ layout(splitViewNode);
28
+ }
26
29
  }
27
30
  export function relayout(splitViewNode, priorities, manuallyResizablePriorities, sizesPx) {
28
31
  var _a, _b, _c, _d;
29
32
  const containerSizePx = splitViewNode.element.splitView === Direction.horizontal
30
33
  ? (_b = (_a = splitViewNode.element.layoutInfo) === null || _a === void 0 ? void 0 : _a.contentSizeXpx) !== null && _b !== void 0 ? _b : 0
31
34
  : (_d = (_c = splitViewNode.element.layoutInfo) === null || _c === void 0 ? void 0 : _c.contentSizeYpx) !== null && _d !== void 0 ? _d : 0;
32
- const totalSizePx = sizesPx.reduce((p, c) => p + c.sizePx, 0);
33
- let deltaPx = containerSizePx - totalSizePx;
34
- DEBUG && console.log(printPriorities(priorities, manuallyResizablePriorities), "color: grey", "color:", "color: grey", "color:");
35
- DEBUG && console.log(`(relayout) ∆ = ${n(deltaPx)}px, container = ${n(containerSizePx)}px, total = ${totalSizePx}`);
36
- deltaPx = resizeUsingDelta(splitViewNode, deltaPx, sizesPx.length, priorities, sizesPx);
37
- DEBUG && console.log(`(relayout) ~∆ = ${n(deltaPx)}, container = ${n(containerSizePx, 3)}px, total = ${n(sizesPx.reduce((p, c) => p + c.sizePx, 0), 3)}px`);
38
- if (deltaPx < -(1 / devicePixelRatio)) {
39
- DEBUG && console.log(`%c${deltaPx}px`, "color: lime");
40
- resizeUsingDelta(splitViewNode, deltaPx, sizesPx.length, manuallyResizablePriorities, sizesPx, true);
35
+ if (containerSizePx > 0) {
36
+ const totalSizePx = sizesPx.reduce((p, c) => p + c.sizePx, 0);
37
+ let deltaPx = containerSizePx - totalSizePx;
38
+ DEBUG && console.log(printPriorities(priorities, manuallyResizablePriorities), "color: grey", "color:", "color: grey", "color:");
39
+ DEBUG && console.group(`(relayout) ∆ = ${n(deltaPx)}px, container = ${n(containerSizePx)}px, total = ${totalSizePx}`);
40
+ deltaPx = resizeUsingDelta(splitViewNode, deltaPx, sizesPx.length, priorities, sizesPx);
41
+ DEBUG && console.groupEnd();
42
+ DEBUG && console.group(`(relayout) ~∆ = ${n(deltaPx)}, container = ${n(containerSizePx, 3)}px, total = ${n(sizesPx.reduce((p, c) => p + c.sizePx, 0), 3)}px`);
43
+ if (deltaPx < -(1 / devicePixelRatio)) {
44
+ DEBUG && console.log(`%c${deltaPx}px`, "color: lime");
45
+ resizeUsingDelta(splitViewNode, deltaPx, sizesPx.length, manuallyResizablePriorities, sizesPx, true);
46
+ }
47
+ DEBUG && console.groupEnd();
48
+ layout(splitViewNode);
41
49
  }
42
- layout(splitViewNode);
43
50
  }
44
51
  export function resizeUsingDelta(splitViewNode, deltaPx, index, priorities, sizesPx, force = false) {
45
52
  const isHorizontal = splitViewNode.element.splitView === Direction.horizontal;
@@ -63,29 +70,31 @@ export function resizeUsingDelta(splitViewNode, deltaPx, index, priorities, size
63
70
  const minDeltaPx = Math.max(minBeforeDeltaPx, minAfterDeltaPx);
64
71
  const maxDeltaPx = Math.min(maxBeforeDeltaPx, maxAfterDeltaPx);
65
72
  const clampedDeltaPx = clamp(deltaPx, minDeltaPx, maxDeltaPx);
66
- DEBUG && console.log(`%c${sizesPx.map((x, i) => {
73
+ DEBUG && console.log("Initial sizes:");
74
+ DEBUG && sizesPx.map((x, i) => {
67
75
  const size = isHorizontal ? x.node.element.widthPx : x.node.element.heightPx;
68
- return `${i}: ${size.minPx}..${x.sizePx}..${size.maxPx} (px)`;
69
- }).join("\n")}`, "color: skyblue");
70
- DEBUG && console.log(`[%c${Array.from({ length: index }).map((x, i) => i).join(",")}%c | %c${Array.from({ length: Math.max(0, sizesPx.length - index) }).map((x, i) => index + i).join(",")}%c]\n∆ = ${n(minDeltaPx)}px..${n(deltaPx)}px -> %c${n(clampedDeltaPx)}px%c..${n(maxDeltaPx)}px`, "color: #00BB00", "color:", "color: orange", "color:", "color: yellow", "color:");
76
+ return console.log(`%c ${i}: ${size.minPx}..${x.sizePx}..${size.maxPx} (px)`, "color: skyblue");
77
+ });
78
+ DEBUG && console.log(`[%c${Array.from({ length: index }).map((x, i) => i).join(",")}%c | %c${Array.from({ length: Math.max(0, sizesPx.length - index) }).map((x, i) => index + i).join(",")}%c] ∆ = ${n(minDeltaPx)}px..${n(deltaPx)}px -> %c${n(clampedDeltaPx)}px%c..${n(maxDeltaPx)}px`, "color: #00BB00", "color:", "color: #00BB00", "color:", "color: yellow", "color:");
71
79
  if (clampedDeltaPx !== 0) {
80
+ DEBUG && console.log("distribution: start");
72
81
  if (index > 0)
73
82
  beforeDeltaPx = distribute(1, clampedDeltaPx, index, priorities, sizesPx, isHorizontal, force);
74
83
  if (hasAfter)
75
84
  distribute(-1, clampedDeltaPx, index, priorities, sizesPx, isHorizontal, force);
85
+ DEBUG && console.log("distribution: end");
76
86
  }
77
87
  }
88
+ DEBUG && console.log("Set new sizes:");
78
89
  for (let i = 0; i < sizesPx.length; i++) {
79
90
  const el = sizesPx[i].node.element;
80
- if (el.layoutInfo === undefined)
81
- el.layoutInfo = new ElLayoutInfo(InitialElLayoutInfo);
91
+ DEBUG && console.log(`%c ${i}: ${n(el.layoutInfo.effectiveSizePx)} -> ${n(sizesPx[i].sizePx)} (px)`, "color: skyblue");
82
92
  el.layoutInfo.effectiveSizePx = sizesPx[i].sizePx;
83
- DEBUG && console.log(`[${i}]: set size = ${n(sizesPx[i].sizePx)}px`);
84
93
  }
85
94
  return beforeDeltaPx;
86
95
  }
87
96
  export function layout(splitViewNode) {
88
- var _a, _b, _c, _d, _e, _f, _g, _h;
97
+ var _a, _b, _c, _d, _e, _f, _g;
89
98
  const isHorizontal = splitViewNode.element.splitView === Direction.horizontal;
90
99
  let posPx = 0;
91
100
  let shrinkBefore = false;
@@ -93,8 +102,6 @@ export function layout(splitViewNode) {
93
102
  let isSplitterEnabled = false;
94
103
  const sizesPx = [];
95
104
  const layoutInfo = splitViewNode.element.layoutInfo;
96
- const offsetXpx = (_a = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.offsetXpx) !== null && _a !== void 0 ? _a : 0;
97
- const offsetYpx = (_b = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.offsetYpx) !== null && _b !== void 0 ? _b : 0;
98
105
  for (const item of splitViewNode.children.items()) {
99
106
  const child = item.instance;
100
107
  if (isSplitViewPartition(child.driver)) {
@@ -102,7 +109,7 @@ export function layout(splitViewNode) {
102
109
  if (el.native !== undefined) {
103
110
  const current = item;
104
111
  const sizePx = isHorizontal ? el.widthPx : el.heightPx;
105
- const effectiveSizePx = (_d = (_c = el.layoutInfo) === null || _c === void 0 ? void 0 : _c.effectiveSizePx) !== null && _d !== void 0 ? _d : 0;
112
+ const effectiveSizePx = (_b = (_a = el.layoutInfo) === null || _a === void 0 ? void 0 : _a.effectiveSizePx) !== null && _b !== void 0 ? _b : 0;
106
113
  posPx += effectiveSizePx;
107
114
  sizesPx.push(effectiveSizePx);
108
115
  el.native.setAttribute("rx-max", equal(effectiveSizePx, sizePx.maxPx) ? "true" : "false");
@@ -117,7 +124,7 @@ export function layout(splitViewNode) {
117
124
  const el = child.element;
118
125
  if (el.native !== undefined) {
119
126
  const sizePx = isHorizontal ? el.widthPx : el.heightPx;
120
- const effectiveSizePx = (_f = (_e = el.layoutInfo) === null || _e === void 0 ? void 0 : _e.effectiveSizePx) !== null && _f !== void 0 ? _f : 0;
127
+ const effectiveSizePx = (_d = (_c = el.layoutInfo) === null || _c === void 0 ? void 0 : _c.effectiveSizePx) !== null && _d !== void 0 ? _d : 0;
121
128
  shrinkAfter || (shrinkAfter = greater(effectiveSizePx - sizePx.minPx, 0));
122
129
  growAfter || (growAfter = greater(sizePx.maxPx - effectiveSizePx, 0));
123
130
  isSplitterEnabled = growBefore && shrinkAfter || growAfter && shrinkBefore;
@@ -133,15 +140,15 @@ export function layout(splitViewNode) {
133
140
  if (el.native !== undefined) {
134
141
  el.style.display = isSplitterEnabled ? "block" : "none";
135
142
  if (isHorizontal)
136
- el.style.left = `${offsetXpx + posPx}px`;
143
+ el.style.left = `${posPx}px`;
137
144
  else
138
- el.style.top = `${offsetYpx + posPx}px`;
145
+ el.style.top = `${posPx}px`;
139
146
  }
140
147
  }
141
148
  }
142
- const containerSizePx = (_g = (isHorizontal ? layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.contentSizeXpx : layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.contentSizeYpx)) !== null && _g !== void 0 ? _g : 0;
149
+ const containerSizePx = (_e = (isHorizontal ? layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.contentSizeXpx : layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.contentSizeYpx)) !== null && _e !== void 0 ? _e : 0;
143
150
  const isOverflowing = greater(posPx, containerSizePx);
144
- const wrapper = (_h = splitViewNode.children.firstMergedItem()) === null || _h === void 0 ? void 0 : _h.instance;
151
+ const wrapper = (_g = (_f = splitViewNode.children.firstMergedItem()) === null || _f === void 0 ? void 0 : _f.instance.children.firstMergedItem()) === null || _g === void 0 ? void 0 : _g.instance;
145
152
  if (wrapper !== undefined) {
146
153
  if (isHorizontal)
147
154
  wrapper.element.style.gridTemplateColumns = sizesPx.map(x => `${x}px`).join(" ");
@@ -149,12 +156,12 @@ export function layout(splitViewNode) {
149
156
  wrapper.element.style.gridTemplateRows = sizesPx.map(x => `${x}px`).join(" ");
150
157
  if (isOverflowing) {
151
158
  if (isHorizontal)
152
- wrapper.element.style.overflow = "scroll hidden";
159
+ wrapper.element.style.overflow = "scroll visible";
153
160
  else
154
- wrapper.element.style.overflow = "hidden scroll";
161
+ wrapper.element.style.overflow = "visible scroll";
155
162
  }
156
163
  else {
157
- wrapper.element.style.overflow = "hidden";
164
+ wrapper.element.style.overflow = "visible";
158
165
  }
159
166
  }
160
167
  }
@@ -284,8 +291,8 @@ function distribute(sign, deltaPx, index, priorities, sizesPx, isHorizontal, for
284
291
  fractionCount += growth;
285
292
  }
286
293
  }
287
- } while (Math.abs(deltaPx) > eps && fractionCount > 0);
288
- if (Math.abs(deltaPx) <= eps) {
294
+ } while (!equal(deltaPx, 0) && fractionCount > 0);
295
+ if (equal(deltaPx, 0)) {
289
296
  break;
290
297
  }
291
298
  }
@@ -294,7 +301,7 @@ function distribute(sign, deltaPx, index, priorities, sizesPx, isHorizontal, for
294
301
  function printPriorities(priorities, manuallyResizablePriorities) {
295
302
  let text = "";
296
303
  if (priorities.length > 0) {
297
- text += `Automatically Resizable:\n%c(${priorities.map(x => `0x${x.toString(2)}`).join(", ")})%c\n`;
304
+ text += `Automatically Resizable:\n%c(${priorities.map(x => `0b${x.toString(2)}`).join(", ")})%c\n`;
298
305
  for (let i = 0; i < priorities.length; i++) {
299
306
  let vector = priorities[i];
300
307
  const parts = [];
@@ -309,7 +316,7 @@ function printPriorities(priorities, manuallyResizablePriorities) {
309
316
  }
310
317
  }
311
318
  if (manuallyResizablePriorities.length > 0) {
312
- text += `Manually Resizable:\n%c(${manuallyResizablePriorities.map(x => `0x${x.toString(2)}`).join(", ")})%c\n`;
319
+ text += `Manually Resizable:\n%c(${manuallyResizablePriorities.map(x => `0b${x.toString(2)}`).join(", ")})%c\n`;
313
320
  for (let i = 0; i < manuallyResizablePriorities.length; i++) {
314
321
  let vector = manuallyResizablePriorities[i];
315
322
  const parts = [];
@@ -107,7 +107,7 @@ export class ButtonSensor extends BasePointerSensor {
107
107
  this.positionY = e.clientY;
108
108
  this.revision++;
109
109
  }
110
- Transaction.separate(() => {
110
+ Transaction.isolate(() => {
111
111
  var _a;
112
112
  (_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window, "button");
113
113
  });
@@ -127,7 +127,7 @@ export class HtmlDragSensor extends HtmlElementSensor {
127
127
  this.dragTargetWindow = undefined;
128
128
  this.previousDragTarget = undefined;
129
129
  this.revision++;
130
- Transaction.separate(() => {
130
+ Transaction.isolate(() => {
131
131
  var _a;
132
132
  (_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window, "htmlDrag");
133
133
  });
@@ -154,7 +154,7 @@ export class PointerSensor extends BasePointerSensor {
154
154
  this.dragTarget = undefined;
155
155
  this.dragTargetWindow = undefined;
156
156
  this.previousDragTarget = undefined;
157
- Transaction.separate(() => {
157
+ Transaction.isolate(() => {
158
158
  var _a;
159
159
  (_a = this.windowSensor) === null || _a === void 0 ? void 0 : _a.setActiveWindow(window, "pointer");
160
160
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "verstak",
3
- "version": "0.24.276",
3
+ "version": "0.24.301",
4
4
  "description": "Verstak - Front-End Library",
5
5
  "publisher": "Nezaboodka Software",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "homepage": "https://github.com/nezaboodka/verstak/blob/master/README.md#readme",
33
33
  "dependencies": {
34
- "reactronic": "^0.24.272"
34
+ "reactronic": "^0.24.301"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.11.17",