phoenix_live_view 1.0.3 → 1.0.4
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.
- package/assets/js/phoenix_live_view/dom_patch.js +1 -1
- package/assets/js/phoenix_live_view/hooks.js +6 -3
- package/assets/js/phoenix_live_view/js.js +9 -13
- package/assets/js/phoenix_live_view/live_socket.js +15 -11
- package/package.json +1 -1
- package/priv/static/phoenix_live_view.cjs.js +29 -30
- package/priv/static/phoenix_live_view.cjs.js.map +3 -3
- package/priv/static/phoenix_live_view.esm.js +29 -30
- package/priv/static/phoenix_live_view.esm.js.map +3 -3
- package/priv/static/phoenix_live_view.js +29 -30
- package/priv/static/phoenix_live_view.min.js +4 -4
|
@@ -433,7 +433,7 @@ export default class DOMPatch {
|
|
|
433
433
|
transitionPendingRemoves(){
|
|
434
434
|
let {pendingRemoves, liveSocket} = this
|
|
435
435
|
if(pendingRemoves.length > 0){
|
|
436
|
-
liveSocket.transitionRemoves(pendingRemoves,
|
|
436
|
+
liveSocket.transitionRemoves(pendingRemoves, () => {
|
|
437
437
|
pendingRemoves.forEach(el => {
|
|
438
438
|
let child = DOM.firstPhxChild(el)
|
|
439
439
|
if(child){ liveSocket.destroyViewByEl(child) }
|
|
@@ -67,9 +67,12 @@ let Hooks = {
|
|
|
67
67
|
ARIA.focusFirst(this.el)
|
|
68
68
|
}
|
|
69
69
|
})
|
|
70
|
-
|
|
71
|
-
if(
|
|
72
|
-
|
|
70
|
+
// only try to change the focus if it is not already inside
|
|
71
|
+
if(!this.el.contains(document.activeElement)){
|
|
72
|
+
this.el.addEventListener("phx:show-end", () => this.el.focus())
|
|
73
|
+
if(window.getComputedStyle(this.el).display !== "none"){
|
|
74
|
+
ARIA.focusFirst(this.el)
|
|
75
|
+
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -97,11 +97,11 @@ let JS = {
|
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
exec_focus(e, eventType, phxEvent, view, sourceEl, el){
|
|
100
|
-
|
|
100
|
+
ARIA.attemptFocus(el)
|
|
101
101
|
},
|
|
102
102
|
|
|
103
103
|
exec_focus_first(e, eventType, phxEvent, view, sourceEl, el){
|
|
104
|
-
|
|
104
|
+
ARIA.focusFirstInteractive(el) || ARIA.focusFirst(el)
|
|
105
105
|
},
|
|
106
106
|
|
|
107
107
|
exec_push_focus(e, eventType, phxEvent, view, sourceEl, el){
|
|
@@ -219,18 +219,14 @@ let JS = {
|
|
|
219
219
|
}
|
|
220
220
|
} else {
|
|
221
221
|
if(this.isVisible(el)){
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
el.dispatchEvent(new Event("phx:hide-end"))
|
|
226
|
-
})
|
|
222
|
+
el.dispatchEvent(new Event("phx:hide-start"))
|
|
223
|
+
DOM.putSticky(el, "toggle", currentEl => currentEl.style.display = "none")
|
|
224
|
+
el.dispatchEvent(new Event("phx:hide-end"))
|
|
227
225
|
} else {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
el.dispatchEvent(new Event("phx:show-end"))
|
|
233
|
-
})
|
|
226
|
+
el.dispatchEvent(new Event("phx:show-start"))
|
|
227
|
+
let stickyDisplay = display || this.defaultDisplay(el)
|
|
228
|
+
DOM.putSticky(el, "toggle", currentEl => currentEl.style.display = stickyDisplay)
|
|
229
|
+
el.dispatchEvent(new Event("phx:show-end"))
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
},
|
|
@@ -393,22 +393,26 @@ export default class LiveSocket {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
replaceMain(href, flash, callback = null, linkRef = this.setPendingLink(href)){
|
|
396
|
-
|
|
396
|
+
const liveReferer = this.currentLocation.href
|
|
397
397
|
this.outgoingMainEl = this.outgoingMainEl || this.main.el
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
|
|
399
|
+
const stickies = DOM.findPhxSticky(document) || []
|
|
400
|
+
const removeEls = DOM.all(this.outgoingMainEl, `[${this.binding("remove")}]`)
|
|
401
|
+
.filter(el => !DOM.isChildOfAny(el, stickies))
|
|
402
|
+
|
|
403
|
+
const newMainEl = DOM.cloneNode(this.outgoingMainEl, "")
|
|
400
404
|
this.main.showLoader(this.loaderTimeout)
|
|
401
405
|
this.main.destroy()
|
|
402
406
|
|
|
403
407
|
this.main = this.newRootView(newMainEl, flash, liveReferer)
|
|
404
408
|
this.main.setRedirect(href)
|
|
405
|
-
this.transitionRemoves(removeEls
|
|
409
|
+
this.transitionRemoves(removeEls)
|
|
406
410
|
this.main.join((joinCount, onDone) => {
|
|
407
411
|
if(joinCount === 1 && this.commitPendingLink(linkRef)){
|
|
408
412
|
this.requestDOMUpdate(() => {
|
|
409
413
|
// remove phx-remove els right before we replace the main element
|
|
410
414
|
removeEls.forEach(el => el.remove())
|
|
411
|
-
|
|
415
|
+
stickies.forEach(el => newMainEl.appendChild(el))
|
|
412
416
|
this.outgoingMainEl.replaceWith(newMainEl)
|
|
413
417
|
this.outgoingMainEl = null
|
|
414
418
|
callback && callback(linkRef)
|
|
@@ -418,12 +422,8 @@ export default class LiveSocket {
|
|
|
418
422
|
})
|
|
419
423
|
}
|
|
420
424
|
|
|
421
|
-
transitionRemoves(elements,
|
|
425
|
+
transitionRemoves(elements, callback){
|
|
422
426
|
let removeAttr = this.binding("remove")
|
|
423
|
-
if(skipSticky){
|
|
424
|
-
const stickies = DOM.findPhxSticky(document) || []
|
|
425
|
-
elements = elements.filter(el => !DOM.isChildOfAny(el, stickies))
|
|
426
|
-
}
|
|
427
427
|
let silenceEvents = (e) => {
|
|
428
428
|
e.preventDefault()
|
|
429
429
|
e.stopImmediatePropagation()
|
|
@@ -800,7 +800,8 @@ export default class LiveSocket {
|
|
|
800
800
|
}
|
|
801
801
|
|
|
802
802
|
historyRedirect(e, href, linkState, flash, targetEl){
|
|
803
|
-
|
|
803
|
+
const clickLoading = targetEl && e.isTrusted && e.type !== "popstate"
|
|
804
|
+
if(clickLoading){ targetEl.classList.add("phx-click-loading") }
|
|
804
805
|
if(!this.isConnected() || !this.main.isMain()){ return Browser.redirect(href, flash) }
|
|
805
806
|
|
|
806
807
|
// convert to full href if only path prefix
|
|
@@ -829,6 +830,9 @@ export default class LiveSocket {
|
|
|
829
830
|
DOM.dispatchEvent(window, "phx:navigate", {detail: {href, patch: false, pop: false, direction: "forward"}})
|
|
830
831
|
this.registerNewLocation(window.location)
|
|
831
832
|
}
|
|
833
|
+
// explicitly undo click-loading class
|
|
834
|
+
// (in case it originated in a sticky live view, otherwise it would be removed anyway)
|
|
835
|
+
if(clickLoading){ targetEl.classList.remove("phx-click-loading") }
|
|
832
836
|
done()
|
|
833
837
|
})
|
|
834
838
|
})
|
package/package.json
CHANGED
|
@@ -1166,9 +1166,11 @@ var Hooks = {
|
|
|
1166
1166
|
aria_default.focusFirst(this.el);
|
|
1167
1167
|
}
|
|
1168
1168
|
});
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1169
|
+
if (!this.el.contains(document.activeElement)) {
|
|
1170
|
+
this.el.addEventListener("phx:show-end", () => this.el.focus());
|
|
1171
|
+
if (window.getComputedStyle(this.el).display !== "none") {
|
|
1172
|
+
aria_default.focusFirst(this.el);
|
|
1173
|
+
}
|
|
1172
1174
|
}
|
|
1173
1175
|
}
|
|
1174
1176
|
}
|
|
@@ -1466,7 +1468,7 @@ var DOMPostMorphRestorer = class {
|
|
|
1466
1468
|
}
|
|
1467
1469
|
};
|
|
1468
1470
|
|
|
1469
|
-
// node_modules/morphdom/dist/morphdom-esm.js
|
|
1471
|
+
// ../node_modules/morphdom/dist/morphdom-esm.js
|
|
1470
1472
|
var DOCUMENT_FRAGMENT_NODE = 11;
|
|
1471
1473
|
function morphAttrs(fromNode, toNode) {
|
|
1472
1474
|
var toNodeAttrs = toNode.attributes;
|
|
@@ -2343,7 +2345,7 @@ var DOMPatch = class {
|
|
|
2343
2345
|
transitionPendingRemoves() {
|
|
2344
2346
|
let { pendingRemoves, liveSocket } = this;
|
|
2345
2347
|
if (pendingRemoves.length > 0) {
|
|
2346
|
-
liveSocket.transitionRemoves(pendingRemoves,
|
|
2348
|
+
liveSocket.transitionRemoves(pendingRemoves, () => {
|
|
2347
2349
|
pendingRemoves.forEach((el) => {
|
|
2348
2350
|
let child = dom_default.firstPhxChild(el);
|
|
2349
2351
|
if (child) {
|
|
@@ -2803,10 +2805,10 @@ var JS = {
|
|
|
2803
2805
|
view.liveSocket.pushHistoryPatch(e, href, replace ? "replace" : "push", sourceEl);
|
|
2804
2806
|
},
|
|
2805
2807
|
exec_focus(e, eventType, phxEvent, view, sourceEl, el) {
|
|
2806
|
-
|
|
2808
|
+
aria_default.attemptFocus(el);
|
|
2807
2809
|
},
|
|
2808
2810
|
exec_focus_first(e, eventType, phxEvent, view, sourceEl, el) {
|
|
2809
|
-
|
|
2811
|
+
aria_default.focusFirstInteractive(el) || aria_default.focusFirst(el);
|
|
2810
2812
|
},
|
|
2811
2813
|
exec_push_focus(e, eventType, phxEvent, view, sourceEl, el) {
|
|
2812
2814
|
window.requestAnimationFrame(() => focusStack.push(el || sourceEl));
|
|
@@ -2912,18 +2914,14 @@ var JS = {
|
|
|
2912
2914
|
}
|
|
2913
2915
|
} else {
|
|
2914
2916
|
if (this.isVisible(el)) {
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
el.dispatchEvent(new Event("phx:hide-end"));
|
|
2919
|
-
});
|
|
2917
|
+
el.dispatchEvent(new Event("phx:hide-start"));
|
|
2918
|
+
dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = "none");
|
|
2919
|
+
el.dispatchEvent(new Event("phx:hide-end"));
|
|
2920
2920
|
} else {
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
el.dispatchEvent(new Event("phx:show-end"));
|
|
2926
|
-
});
|
|
2921
|
+
el.dispatchEvent(new Event("phx:show-start"));
|
|
2922
|
+
let stickyDisplay = display || this.defaultDisplay(el);
|
|
2923
|
+
dom_default.putSticky(el, "toggle", (currentEl) => currentEl.style.display = stickyDisplay);
|
|
2924
|
+
el.dispatchEvent(new Event("phx:show-end"));
|
|
2927
2925
|
}
|
|
2928
2926
|
}
|
|
2929
2927
|
},
|
|
@@ -4767,7 +4765,7 @@ var LiveSocket = class {
|
|
|
4767
4765
|
}
|
|
4768
4766
|
// public
|
|
4769
4767
|
version() {
|
|
4770
|
-
return "1.0.
|
|
4768
|
+
return "1.0.4";
|
|
4771
4769
|
}
|
|
4772
4770
|
isProfileEnabled() {
|
|
4773
4771
|
return this.sessionStorage.getItem(PHX_LV_PROFILE) === "true";
|
|
@@ -4984,20 +4982,21 @@ var LiveSocket = class {
|
|
|
4984
4982
|
browser_default.redirect(to, flash);
|
|
4985
4983
|
}
|
|
4986
4984
|
replaceMain(href, flash, callback = null, linkRef = this.setPendingLink(href)) {
|
|
4987
|
-
|
|
4985
|
+
const liveReferer = this.currentLocation.href;
|
|
4988
4986
|
this.outgoingMainEl = this.outgoingMainEl || this.main.el;
|
|
4989
|
-
|
|
4990
|
-
|
|
4987
|
+
const stickies = dom_default.findPhxSticky(document) || [];
|
|
4988
|
+
const removeEls = dom_default.all(this.outgoingMainEl, `[${this.binding("remove")}]`).filter((el) => !dom_default.isChildOfAny(el, stickies));
|
|
4989
|
+
const newMainEl = dom_default.cloneNode(this.outgoingMainEl, "");
|
|
4991
4990
|
this.main.showLoader(this.loaderTimeout);
|
|
4992
4991
|
this.main.destroy();
|
|
4993
4992
|
this.main = this.newRootView(newMainEl, flash, liveReferer);
|
|
4994
4993
|
this.main.setRedirect(href);
|
|
4995
|
-
this.transitionRemoves(removeEls
|
|
4994
|
+
this.transitionRemoves(removeEls);
|
|
4996
4995
|
this.main.join((joinCount, onDone) => {
|
|
4997
4996
|
if (joinCount === 1 && this.commitPendingLink(linkRef)) {
|
|
4998
4997
|
this.requestDOMUpdate(() => {
|
|
4999
4998
|
removeEls.forEach((el) => el.remove());
|
|
5000
|
-
|
|
4999
|
+
stickies.forEach((el) => newMainEl.appendChild(el));
|
|
5001
5000
|
this.outgoingMainEl.replaceWith(newMainEl);
|
|
5002
5001
|
this.outgoingMainEl = null;
|
|
5003
5002
|
callback && callback(linkRef);
|
|
@@ -5006,12 +5005,8 @@ var LiveSocket = class {
|
|
|
5006
5005
|
}
|
|
5007
5006
|
});
|
|
5008
5007
|
}
|
|
5009
|
-
transitionRemoves(elements,
|
|
5008
|
+
transitionRemoves(elements, callback) {
|
|
5010
5009
|
let removeAttr = this.binding("remove");
|
|
5011
|
-
if (skipSticky) {
|
|
5012
|
-
const stickies = dom_default.findPhxSticky(document) || [];
|
|
5013
|
-
elements = elements.filter((el) => !dom_default.isChildOfAny(el, stickies));
|
|
5014
|
-
}
|
|
5015
5010
|
let silenceEvents = (e) => {
|
|
5016
5011
|
e.preventDefault();
|
|
5017
5012
|
e.stopImmediatePropagation();
|
|
@@ -5371,7 +5366,8 @@ var LiveSocket = class {
|
|
|
5371
5366
|
this.registerNewLocation(window.location);
|
|
5372
5367
|
}
|
|
5373
5368
|
historyRedirect(e, href, linkState, flash, targetEl) {
|
|
5374
|
-
|
|
5369
|
+
const clickLoading = targetEl && e.isTrusted && e.type !== "popstate";
|
|
5370
|
+
if (clickLoading) {
|
|
5375
5371
|
targetEl.classList.add("phx-click-loading");
|
|
5376
5372
|
}
|
|
5377
5373
|
if (!this.isConnected() || !this.main.isMain()) {
|
|
@@ -5397,6 +5393,9 @@ var LiveSocket = class {
|
|
|
5397
5393
|
dom_default.dispatchEvent(window, "phx:navigate", { detail: { href, patch: false, pop: false, direction: "forward" } });
|
|
5398
5394
|
this.registerNewLocation(window.location);
|
|
5399
5395
|
}
|
|
5396
|
+
if (clickLoading) {
|
|
5397
|
+
targetEl.classList.remove("phx-click-loading");
|
|
5398
|
+
}
|
|
5400
5399
|
done();
|
|
5401
5400
|
});
|
|
5402
5401
|
});
|