Merge branch 'main' into delete-account-improvements

This commit is contained in:
Alexander Zaytsev
2026-03-19 15:26:31 +01:00
331 changed files with 8082 additions and 2471 deletions
@@ -0,0 +1,44 @@
import { BridgeComponent } from "@hotwired/hotwire-native-bridge"
export default class extends BridgeComponent {
static component = "stamp"
static values = { scopeSelector: { type: String, default: "body" } }
connect() {
super.connect()
if (this.element.closest(this.scopeSelectorValue)) {
this.notifyBridgeOfConnect()
this.#observeStamp()
}
}
disconnect() {
super.disconnect()
this.notifyBridgeOfDisconnect()
this.stampObserver?.disconnect()
}
notifyBridgeOfConnect() {
const bridgeElement = this.bridgeElement
this.send("connect", {
title: bridgeElement.title,
description: bridgeElement.bridgeAttribute("description")
})
}
notifyBridgeOfDisconnect() {
this.send("disconnect")
}
#observeStamp() {
this.stampObserver = new MutationObserver(() => {
this.notifyBridgeOfConnect()
})
this.stampObserver.observe(this.element, {
attributes: true
})
}
}
@@ -0,0 +1,8 @@
import { Controller } from "@hotwired/stimulus"
import { Turbo } from "@hotwired/turbo-rails"
export default class extends Controller {
clearCache() {
Turbo.offline.clearCache()
}
}
@@ -15,7 +15,7 @@ export default class extends Controller {
submit() {
if (this.inputTarget.disabled) return
this.element.submit()
this.element.requestSubmit()
this.inputTarget.disabled = true
}
}
@@ -1,8 +1,12 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { label: String }
static targets = [ "referrerBackLink" ]
rememberLocation() {
sessionStorage.setItem("referrerUrl", window.location.href)
sessionStorage.setItem("referrerLabel", this.labelValue)
}
backIfSamePath(event) {
@@ -16,6 +20,20 @@ export default class extends Controller {
Turbo.visit(this.#referrerUrl)
}
}
referrerBackLinkTargetConnected(link) {
if (!this.#referrerUrl || !this.#referrerLabel) { return }
const stripTrailingSlash = path => path.replace(/\/$/, "")
const allowedPaths = (link.dataset.turboNavigationAllowedReferrerPaths || "").split(",").map(stripTrailingSlash)
const referrerPath = stripTrailingSlash(new URL(this.#referrerUrl).pathname)
if (!allowedPaths.includes(referrerPath)) { return }
link.href = this.#referrerUrl
const strong = link.querySelector("strong")
if (strong) { strong.textContent = `Back to ${this.#referrerLabel}` }
}
get #referrerPath() {
if (!this.#referrerUrl) return null
return new URL(this.#referrerUrl).pathname
@@ -24,4 +42,8 @@ export default class extends Controller {
get #referrerUrl() {
return sessionStorage.getItem("referrerUrl")
}
get #referrerLabel() {
return sessionStorage.getItem("referrerLabel")
}
}
@@ -15,7 +15,7 @@ export default class extends Controller {
}
#showFileName() {
this.fileNameTarget.innerHTML = this.#file.name
this.fileNameTarget.innerText = this.#file.name
this.fileNameTarget.removeAttribute("hidden")
this.placeholderTarget.setAttribute("hidden", true)
}