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
@@ -642,7 +642,9 @@ var DOM = {
642
642
  if (this.once(el, "bind-debounce")) {
643
643
  el.addEventListener("blur", () => {
644
644
  clearTimeout(this.private(el, THROTTLED));
645
- this.triggerCycle(el, DEBOUNCE_TRIGGER);
645
+ if (asyncFilter()) {
646
+ this.triggerCycle(el, DEBOUNCE_TRIGGER);
647
+ }
646
648
  });
647
649
  }
648
650
  }
@@ -2796,7 +2798,7 @@ var DOMPatch = class {
2796
2798
  transitionPendingRemoves() {
2797
2799
  const { pendingRemoves, liveSocket } = this;
2798
2800
  if (pendingRemoves.length > 0) {
2799
- liveSocket.transitionRemoves(pendingRemoves, () => {
2801
+ liveSocket.transitionRemoves(pendingRemoves, this.view, () => {
2800
2802
  pendingRemoves.forEach((el) => {
2801
2803
  const child = dom_default.firstPhxChild(el);
2802
2804
  if (child) {
@@ -4424,6 +4426,7 @@ var View = class _View {
4424
4426
  if (container) {
4425
4427
  const [tag, attrs] = container;
4426
4428
  this.el = dom_default.replaceRootContainer(this.el, tag, attrs);
4429
+ dom_default.putPrivate(this.el, "view", this);
4427
4430
  }
4428
4431
  this.childJoins = 0;
4429
4432
  this.joinPending = true;
@@ -4510,6 +4513,7 @@ var View = class _View {
4510
4513
  throw new Error("unable to find root element for view");
4511
4514
  }
4512
4515
  this.el = el;
4516
+ dom_default.putPrivate(this.el, "view", this);
4513
4517
  this.el.setAttribute(PHX_ROOT_ID, this.root.id);
4514
4518
  }
4515
4519
  // this is invoked for dead and live views, so we must filter by
@@ -4698,6 +4702,7 @@ var View = class _View {
4698
4702
  rootEl.setAttribute(PHX_SESSION, this.getSession());
4699
4703
  rootEl.setAttribute(PHX_STATIC, this.getStatic() ?? "");
4700
4704
  this.parent && rootEl.setAttribute(PHX_PARENT_ID, this.parent.id);
4705
+ dom_default.putPrivate(rootEl, "view", this);
4701
4706
  const formsToRecover = (
4702
4707
  // we go over all forms in the new DOM; because this is only the HTML for the current
4703
4708
  // view, we can be sure that all forms are owned by this view:
@@ -6060,7 +6065,7 @@ var LiveSocket = class {
6060
6065
  * Returns the version of the LiveView client.
6061
6066
  */
6062
6067
  version() {
6063
- return "1.2.0";
6068
+ return "1.2.2";
6064
6069
  }
6065
6070
  /**
6066
6071
  * Returns true if profiling is enabled. See {@link enableProfiling} and {@link disableProfiling}.
@@ -6413,11 +6418,12 @@ var LiveSocket = class {
6413
6418
  `[${this.binding("remove")}]`
6414
6419
  ).filter((el) => !dom_default.isChildOfAny(el, stickies));
6415
6420
  const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
6416
- this.main.showLoader(this.loaderTimeout);
6417
- this.main.destroy();
6421
+ const oldMainView = this.main;
6422
+ oldMainView.showLoader(this.loaderTimeout);
6423
+ oldMainView.destroy();
6418
6424
  this.main = this.newRootView(newMainEl, flash, liveReferer);
6419
6425
  this.main.setRedirect(href);
6420
- this.transitionRemoves(removeEls);
6426
+ this.transitionRemoves(removeEls, oldMainView);
6421
6427
  this.main.join((joinCount, onDone) => {
6422
6428
  if (joinCount === 1 && this.commitPendingLink(linkRef)) {
6423
6429
  this.requestDOMUpdate(() => {
@@ -6432,7 +6438,7 @@ var LiveSocket = class {
6432
6438
  });
6433
6439
  }
6434
6440
  /** @internal */
6435
- transitionRemoves(elements, callback) {
6441
+ transitionRemoves(elements, view, callback) {
6436
6442
  const removeAttr = this.binding("remove");
6437
6443
  const silenceEvents = (e) => {
6438
6444
  e.preventDefault();
@@ -6442,7 +6448,8 @@ var LiveSocket = class {
6442
6448
  for (const event of this.boundEventNames) {
6443
6449
  el.addEventListener(event, silenceEvents, true);
6444
6450
  }
6445
- this.execJS(el, el.getAttribute(removeAttr), "remove");
6451
+ const e = new CustomEvent("phx:exec", { detail: { sourceElement: el } });
6452
+ js_default.exec(e, "remove", el.getAttribute(removeAttr), view, el);
6446
6453
  });
6447
6454
  this.requestDOMUpdate(() => {
6448
6455
  elements.forEach((el) => {
@@ -6468,7 +6475,7 @@ var LiveSocket = class {
6468
6475
  let view;
6469
6476
  const viewEl = dom_default.closestViewEl(childEl);
6470
6477
  if (viewEl) {
6471
- view = this.getViewByEl(viewEl);
6478
+ view = dom_default.private(viewEl, "view");
6472
6479
  } else {
6473
6480
  if (!childEl.isConnected) {
6474
6481
  return null;