phoenix_live_view 1.2.0 → 1.2.2

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 (30) hide show
  1. package/assets/js/phoenix_live_view/dom.ts +3 -1
  2. package/assets/js/phoenix_live_view/dom_patch.ts +1 -1
  3. package/assets/js/phoenix_live_view/live_socket.ts +16 -9
  4. package/assets/js/phoenix_live_view/view.ts +6 -0
  5. package/assets/js/types/assets/js/phoenix_live_view/aria.d.ts +9 -0
  6. package/assets/js/types/assets/js/phoenix_live_view/browser.d.ts +20 -0
  7. package/assets/js/types/assets/js/phoenix_live_view/constants.d.ts +98 -0
  8. package/assets/js/types/assets/js/phoenix_live_view/dom.d.ts +82 -0
  9. package/assets/js/types/assets/js/phoenix_live_view/dom_patch.d.ts +65 -0
  10. package/assets/js/types/assets/js/phoenix_live_view/dom_post_morph_restorer.d.ts +8 -0
  11. package/assets/js/types/assets/js/phoenix_live_view/element_ref.d.ts +14 -0
  12. package/assets/js/types/assets/js/phoenix_live_view/entry_uploader.d.ts +16 -0
  13. package/assets/js/types/assets/js/phoenix_live_view/hooks.d.ts +3 -0
  14. package/assets/js/types/assets/js/phoenix_live_view/index.d.ts +48 -0
  15. package/assets/js/types/assets/js/phoenix_live_view/js.d.ts +99 -0
  16. package/assets/js/types/assets/js/phoenix_live_view/js_commands.d.ts +225 -0
  17. package/assets/js/types/assets/js/phoenix_live_view/live_socket.d.ts +315 -0
  18. package/assets/js/types/assets/js/phoenix_live_view/live_uploader.d.ts +29 -0
  19. package/assets/js/types/assets/js/phoenix_live_view/rendered.d.ts +50 -0
  20. package/assets/js/types/assets/js/phoenix_live_view/upload_entry.d.ts +42 -0
  21. package/assets/js/types/assets/js/phoenix_live_view/utils.d.ts +15 -0
  22. package/assets/js/types/assets/js/phoenix_live_view/view.d.ts +1 -0
  23. package/assets/js/types/assets/js/phoenix_live_view/view_hook.d.ts +279 -0
  24. package/package.json +2 -2
  25. package/priv/static/phoenix_live_view.cjs.js +16 -9
  26. package/priv/static/phoenix_live_view.cjs.js.map +2 -2
  27. package/priv/static/phoenix_live_view.esm.js +16 -9
  28. package/priv/static/phoenix_live_view.esm.js.map +2 -2
  29. package/priv/static/phoenix_live_view.js +16 -9
  30. package/priv/static/phoenix_live_view.min.js +4 -4
