verstak 0.24.125 → 0.24.128

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.
Files changed (39) hide show
  1. package/build/dist/source/archive/RxDomV1.js +1 -1
  2. package/build/dist/source/html/El.d.ts +22 -24
  3. package/build/dist/source/html/El.js +35 -35
  4. package/build/dist/source/html/Elements.d.ts +3 -2
  5. package/build/dist/source/html/Elements.js +12 -9
  6. package/build/dist/source/html/Handlers.d.ts +6 -0
  7. package/build/dist/source/html/Handlers.js +55 -0
  8. package/build/dist/source/html/HtmlApiExt.d.ts +2 -0
  9. package/build/dist/source/html/HtmlApiExt.js +11 -1
  10. package/build/dist/source/html/HtmlElements.js +174 -174
  11. package/build/dist/source/html/api.d.ts +1 -1
  12. package/build/dist/source/html/api.js +1 -1
  13. package/build/dist/source/html/sensors/BasePointerSensor.d.ts +5 -5
  14. package/build/dist/source/html/sensors/BasePointerSensor.js +11 -11
  15. package/build/dist/source/html/sensors/ButtonSensor.d.ts +6 -6
  16. package/build/dist/source/html/sensors/ButtonSensor.js +39 -48
  17. package/build/dist/source/html/sensors/DataForSensor.d.ts +1 -0
  18. package/build/dist/source/html/sensors/DataForSensor.js +1 -0
  19. package/build/dist/source/html/sensors/FocusSensor.d.ts +2 -2
  20. package/build/dist/source/html/sensors/FocusSensor.js +14 -17
  21. package/build/dist/source/html/sensors/HoverSensor.d.ts +15 -4
  22. package/build/dist/source/html/sensors/HoverSensor.js +65 -24
  23. package/build/dist/source/html/sensors/HtmlDragSensor.d.ts +2 -2
  24. package/build/dist/source/html/sensors/HtmlDragSensor.js +25 -34
  25. package/build/dist/source/html/sensors/HtmlElementSensor.d.ts +3 -3
  26. package/build/dist/source/html/sensors/HtmlElementSensor.js +7 -4
  27. package/build/dist/source/html/sensors/HtmlSensors.d.ts +23 -11
  28. package/build/dist/source/html/sensors/HtmlSensors.js +81 -35
  29. package/build/dist/source/html/sensors/KeyboardSensor.d.ts +17 -17
  30. package/build/dist/source/html/sensors/KeyboardSensor.js +42 -51
  31. package/build/dist/source/html/sensors/PointerSensor.d.ts +3 -2
  32. package/build/dist/source/html/sensors/PointerSensor.js +28 -38
  33. package/build/dist/source/html/sensors/ScrollSensor.d.ts +12 -0
  34. package/build/dist/source/html/sensors/ScrollSensor.js +62 -0
  35. package/build/dist/source/html/sensors/WheelSensor.d.ts +2 -2
  36. package/build/dist/source/html/sensors/WheelSensor.js +11 -20
  37. package/package.json +8 -8
  38. package/build/dist/source/html/ReactingFocuser.d.ts +0 -2
  39. package/build/dist/source/html/ReactingFocuser.js +0 -20
