bard-attachment_field 0.2.2 → 0.2.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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/input-attachment.js +10 -4
- data/input-attachment/src/components/attachment-file/attachment-file.tsx +2 -0
- data/input-attachment/src/components/attachment-file/readme.md +1 -0
- data/input-attachment/src/components/input-attachment/input-attachment.tsx +5 -0
- data/input-attachment/src/components.d.ts +2 -0
- data/lib/bard/attachment_field/cucumber.rb +2 -2
- data/lib/bard/attachment_field/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f060d98d9b6c3c4e0494845d868b7f702009df53e1cd39ac0d659402a8c28b97
|
|
4
|
+
data.tar.gz: a2e2afa88506420373c09e818612a037eb111a910370c87a2f41c69968d84151
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1480f10a1aaf61dc8f14e7c0e97062b033e85aa8d97d47e6df857cf1d254ad3b3adbee192d3de2156dc19dc3d2de16f244c9b6561933483c70a797ba63a0eecc
|
|
7
|
+
data.tar.gz: c78324d6d01030eeb10180287c14c6218e122ad865b511c89c7613ce8515b04aa3f138d4cdf8e0aab35216b66443478fafb6e6314955cfe9b01d06b1320493fb
|
|
@@ -5320,6 +5320,7 @@ var AttachmentFile = /* @__PURE__ */ proxyCustomElement(class AttachmentFile2 ex
|
|
|
5320
5320
|
this.__attachShadow();
|
|
5321
5321
|
this.removeEvent = createEvent(this, "attachment-file:remove", 7);
|
|
5322
5322
|
this.validationEvent = createEvent(this, "attachment-file:validation", 7);
|
|
5323
|
+
this.readyEvent = createEvent(this, "attachment-file:ready", 7);
|
|
5323
5324
|
}
|
|
5324
5325
|
get el() {
|
|
5325
5326
|
return this;
|
|
@@ -5339,6 +5340,7 @@ var AttachmentFile = /* @__PURE__ */ proxyCustomElement(class AttachmentFile2 ex
|
|
|
5339
5340
|
validationMessage;
|
|
5340
5341
|
removeEvent;
|
|
5341
5342
|
validationEvent;
|
|
5343
|
+
readyEvent;
|
|
5342
5344
|
removeClicked = (event) => {
|
|
5343
5345
|
event.stopPropagation();
|
|
5344
5346
|
event.preventDefault();
|
|
@@ -5382,6 +5384,7 @@ var AttachmentFile = /* @__PURE__ */ proxyCustomElement(class AttachmentFile2 ex
|
|
|
5382
5384
|
this.state = "complete";
|
|
5383
5385
|
this.percent = 100;
|
|
5384
5386
|
this.value = val;
|
|
5387
|
+
this.readyEvent.emit(this);
|
|
5385
5388
|
});
|
|
5386
5389
|
}
|
|
5387
5390
|
}
|
|
@@ -5411,7 +5414,7 @@ var AttachmentFile = /* @__PURE__ */ proxyCustomElement(class AttachmentFile2 ex
|
|
|
5411
5414
|
}
|
|
5412
5415
|
}
|
|
5413
5416
|
render() {
|
|
5414
|
-
return h(Host, { key: "
|
|
5417
|
+
return h(Host, { key: "1af2d43e01a8714c658ea70a9ca68cce57bbda12" }, h("slot", { key: "deadfff4a159e17d52ed8f66d5d18aecc71fb44d" }), h("figure", { key: "7319a724f2d51c396734dacd7528b1864fb8e980" }, h("div", { key: "ce0794f4062073a8fc28e4f2398a91d711f00521", class: "progress-details" }, h("progress-bar", { key: "30c130654e71e87036beaaf02f15453e1d35ab7a", percent: this.percent, class: this.state }, h("a", { key: "12dcf70078803fe226e9abf265dcaacd0241bfe3", class: "download-link", href: this.src, download: this.filename, onClick: (e) => e.stopPropagation() }, this.filename)), h("span", { key: "e736b315d4e0c3ec601c0fdec08ce7cce5665bef", class: "progress-icon" }), h("a", { key: "dd356dcc5f72ad33a5a52de080aa60f4af7df284", class: "remove-media", onClick: this.removeClicked, href: "#" }, h("span", { key: "c9976fdb30e8d3fa78bfc838eba1e8c33ff11c04" }, "Remove media")), this.uploadError && this._file ? h("a", { class: "retry-media", onClick: this.retryClicked, href: "#" }, h("span", null, "Retry upload")) : ""), this.validationError || this.uploadError ? h("p", { class: "validation-error" }, this.validationError || this.uploadError) : "", this.preview ? h("attachment-preview", { src: this.src, filetype: this.filetype }) : ""));
|
|
5415
5418
|
}
|
|
5416
5419
|
componentDidLoad() {
|
|
5417
5420
|
if (this.state == "pending" && this._file) {
|
|
@@ -5948,6 +5951,9 @@ var InputAttachment$1 = /* @__PURE__ */ proxyCustomElement(class InputAttachment
|
|
|
5948
5951
|
handleChildValidation(_event) {
|
|
5949
5952
|
this.updateFormValue();
|
|
5950
5953
|
}
|
|
5954
|
+
handleChildReady(_event) {
|
|
5955
|
+
this.updateFormValue();
|
|
5956
|
+
}
|
|
5951
5957
|
fireChangeEvent() {
|
|
5952
5958
|
requestAnimationFrame(() => {
|
|
5953
5959
|
this.updateFormValue();
|
|
@@ -5959,12 +5965,12 @@ var InputAttachment$1 = /* @__PURE__ */ proxyCustomElement(class InputAttachment
|
|
|
5959
5965
|
return this.disabled || !!this.el.closest("fieldset[disabled]");
|
|
5960
5966
|
}
|
|
5961
5967
|
render() {
|
|
5962
|
-
return h(Host, { key: "
|
|
5968
|
+
return h(Host, { key: "da0ceb39e5024d0dfe50511a4aa1139188dcb4a2" }, h("input", { key: "b9197faa99dcd580bf7c0fb7f356daa715d901d1", ref: (el) => this.fileInput = el, type: "file", multiple: this.multiple, accept: this.accepts, required: this.required && this.files.length === 0, disabled: this.isDisabled, onChange: () => this.handleFileInputChange(), style: {
|
|
5963
5969
|
opacity: "0.01",
|
|
5964
5970
|
width: "1px",
|
|
5965
5971
|
height: "1px",
|
|
5966
5972
|
zIndex: "-999"
|
|
5967
|
-
} }), h("file-drop", { key: "
|
|
5973
|
+
} }), h("file-drop", { key: "ce0608a99601202d437b7228e87437b510ba639f", onClick: () => this.fileInput?.click(), onDrop: this.handleDrop }, h("p", { key: "658d85fa352e7517789d95ad0c25756dafc79c08", part: "title" }, h("strong", { key: "7a160aa3132cdc8159e4319262cca69aa0b60d63" }, "Choose ", this.multiple ? "files" : "file", " "), h("span", { key: "51ab69b28833c8d442d1907ead5ddc79a6820f53" }, "or drag ", this.multiple ? "them" : "it", " here.")), h("div", { key: "a5bbee999e0575e27f7fc058640d8ee281ee0728", class: `media-preview ${this.multiple ? "-stacked" : ""}` }, h("slot", { key: "3a07d4e5aeaaf80fd5e37e9b135eb820dfcef757" }))));
|
|
5968
5974
|
}
|
|
5969
5975
|
componentDidRender() {
|
|
5970
5976
|
if (this.files.length === 0) {
|
|
@@ -6041,7 +6047,7 @@ var InputAttachment$1 = /* @__PURE__ */ proxyCustomElement(class InputAttachment
|
|
|
6041
6047
|
"max": [2],
|
|
6042
6048
|
"preview": [4],
|
|
6043
6049
|
"disabled": [4]
|
|
6044
|
-
}, [[0, "attachment-file:remove", "removeUploadedFile"], [0, "attachment-file:validation", "handleChildValidation"], [0, "direct-upload:end", "fireChangeEvent"]]]);
|
|
6050
|
+
}, [[0, "attachment-file:remove", "removeUploadedFile"], [0, "attachment-file:validation", "handleChildValidation"], [0, "attachment-file:ready", "handleChildReady"], [0, "direct-upload:end", "fireChangeEvent"]]]);
|
|
6045
6051
|
var InputAttachment2 = InputAttachment$1;
|
|
6046
6052
|
|
|
6047
6053
|
// dist/components/index.js
|
|
@@ -32,6 +32,7 @@ export class AttachmentFile {
|
|
|
32
32
|
|
|
33
33
|
@Event({ eventName: "attachment-file:remove" }) removeEvent: EventEmitter
|
|
34
34
|
@Event({ eventName: "attachment-file:validation" }) validationEvent: EventEmitter
|
|
35
|
+
@Event({ eventName: "attachment-file:ready" }) readyEvent: EventEmitter
|
|
35
36
|
|
|
36
37
|
private removeClicked = event => {
|
|
37
38
|
event.stopPropagation()
|
|
@@ -82,6 +83,7 @@ export class AttachmentFile {
|
|
|
82
83
|
this.state = "complete"
|
|
83
84
|
this.percent = 100
|
|
84
85
|
this.value = val
|
|
86
|
+
this.readyEvent.emit(this)
|
|
85
87
|
})
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
| Event | Description | Type |
|
|
30
30
|
| ---------------------------- | ----------- | ------------------ |
|
|
31
|
+
| `attachment-file:ready` | | `CustomEvent<any>` |
|
|
31
32
|
| `attachment-file:remove` | | `CustomEvent<any>` |
|
|
32
33
|
| `attachment-file:validation` | | `CustomEvent<any>` |
|
|
33
34
|
|
|
@@ -231,6 +231,11 @@ export class InputAttachment {
|
|
|
231
231
|
this.updateFormValue()
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
@Listen("attachment-file:ready")
|
|
235
|
+
handleChildReady(_event) {
|
|
236
|
+
this.updateFormValue()
|
|
237
|
+
}
|
|
238
|
+
|
|
234
239
|
@Listen("direct-upload:end")
|
|
235
240
|
fireChangeEvent() {
|
|
236
241
|
requestAnimationFrame(() => {
|
|
@@ -68,6 +68,7 @@ declare global {
|
|
|
68
68
|
interface HTMLAttachmentFileElementEventMap {
|
|
69
69
|
"attachment-file:remove": any;
|
|
70
70
|
"attachment-file:validation": any;
|
|
71
|
+
"attachment-file:ready": any;
|
|
71
72
|
}
|
|
72
73
|
interface HTMLAttachmentFileElement extends Components.AttachmentFile, HTMLStencilElement {
|
|
73
74
|
addEventListener<K extends keyof HTMLAttachmentFileElementEventMap>(type: K, listener: (this: HTMLAttachmentFileElement, ev: AttachmentFileCustomEvent<HTMLAttachmentFileElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
@@ -108,6 +109,7 @@ declare namespace LocalJSX {
|
|
|
108
109
|
"filetype"?: string;
|
|
109
110
|
"max"?: number;
|
|
110
111
|
"name"?: string;
|
|
112
|
+
"onAttachment-file:ready"?: (event: AttachmentFileCustomEvent<any>) => void;
|
|
111
113
|
"onAttachment-file:remove"?: (event: AttachmentFileCustomEvent<any>) => void;
|
|
112
114
|
"onAttachment-file:validation"?: (event: AttachmentFileCustomEvent<any>) => void;
|
|
113
115
|
/**
|
|
@@ -54,7 +54,7 @@ module Bard::AttachmentField::TestHelper
|
|
|
54
54
|
def wait_for_files(session, element_id, minimum, timeout: 15)
|
|
55
55
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
56
56
|
loop do
|
|
57
|
-
count = session.evaluate_script("document.getElementById(
|
|
57
|
+
count = session.evaluate_script("document.getElementById(`#{element_id}`).querySelectorAll('attachment-file').length")
|
|
58
58
|
break if count >= minimum
|
|
59
59
|
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
60
60
|
raise "Expected at least #{minimum} attachment-file(s) in ##{element_id}, found #{count} after #{timeout}s" if elapsed > timeout
|
|
@@ -65,7 +65,7 @@ module Bard::AttachmentField::TestHelper
|
|
|
65
65
|
def wait_for_no_files(session, element_id, selector = "attachment-file", timeout: 10)
|
|
66
66
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
67
67
|
loop do
|
|
68
|
-
count = session.evaluate_script("document.getElementById(
|
|
68
|
+
count = session.evaluate_script("document.getElementById(`#{element_id}`).querySelectorAll(`#{selector}`).length")
|
|
69
69
|
break if count == 0
|
|
70
70
|
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
71
71
|
raise "Expected no #{selector} in ##{element_id}, found #{count} after #{timeout}s" if elapsed > timeout
|