tutuca 0.9.58 → 0.9.59

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.
@@ -3928,6 +3928,7 @@ class Path {
3928
3928
  }
3929
3929
  static fromNodeAndEventName(node, eventName, rootNode, maxDepth, comps, stopOnNoEvent = true) {
3930
3930
  const pathSteps = [];
3931
+ const bubbles = BUBBLING_EVENTS.has(eventName);
3931
3932
  let depth = 0;
3932
3933
  let eventIds = [];
3933
3934
  let handlers = null;
@@ -3941,15 +3942,23 @@ class Path {
3941
3942
  eventIds.push(eid);
3942
3943
  if (cid !== undefined) {
3943
3944
  const comp = comps.getComponentForId(+cid);
3944
- if (isLeafComponent) {
3945
+ let pushStep = true;
3946
+ if (handlers === null && (isLeafComponent || bubbles)) {
3945
3947
  handlers = findHandlers(comp, eventIds, vid, eventName);
3946
- if (handlers === null && stopOnNoEvent)
3947
- return NO_EVENT_INFO;
3948
- isLeafComponent = false;
3948
+ if (handlers === null) {
3949
+ if (isLeafComponent && stopOnNoEvent && !bubbles)
3950
+ return NO_EVENT_INFO;
3951
+ } else if (!isLeafComponent) {
3952
+ pathSteps.length = 0;
3953
+ pushStep = false;
3954
+ }
3955
+ }
3956
+ isLeafComponent = false;
3957
+ if (pushStep) {
3958
+ const step = resolvePathStep(comp, nodeIds, vid);
3959
+ if (step)
3960
+ pathSteps.push(step);
3949
3961
  }
3950
- const step = resolvePathStep(comp, nodeIds, vid);
3951
- if (step)
3952
- pathSteps.push(step);
3953
3962
  eventIds = [];
3954
3963
  nodeIds = [];
3955
3964
  }
@@ -4051,7 +4060,7 @@ class PathBuilder {
4051
4060
  return this.add(new SeqStep(name, key));
4052
4061
  }
4053
4062
  }
4054
- var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, EMPTY_META, NO_EVENT_INFO;
4063
+ var NONE, BindStep, FieldStep, SeqStep, SeqAccessStep, EachBindStep, EachRenderItStep, EMPTY_META, NO_EVENT_INFO, BUBBLING_EVENTS;
4055
4064
  var init_path = __esm(() => {
4056
4065
  NONE = Symbol("NONE");
4057
4066
  BindStep = class BindStep extends Step {
@@ -4161,6 +4170,7 @@ var init_path = __esm(() => {
4161
4170
  };
4162
4171
  EMPTY_META = {};
4163
4172
  NO_EVENT_INFO = [null, null];
4173
+ BUBBLING_EVENTS = new Set(["drop"]);
4164
4174
  });
4165
4175
 
4166
4176
  // src/value.js
@@ -9176,7 +9186,7 @@ class App {
9176
9186
  }
9177
9187
  _dispatchEvent(e) {
9178
9188
  const { type: type3 } = e;
9179
- const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend";
9189
+ const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend" || type3 === "drop";
9180
9190
  const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
9181
9191
  const [path, handlers] = Path.fromEvent(e, root, maxDepth, comps, !isDrag);
9182
9192
  if (isDrag)
@@ -9248,6 +9258,9 @@ class App {
9248
9258
  const dragType = e.target.dataset.dragtype ?? "?";
9249
9259
  const stack = path.buildStack(this.makeStack(rootValue));
9250
9260
  this.dragInfo = new DragInfo(path, stack, e, value, dragType, e.target);
9261
+ } else if (type3 === "drop") {
9262
+ e.preventDefault();
9263
+ this._cleanDragOverAttrs();
9251
9264
  } else {
9252
9265
  if (this.dragInfo !== null) {
9253
9266
  delete this.dragInfo.node.dataset.dragging;
@@ -9285,11 +9298,14 @@ class App {
9285
9298
  }
9286
9299
  this._compiled = true;
9287
9300
  }
9301
+ subscribeToEvents(eventNames) {
9302
+ for (const name of eventNames)
9303
+ this.rootNode.addEventListener(name, this, listenerOpts(name));
9304
+ }
9288
9305
  start(opts) {
9289
9306
  if (!this._compiled)
9290
9307
  this.compile();
9291
- for (const name of this._eventNames)
9292
- this.rootNode.addEventListener(name, this, listenerOpts(name));
9308
+ this.subscribeToEvents(this._eventNames);
9293
9309
  this.onChange((info) => {
9294
9310
  if (info.val !== info.old)
9295
9311
  this.render();
@@ -3481,6 +3481,7 @@ class Path {
3481
3481
  }
3482
3482
  static fromNodeAndEventName(node, eventName, rootNode, maxDepth, comps, stopOnNoEvent = true) {
3483
3483
  const pathSteps = [];
3484
+ const bubbles = BUBBLING_EVENTS.has(eventName);
3484
3485
  let depth = 0;
3485
3486
  let eventIds = [];
3486
3487
  let handlers = null;
@@ -3494,15 +3495,23 @@ class Path {
3494
3495
  eventIds.push(eid);
3495
3496
  if (cid !== undefined) {
3496
3497
  const comp = comps.getComponentForId(+cid);
3497
- if (isLeafComponent) {
3498
+ let pushStep = true;
3499
+ if (handlers === null && (isLeafComponent || bubbles)) {
3498
3500
  handlers = findHandlers(comp, eventIds, vid, eventName);
3499
- if (handlers === null && stopOnNoEvent)
3500
- return NO_EVENT_INFO;
3501
- isLeafComponent = false;
3501
+ if (handlers === null) {
3502
+ if (isLeafComponent && stopOnNoEvent && !bubbles)
3503
+ return NO_EVENT_INFO;
3504
+ } else if (!isLeafComponent) {
3505
+ pathSteps.length = 0;
3506
+ pushStep = false;
3507
+ }
3508
+ }
3509
+ isLeafComponent = false;
3510
+ if (pushStep) {
3511
+ const step = resolvePathStep(comp, nodeIds, vid);
3512
+ if (step)
3513
+ pathSteps.push(step);
3502
3514
  }
3503
- const step = resolvePathStep(comp, nodeIds, vid);
3504
- if (step)
3505
- pathSteps.push(step);
3506
3515
  eventIds = [];
3507
3516
  nodeIds = [];
3508
3517
  }
@@ -3587,6 +3596,7 @@ function resolvePathStep(comp, nodeIds, vid) {
3587
3596
  return null;
3588
3597
  }
3589
3598
  var NO_EVENT_INFO = [null, null];
3599
+ var BUBBLING_EVENTS = new Set(["drop"]);
3590
3600
 
3591
3601
  class PathBuilder {
3592
3602
  constructor() {
@@ -8664,7 +8674,7 @@ class Component {
8664
8674
  }
8665
8675
  }
8666
8676
  make(args, opts) {
8667
- return this.Class.make(args, opts);
8677
+ return this.Class.make(args, opts ?? { scope: this.scope });
8668
8678
  }
8669
8679
  getView(name) {
8670
8680
  return this.views[name] ?? this.views.main;
@@ -9521,7 +9531,7 @@ class App {
9521
9531
  }
9522
9532
  _dispatchEvent(e) {
9523
9533
  const { type: type3 } = e;
9524
- const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend";
9534
+ const isDrag = type3 === "dragover" || type3 === "dragstart" || type3 === "dragend" || type3 === "drop";
9525
9535
  const { rootNode: root, maxEventNodeDepth: maxDepth, comps, transactor } = this;
9526
9536
  const [path, handlers] = Path.fromEvent(e, root, maxDepth, comps, !isDrag);
9527
9537
  if (isDrag)
@@ -9593,6 +9603,9 @@ class App {
9593
9603
  const dragType = e.target.dataset.dragtype ?? "?";
9594
9604
  const stack = path.buildStack(this.makeStack(rootValue));
9595
9605
  this.dragInfo = new DragInfo(path, stack, e, value, dragType, e.target);
9606
+ } else if (type3 === "drop") {
9607
+ e.preventDefault();
9608
+ this._cleanDragOverAttrs();
9596
9609
  } else {
9597
9610
  if (this.dragInfo !== null) {
9598
9611
  delete this.dragInfo.node.dataset.dragging;
@@ -9630,11 +9643,14 @@ class App {
9630
9643
  }
9631
9644
  this._compiled = true;
9632
9645
  }
9646
+ subscribeToEvents(eventNames) {
9647
+ for (const name of eventNames)
9648
+ this.rootNode.addEventListener(name, this, listenerOpts(name));
9649
+ }
9633
9650
  start(opts) {
9634
9651
  if (!this._compiled)
9635
9652
  this.compile();
9636
- for (const name of this._eventNames)
9637
- this.rootNode.addEventListener(name, this, listenerOpts(name));
9653
+ this.subscribeToEvents(this._eventNames);
9638
9654
  this.onChange((info) => {
9639
9655
  if (info.val !== info.old)
9640
9656
  this.render();