@@ -689,7 +689,9 @@ var LiveView = (() => {
689
689
  if (this.once(el, "bind-debounce")) {
690
690
  el.addEventListener("blur", () => {
691
691
  clearTimeout(this.private(el, THROTTLED));
692
- this.triggerCycle(el, DEBOUNCE_TRIGGER);
692
+ if (asyncFilter()) {
693
+ this.triggerCycle(el, DEBOUNCE_TRIGGER);
694
+ }
693
695
  });
694
696
  }
695
697
  }
@@ -2847,7 +2849,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
2847
2849
  transitionPendingRemoves() {
2848
2850
  const { pendingRemoves, liveSocket } = this;
2849
2851
  if (pendingRemoves.length > 0) {
2850
- liveSocket.transitionRemoves(pendingRemoves, () => {
2852
+ liveSocket.transitionRemoves(pendingRemoves, this.view, () => {
2851
2853
  pendingRemoves.forEach((el) => {
2852
2854
  const child = dom_default.firstPhxChild(el);
2853
2855
  if (child) {
@@ -4476,6 +4478,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4476
4478
  if (container) {
4477
4479
  const [tag, attrs] = container;
4478
4480
  this.el = dom_default.replaceRootContainer(this.el, tag, attrs);
4481
+ dom_default.putPrivate(this.el, "view", this);
4479
4482
  }
4480
4483
  this.childJoins = 0;
4481
4484
  this.joinPending = true;
@@ -4562,6 +4565,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4562
4565
  throw new Error("unable to find root element for view");
4563
4566
  }
4564
4567
  this.el = el;
4568
+ dom_default.putPrivate(this.el, "view", this);
4565
4569
  this.el.setAttribute(PHX_ROOT_ID, this.root.id);
4566
4570
  }
4567
4571
  // this is invoked for dead and live views, so we must filter by
@@ -4752,6 +4756,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
4752
4756
  rootEl.setAttribute(PHX_SESSION, this.getSession());
4753
4757
  rootEl.setAttribute(PHX_STATIC, (_a = this.getStatic()) != null ? _a : "");
4754
4758
  this.parent && rootEl.setAttribute(PHX_PARENT_ID, this.parent.id);
4759
+ dom_default.putPrivate(rootEl, "view", this);
4755
4760
  const formsToRecover = (
4756
4761
  // we go over all forms in the new DOM; because this is only the HTML for the current
4757
4762
  // view, we can be sure that all forms are owned by this view:
@@ -6112,7 +6117,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6112
6117
  * Returns the version of the LiveView client.
6113
6118
  */
6114
6119
  version() {
6115
- return "1.2.0";
6120
+ return "1.2.2";
6116
6121
  }
6117
6122
  /**
6118
6123
  * Returns true if profiling is enabled. See {@link enableProfiling} and {@link disableProfiling}.
@@ -6466,11 +6471,12 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6466
6471
  `[${this.binding("remove")}]`
6467
6472
  ).filter((el) => !dom_default.isChildOfAny(el, stickies));
6468
6473
  const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
6469
- this.main.showLoader(this.loaderTimeout);
6470
- this.main.destroy();
6474
+ const oldMainView = this.main;
6475
+ oldMainView.showLoader(this.loaderTimeout);
6476
+ oldMainView.destroy();
6471
6477
  this.main = this.newRootView(newMainEl, flash, liveReferer);
6472
6478
  this.main.setRedirect(href);
6473
- this.transitionRemoves(removeEls);
6479
+ this.transitionRemoves(removeEls, oldMainView);
6474
6480
  this.main.join((joinCount, onDone) => {
6475
6481
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
6476
6482
  this.requestDOMUpdate(() => {
@@ -6485,7 +6491,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6485
6491
  });
6486
6492
  }
6487
6493
  /** @internal */
6488
- transitionRemoves(elements, callback) {
6494
+ transitionRemoves(elements, view, callback) {
6489
6495
  const removeAttr = this.binding("remove");
6490
6496
  const silenceEvents = (e) => {
6491
6497
  e.preventDefault();
@@ -6495,7 +6501,8 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6495
6501
  for (const event of this.boundEventNames) {
6496
6502
  el.addEventListener(event, silenceEvents, true);
6497
6503
  }
6498
- this.execJS(el, el.getAttribute(removeAttr), "remove");
6504
+ const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
6505
+ js_default.exec(e, "remove", el.getAttribute(removeAttr), view, el);
6499
6506
  });
6500
6507
  this.requestDOMUpdate(() => {
6501
6508
  elements.forEach((el) => {
@@ -6521,7 +6528,7 @@ removing illegal node: "${("outerHTML" in childNode && childNode.outerHTML || ch
6521
6528
  let view;
6522
6529
  const viewEl = dom_default.closestViewEl(childEl);
6523
6530
  if (viewEl) {
6524
- view = this.getViewByEl(viewEl);
6531
+ view = dom_default.private(viewEl, "view");
6525
6532
  } else {
6526
6533
  if (!childEl.isConnected) {
6527
6534
  return null;