bard-attachment_field 0.6.5 → 0.6.6
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa5230e35acbf0f53cec473a5f38fe446d61b5bcd53fc3582671ac6cb6eee2d8
|
|
4
|
+
data.tar.gz: ce72ba7c879890dd9a587e858c4f6e895f961d3adf47353bc9f06a4d301dc441
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a51d0f59a8683147ac2c33f21890a1ecb9663935823a5e61ea93b15f7f5001465e308e4993ee38e89cea814476a75793968bfd571a69ea9759e9fab9b430d47
|
|
7
|
+
data.tar.gz: ab279c90963b58f1a25389662f6ea49267597ced211b67559278c42e0efda6345f0583a5b365be46d29595cfe0b04f5a3182d490b5019aba33e574a4823f6d6c
|
|
@@ -5043,15 +5043,16 @@ var o2 = class _o {
|
|
|
5043
5043
|
element;
|
|
5044
5044
|
controllers;
|
|
5045
5045
|
submitted;
|
|
5046
|
+
submitter;
|
|
5046
5047
|
processing;
|
|
5047
5048
|
constructor(t2, { uploadDialog: e3 = true } = {}) {
|
|
5048
|
-
this.element = t2, this.controllers = [], this.submitted = false, this.processing = false, e3 && (this.dialog = document.createElement("upload-dialog"), this.dialog.id = "form-controller-dialog", this.element.appendChild(this.dialog)), this.element.addEventListener("submit", ((t3) => this.submit(t3))), window.addEventListener("beforeunload", ((t3) => this.beforeUnload(t3))), this.element.addEventListener("direct-upload:initialize", ((t3) => this.init(t3))), this.element.addEventListener("direct-upload:start", ((t3) => this.start(t3))), this.element.addEventListener("direct-upload:progress", ((t3) => this.progress(t3))), this.element.addEventListener("direct-upload:error", ((t3) => this.error(t3))), this.element.addEventListener("direct-upload:end", ((t3) => this.end(t3))), this.element.addEventListener("attachment-file:remove", ((t3) => this.removeUploadedFile(t3)));
|
|
5049
|
+
this.element = t2, this.controllers = [], this.submitted = false, this.processing = false, e3 && (this.dialog = document.createElement("upload-dialog"), this.dialog.id = "form-controller-dialog", this.element.appendChild(this.dialog)), this.element.addEventListener("submit", ((t3) => this.submit(t3)), { capture: true }), window.addEventListener("beforeunload", ((t3) => this.beforeUnload(t3))), this.element.addEventListener("direct-upload:initialize", ((t3) => this.init(t3))), this.element.addEventListener("direct-upload:start", ((t3) => this.start(t3))), this.element.addEventListener("direct-upload:progress", ((t3) => this.progress(t3))), this.element.addEventListener("direct-upload:error", ((t3) => this.error(t3))), this.element.addEventListener("direct-upload:end", ((t3) => this.end(t3))), this.element.addEventListener("attachment-file:remove", ((t3) => this.removeUploadedFile(t3)));
|
|
5049
5050
|
}
|
|
5050
5051
|
beforeUnload(t2) {
|
|
5051
5052
|
if (this.processing) return t2.preventDefault(), t2.returnValue = "";
|
|
5052
5053
|
}
|
|
5053
5054
|
submit(t2) {
|
|
5054
|
-
(0 !== this.controllers.length || this.hasUploadErrors() || this.processing) && (t2.preventDefault(), this.submitted = true, this.setInputAttachmentsDisabled(true), this.startNextController(), this.processing && this.dialog?.open());
|
|
5055
|
+
(0 !== this.controllers.length || this.hasUploadErrors() || this.processing) && (t2.preventDefault(), t2.stopImmediatePropagation(), this.submitted = true, this.submitter = t2.submitter, this.setInputAttachmentsDisabled(true), this.startNextController(), this.processing && this.dialog?.open());
|
|
5055
5056
|
}
|
|
5056
5057
|
startNextController() {
|
|
5057
5058
|
if (this.processing) return;
|
|
@@ -5067,7 +5068,7 @@ var o2 = class _o {
|
|
|
5067
5068
|
if (this.submitted) {
|
|
5068
5069
|
if (this.hasUploadErrors()) return this.dialog?.close(), void this.setInputAttachmentsDisabled(false);
|
|
5069
5070
|
this.setInputAttachmentsDisabled(true), requestAnimationFrame((() => {
|
|
5070
|
-
this.element.
|
|
5071
|
+
this.submitted = false, this.setInputAttachmentsDisabled(false), this.dialog?.close(), this.element.requestSubmit(this.submitter);
|
|
5071
5072
|
}));
|
|
5072
5073
|
}
|
|
5073
5074
|
}
|
|
@@ -11,6 +11,7 @@ export default class FormController {
|
|
|
11
11
|
element: HTMLFormElement
|
|
12
12
|
controllers: Array<DirectUploadController>
|
|
13
13
|
submitted: boolean
|
|
14
|
+
submitter: HTMLElement | null
|
|
14
15
|
processing: boolean
|
|
15
16
|
|
|
16
17
|
constructor(form, { uploadDialog = true } = {}) {
|
|
@@ -25,7 +26,7 @@ export default class FormController {
|
|
|
25
26
|
this.element.appendChild(this.dialog)
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
this.element.addEventListener("submit", event => this.submit(event))
|
|
29
|
+
this.element.addEventListener("submit", event => this.submit(event), { capture: true })
|
|
29
30
|
window.addEventListener("beforeunload", event => this.beforeUnload(event))
|
|
30
31
|
|
|
31
32
|
this.element.addEventListener("direct-upload:initialize", event => this.init(event))
|
|
@@ -47,7 +48,9 @@ export default class FormController {
|
|
|
47
48
|
submit(event) {
|
|
48
49
|
if(this.controllers.length === 0 && !this.hasUploadErrors() && !this.processing) return
|
|
49
50
|
event.preventDefault()
|
|
51
|
+
event.stopImmediatePropagation() // the held submit isn't the real one; listeners see the replay instead
|
|
50
52
|
this.submitted = true
|
|
53
|
+
this.submitter = event.submitter
|
|
51
54
|
this.setInputAttachmentsDisabled(true)
|
|
52
55
|
this.startNextController()
|
|
53
56
|
if(this.processing) {
|
|
@@ -96,7 +99,11 @@ export default class FormController {
|
|
|
96
99
|
}
|
|
97
100
|
this.setInputAttachmentsDisabled(true)
|
|
98
101
|
requestAnimationFrame(() => { // run after pending rAF callbacks (e.g. updateFormValue)
|
|
99
|
-
this.
|
|
102
|
+
this.submitted = false
|
|
103
|
+
this.setInputAttachmentsDisabled(false)
|
|
104
|
+
;(this.dialog as any)?.close()
|
|
105
|
+
// replay through the submit event, so Turbo handles it like the original
|
|
106
|
+
this.element.requestSubmit(this.submitter)
|
|
100
107
|
})
|
|
101
108
|
}
|
|
102
109
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bard-attachment_field
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activestorage
|