@@ -85,7 +85,7 @@ RxNodeInstanceImpl.gUuid = 0;
85
85
  __decorate([
86
86
  reactive,
87
87
  options({
88
- reentrance: Reentrance.CancelPrevious,
88
+ reentrance: Reentrance.cancelPrevious,
89
89
  triggeringArgs: true,
90
90
  noSideEffects: true
91
91
  }),
@@ -2,12 +2,10 @@ import { RxNode, BaseDriver } from "reactronic";
2
2
  export declare class ElDriver<T extends Element, M = unknown> extends BaseDriver<El<T, M>> {
3
3
  allocate(node: RxNode<El<T, M>>): El<T, M>;
4
4
  }
5
- export type BaseEl<T = any, M = any> = {
5
+ export type El<T = any, M = any> = {
6
6
  readonly node: RxNode<El<T, M>>;
7
- model: M;
8
- };
9
- export type El<T = any, M = any> = BaseEl<T, M> & {
10
7
  native: T;
8
+ model: M;
11
9
  kind: ElKind;
12
10
  area: ElArea;
13
11
  widthGrowth: number;
@@ -23,13 +21,13 @@ export type El<T = any, M = any> = BaseEl<T, M> & {
23
21
  useStyle(styleName: string, enabled?: boolean): void;
24
22
  };
25
23
  export declare enum ElKind {
26
- Section = 0,
27
- Table = 1,
28
- Note = 2,
29
- Group = 3,
30
- Part = 4,
31
- Cursor = 5,
32
- Native = 6
24
+ section = 0,
25
+ table = 1,
26
+ note = 2,
27
+ group = 3,
28
+ part = 4,
29
+ cursor = 5,
30
+ native = 6
33
31
  }
34
32
  export type ElCoords = {
35
33
  x1: number;
@@ -38,15 +36,15 @@ export type ElCoords = {
38
36
  y2: number;
39
37
  };
40
38
  export declare enum Align {
41
- Default = 16,
42
- ToBounds = 0,
43
- ToLeft = 1,
44
- ToCenterX = 2,
45
- ToRight = 3,
46
- ToTop = 4,
47
- ToCenterY = 8,
48
- ToBottom = 12,
49
- ToCenter = 10
39
+ default = 16,
40
+ toBounds = 0,
41
+ toLeft = 1,
42
+ toCenterX = 2,
43
+ toRight = 3,
44
+ toTop = 4,
45
+ toCenterY = 8,
46
+ toBottom = 12,
47
+ toCenter = 10
50
48
  }
51
49
  export type ElasticSize = {
52
50
  cells?: number;
@@ -123,10 +121,10 @@ declare class CursorPosition {
123
121
  constructor(prev: CursorPosition);
124
122
  }
125
123
  declare enum CursorFlags {
126
- None = 0,
127
- OwnCursorPosition = 1,
128
- UsesRunningColumnCount = 2,
129
- UsesRunningRowCount = 4
124
+ none = 0,
125
+ ownCursorPosition = 1,
126
+ usesRunningColumnCount = 2,
127
+ usesRunningRowCount = 4
130
128
  }
131
129
  export declare class CursorCommand {
132
130
  absolute?: string;
@@ -7,25 +7,25 @@ export class ElDriver extends BaseDriver {
7
7
  }
8
8
  export var ElKind;
9
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";
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
17
  })(ElKind || (ElKind = {}));
18
18
  export var Align;
19
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";
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
29
  })(Align || (Align = {}));
30
30
  export class ElImpl {
31
31
  constructor(node) {
@@ -35,7 +35,7 @@ export class ElImpl {
35
35
  this.cursorPosition = undefined;
36
36
  this.native = undefined;
37
37
  this.model = undefined;
38
- this._kind = ElKind.Part;
38
+ this._kind = ElKind.part;
39
39
  this._area = undefined;
40
40
  this._coords = UndefinedElCoords;
41
41
  this._widthGrowth = 0;
@@ -44,8 +44,8 @@ export class ElImpl {
44
44
  this._heightGrowth = 0;
45
45
  this._minHeight = "";
46
46
  this._maxHeight = "";
47
- this._contentAlignment = Align.Default;
48
- this._elementAlignment = Align.Default;
47
+ this._contentAlignment = Align.default;
48
+ this._elementAlignment = Align.default;
49
49
  this._contentWrapping = true;
50
50
  this._overlayVisible = undefined;
51
51
  this._hasStyles = false;
@@ -54,9 +54,9 @@ export class ElImpl {
54
54
  this._area = undefined;
55
55
  this._hasStyles = false;
56
56
  }
57
- get isSection() { return this.kind === ElKind.Section; }
58
- get isTable() { return this.kind === ElKind.Table; }
59
- get isAuxiliary() { return this.kind > ElKind.Note; }
57
+ get isSection() { return this.kind === ElKind.section; }
58
+ get isTable() { return this.kind === ElKind.table; }
59
+ get isAuxiliary() { return this.kind > ElKind.note; }
60
60
  get kind() { return this._kind; }
61
61
  set kind(value) {
62
62
  if (value !== this._kind || this.node.stamp >= Number.MAX_SAFE_INTEGER - 1) {
@@ -178,18 +178,18 @@ class CursorPosition {
178
178
  this.y = prev.y;
179
179
  this.runningMaxX = prev.runningMaxX;
180
180
  this.runningMaxY = prev.runningMaxY;
181
- this.flags = prev.flags & ~CursorFlags.OwnCursorPosition;
181
+ this.flags = prev.flags & ~CursorFlags.ownCursorPosition;
182
182
  }
183
183
  }
184
184
  var CursorFlags;
185
185
  (function (CursorFlags) {
186
- CursorFlags[CursorFlags["None"] = 0] = "None";
187
- CursorFlags[CursorFlags["OwnCursorPosition"] = 1] = "OwnCursorPosition";
188
- CursorFlags[CursorFlags["UsesRunningColumnCount"] = 2] = "UsesRunningColumnCount";
189
- CursorFlags[CursorFlags["UsesRunningRowCount"] = 4] = "UsesRunningRowCount";
186
+ CursorFlags[CursorFlags["none"] = 0] = "none";
187
+ CursorFlags[CursorFlags["ownCursorPosition"] = 1] = "ownCursorPosition";
188
+ CursorFlags[CursorFlags["usesRunningColumnCount"] = 2] = "usesRunningColumnCount";
189
+ CursorFlags[CursorFlags["usesRunningRowCount"] = 4] = "usesRunningRowCount";
190
190
  })(CursorFlags || (CursorFlags = {}));
191
191
  const UndefinedElCoords = Object.freeze({ x1: 0, y1: 0, x2: 0, y2: 0 });
192
- const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.None }));
192
+ const InitialCursorPosition = Object.freeze(new CursorPosition({ x: 1, y: 1, runningMaxX: 0, runningMaxY: 0, flags: CursorFlags.none }));
193
193
  function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition, newCursorPosition) {
194
194
  var _a, _b;
195
195
  let result;
@@ -199,7 +199,7 @@ function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition
199
199
  if (newCursorPosition) {
200
200
  newCursorPosition.x = isRegularElement ? result.x2 + 1 : result.x1;
201
201
  newCursorPosition.y = result.y1;
202
- newCursorPosition.flags = CursorFlags.OwnCursorPosition;
202
+ newCursorPosition.flags = CursorFlags.ownCursorPosition;
203
203
  }
204
204
  }
205
205
  else if (newCursorPosition) {
@@ -216,7 +216,7 @@ function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition
216
216
  result = { x1: 0, y1: 0, x2: 0, y2: 0 };
217
217
  if (dx === 0 && isRegularElement) {
218
218
  dx = runningX || 1;
219
- newCursorPosition.flags = CursorFlags.UsesRunningColumnCount;
219
+ newCursorPosition.flags = CursorFlags.usesRunningColumnCount;
220
220
  }
221
221
  if (dx >= 0) {
222
222
  if (isRegularElement) {
@@ -242,7 +242,7 @@ function getEffectiveElCoords(isRegularElement, area, maxX, maxY, cursorPosition
242
242
  }
243
243
  if (dy === 0 && isRegularElement) {
244
244
  dy = runningY || 1;
245
- newCursorPosition.flags |= CursorFlags.UsesRunningRowCount;
245
+ newCursorPosition.flags |= CursorFlags.usesRunningRowCount;
246
246
  }
247
247
  if (dy >= 0) {
248
248
  if (isRegularElement) {
@@ -295,7 +295,7 @@ export class CursorCommand {
295
295
  }
296
296
  export class CursorCommandDriver extends ElDriver {
297
297
  constructor() {
298
- super("cursor", false, el => el.kind = ElKind.Cursor);
298
+ super("cursor", false, el => el.kind = ElKind.cursor);
299
299
  }
300
300
  }
301
301
  export class Apply {
@@ -355,7 +355,7 @@ export class Apply {
355
355
  const hostDriver = bNode.host.driver;
356
356
  if (hostDriver.isPartitionSeparator) {
357
357
  const host = bNode.host.seat.instance;
358
- Apply.elementAlignment(element, Align.ToBounds);
358
+ Apply.elementAlignment(element, Align.toBounds);
359
359
  Apply.heightGrowth(host.element, value);
360
360
  }
361
361
  }
@@ -371,7 +371,7 @@ export class Apply {
371
371
  static contentAlignment(element, value) {
372
372
  if (element.native instanceof HTMLElement) {
373
373
  const s = element.native.style;
374
- if ((value & Align.Default) === 0) {
374
+ if ((value & Align.default) === 0) {
375
375
  const v = AlignToCss[(value >> 2) & 0b11];
376
376
  const h = AlignToCss[value & 0b11];
377
377
  const t = TextAlignCss[value & 0b11];
@@ -386,7 +386,7 @@ export class Apply {
386
386
  static elementAlignment(element, value) {
387
387
  if (element.native instanceof HTMLElement) {
388
388
  const s = element.native.style;
389
- if ((value & Align.Default) === 0) {
389
+ if ((value & Align.default) === 0) {
390
390
  const v = AlignToCss[(value >> 2) & 0b11];
391
391
  const h = AlignToCss[value & 0b11];
392
392
  s.alignSelf = v;
@@ -1,4 +1,4 @@
1
- import { RxNodeDecl, RxNode } from "reactronic";
1
+ import { RxNodeDecl, RxNode, Delegate } from "reactronic";
2
2
  import { El, ElArea } from "./El.js";
3
3
  import { HtmlElementDriver } from "./HtmlDriver.js";
4
4
  export declare function Section<M = unknown>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
@@ -9,7 +9,8 @@ export declare function cursor(areaParams: ElArea): void;
9
9
  export declare function Note(content: string, declaration?: RxNodeDecl<El<HTMLElement, void>>): RxNode<El<HTMLElement, void>>;
10
10
  export declare function HtmlNote(content: string, declaration?: RxNodeDecl<El<HTMLElement, void>>): RxNode<El<HTMLElement, void>>;
11
11
  export declare function Group<M = unknown, R = void>(declaration?: RxNodeDecl<El<HTMLElement, M>>, preset?: RxNodeDecl<El<HTMLElement, M>>): RxNode<El<HTMLElement, M>>;
12
- export declare function PseudoElement<M = unknown>(declaration?: RxNodeDecl<El<void, M>>, preset?: RxNodeDecl<El<void, M>>): RxNode<El<void, M>>;
12
+ export declare function Handler<M = unknown>(update: Delegate<El<void, M>>): RxNode<El<void, M>>;
13
+ export declare function SyntheticElement<M = unknown>(declaration?: RxNodeDecl<El<void, M>>, preset?: RxNodeDecl<El<void, M>>): RxNode<El<void, M>>;
13
14
  export declare class VerstakElementDriver<T extends HTMLElement> extends HtmlElementDriver<T> {
14
15
  update(node: RxNode<El<T>>): void | Promise<void>;
15
16
  }
@@ -1,4 +1,4 @@
1
- import { RxNode } from "reactronic";
1
+ import { RxNode, Mode } from "reactronic";
2
2
  import { Constants, CursorCommandDriver, ElKind, ElDriver } from "./El.js";
3
3
  import { HtmlElementDriver } from "./HtmlDriver.js";
4
4
  export function Section(declaration, preset) {
@@ -38,23 +38,26 @@ export function HtmlNote(content, declaration) {
38
38
  export function Group(declaration, preset) {
39
39
  return RxNode.acquire(Drivers.group, declaration, preset);
40
40
  }
41
- export function PseudoElement(declaration, preset) {
41
+ export function Handler(update) {
42
+ return SyntheticElement({ mode: Mode.independentUpdate, update });
43
+ }
44
+ export function SyntheticElement(declaration, preset) {
42
45
  return RxNode.acquire(Drivers.pseudo, declaration, preset);
43
46
  }
44
47
  export class VerstakElementDriver extends HtmlElementDriver {
45
48
  update(node) {
46
49
  const element = node.element;
47
- if (element.kind === ElKind.Section)
50
+ if (element.kind === ElKind.section)
48
51
  startNewRow();
49
52
  return super.update(node);
50
53
  }
51
54
  }
52
55
  const Drivers = {
53
- section: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.Section),
54
- table: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.Table),
55
- note: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.Note),
56
- group: new VerstakElementDriver(Constants.group, false, el => el.kind = ElKind.Group),
57
- partition: new VerstakElementDriver(Constants.partition, true, el => el.kind = ElKind.Part),
56
+ section: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.section),
57
+ table: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.table),
58
+ note: new VerstakElementDriver(Constants.element, false, el => el.kind = ElKind.note),
59
+ group: new VerstakElementDriver(Constants.group, false, el => el.kind = ElKind.group),
60
+ partition: new VerstakElementDriver(Constants.partition, true, el => el.kind = ElKind.part),
58
61
  cursor: new CursorCommandDriver(),
59
- pseudo: new ElDriver("pseudo", false, el => el.kind = ElKind.Group),
62
+ pseudo: new ElDriver("pseudo", false, el => el.kind = ElKind.group),
60
63
  };
@@ -0,0 +1,6 @@
1
+ import { ToggleRef } from "reactronic";
2
+ import { FocusModel } from "./sensors/FocusSensor.js";
3
+ import { ResizedElement } from "./sensors/ResizeSensor.js";
4
+ export declare function OnClick(target: HTMLElement, action: (() => void) | ToggleRef | undefined, key?: string): void;
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?: FocusModel) => void) | undefined, key?: string): void;
@@ -0,0 +1,55 @@
1
+ import { Mode, ToggleRef, unobs } from "reactronic";
2
+ import { SyntheticElement } from "./Elements.js";
3
+ export function OnClick(target, action, key) {
4
+ if (action !== undefined) {
5
+ SyntheticElement({
6
+ key,
7
+ mode: Mode.independentUpdate,
8
+ triggers: { target },
9
+ update() {
10
+ const pointer = target.sensors.pointer;
11
+ if (pointer.clicked) {
12
+ if (action instanceof Function) {
13
+ unobs(() => action());
14
+ }
15
+ else if (action instanceof ToggleRef) {
16
+ unobs(() => action.toggle());
17
+ }
18
+ }
19
+ },
20
+ });
21
+ }
22
+ }
23
+ export function OnResize(target, action, key) {
24
+ if (action) {
25
+ SyntheticElement({
26
+ key,
27
+ mode: Mode.independentUpdate,
28
+ triggers: { target },
29
+ update() {
30
+ const resize = target.sensors.resize;
31
+ resize.resizedElements.forEach(x => {
32
+ action(x);
33
+ });
34
+ },
35
+ });
36
+ }
37
+ }
38
+ export function OnFocus(target, model, switchEditMode = undefined, key) {
39
+ SyntheticElement({
40
+ key,
41
+ mode: Mode.independentUpdate,
42
+ triggers: { target, model },
43
+ initialize(b) {
44
+ b.node.configureReactronic({ throttling: 0 });
45
+ },
46
+ update() {
47
+ if (switchEditMode !== undefined) {
48
+ switchEditMode(model);
49
+ }
50
+ else {
51
+ model.isEditMode ? target.focus() : target.blur();
52
+ }
53
+ },
54
+ });
55
+ }
@@ -1,6 +1,8 @@
1
1
  import { DataForSensor } from "./sensors/DataForSensor.js";
2
+ import { HtmlSensors } from "./sensors/HtmlSensors.js";
2
3
  declare global {
3
4
  interface Element {
5
+ sensors: HtmlSensors;
4
6
  dataForSensor: DataForSensor;
5
7
  resizeObserver?: ResizeObserver;
6
8
  }
@@ -1,6 +1,16 @@
1
- import { SymDataForSensor, SymResizeObserver } from "./sensors/DataForSensor.js";
1
+ import { SymDataForSensor, SymHtmlSensors, SymResizeObserver } from "./sensors/DataForSensor.js";
2
+ import { HtmlSensors } from "./sensors/HtmlSensors.js";
2
3
  const ElementType = global.Element;
3
4
  if (ElementType !== undefined) {
5
+ Object.defineProperty(ElementType.prototype, "sensors", {
6
+ configurable: false, enumerable: false,
7
+ get() {
8
+ let result = this[SymHtmlSensors];
9
+ if (result === undefined)
10
+ result = this[SymHtmlSensors] = new HtmlSensors(this);
11
+ return result;
12
+ },
13
+ });
4
14
  Object.defineProperty(ElementType.prototype, "dataForSensor", {
5
15
  configurable: false, enumerable: false,
6
16
  get() {