bard-attachment_field 0.6.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f03200d473a693885b813d0990c78f6d06c7a3ef6ba6a9b88acdac3769379344
4
- data.tar.gz: e343b3122f95ef094f1060e73661d4a06ca07d0d4f3f041f3388271193a9aea5
3
+ metadata.gz: 171fcac9ab96b706cf55ff53b8f7c18f48aaa29c26a166b4e53c932136071c72
4
+ data.tar.gz: 683c9604ea6c3c0214e2571dee9c66ce2008f9452b9f0e70b393500b0c40d420
5
5
  SHA512:
6
- metadata.gz: 7d8d24848b191cbd2699095a94c512d5eb44c710ee0d36cd167719ae2865f0350b7a701727b19dc84172e35d7f2997e9bc06aaec341be120d1adb21f13bcbd2b
7
- data.tar.gz: ad571bce098435bec2bb4f05197aca1ab0ee9db13ee4325ae0c0aa02d157758ba071c61fc4d819b06b63def46ca39df0936f0faf13feac50c6d4e8bece325b66
6
+ metadata.gz: f21267ecf4f3107be7c9032212323e44b3b43b12fd30949abfdb78782b4779daa1940a7db337be51b4a9355cd6c701a9fa42765a0c1367e376217a7a2267352b
7
+ data.tar.gz: bd493292e9d8c0bff64960bef1aa95f931f334a27de8b80a243ee64b668af75d6735de34820ac0d5eeec80432b7479169bb5c1ba7c481cffa34cfe06c8335098
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.2] - 2026-07-23
4
+
5
+ ### Bug Fixes
6
+
7
+ - Clicking a `<video>` preview to play/pause no longer opens the file picker.
8
+ The click handler now stops propagation so it doesn't bubble to the
9
+ `<file-drop>` wrapper, which opens the upload dialog on click.
10
+
11
+ ## [0.6.1] - 2026-06-24
12
+
13
+ ### Bug Fixes
14
+
15
+ - Bump `@botandrose/progress-bar` to 0.6.1, which moves the `progressbar` role
16
+ off the host onto the inner fill/ring and names it from its slotted content.
17
+ This resolves the `aria-progressbar-name` and `nested-interactive` axe
18
+ violations on `<attachment-file>`, whose download link is slotted as the
19
+ progress bar's content.
20
+
3
21
  ## [0.6.0] - 2026-06-11
4
22
 
5
23
  ### Features
@@ -4087,7 +4087,7 @@ var a = proxyCustomElement(class extends H {
4087
4087
  src;
4088
4088
  filetype;
4089
4089
  render() {
4090
- return h(Host, { key: "429f17fda03ded975255da6335ba23a663ee662e", class: this.computeClass() }, this.isImage() && h("img", { key: "daa4e38cb1375db7d8852ab1cb401f048efbbdc7", src: this.src }), this.isVideo() && h("video", { key: "1b7860bc3edf2f4ba4951dd0bd8a88f14db078a0", src: this.src, onClick: n }), this.isOther() && "This file does not offer a preview", h("slot", { key: "b8a894bcc9ae11619d543b20f2bd2ee9167616d8" }));
4090
+ return h(Host, { key: "429f17fda03ded975255da6335ba23a663ee662e", class: this.computeClass() }, this.isImage() && h("img", { key: "daa4e38cb1375db7d8852ab1cb401f048efbbdc7", src: this.src }), this.isVideo() && h("video", { key: "1b7860bc3edf2f4ba4951dd0bd8a88f14db078a0", src: this.src, onClick: c }), this.isOther() && "This file does not offer a preview", h("slot", { key: "b8a894bcc9ae11619d543b20f2bd2ee9167616d8" }));
4091
4091
  }
4092
4092
  computeClass() {
4093
4093
  return this.isImage() ? "image" : this.isVideo() ? "video" : "other";
@@ -4105,8 +4105,8 @@ var a = proxyCustomElement(class extends H {
4105
4105
  return ":host{display:block;font-size:13px}img,video{max-width:100%;margin-top:10px}";
4106
4106
  }
4107
4107
  }, [769, "attachment-preview", { src: [513], filetype: [513] }]);
4108
- var n = function() {
4109
- return this.paused ? this.play() : this.pause(), false;
4108
+ var c = function(e3) {
4109
+ e3.stopPropagation(), this.paused ? this.play() : this.pause();
4110
4110
  };
4111
4111
 
4112
4112
  // dist/components/attachment-file2.js
@@ -4808,11 +4808,14 @@ var t = class extends HTMLElement {
4808
4808
  super(), this.attachShadow({ mode: "open" }), this._percent = null, this._renderedMode = null, this._rateTimer = null;
4809
4809
  }
4810
4810
  connectedCallback() {
4811
- this.render(), this.setAttribute("role", "progressbar"), this.setAttribute("aria-valuemin", "0"), this.setAttribute("aria-valuemax", "100"), this.updateBar(), this._syncTicker();
4811
+ this.render(), this.updateBar(), this._syncTicker();
4812
4812
  }
4813
4813
  disconnectedCallback() {
4814
4814
  this._stopTicker();
4815
4815
  }
4816
+ get _progressbarEl() {
4817
+ return this.shadowRoot.querySelector("circular" === this.mode ? ".ring" : ".bar");
4818
+ }
4816
4819
  get percent() {
4817
4820
  return this._percent;
4818
4821
  }
@@ -4849,13 +4852,14 @@ var t = class extends HTMLElement {
4849
4852
  }
4850
4853
  updateBar() {
4851
4854
  if ("circular" === this.mode) {
4852
- const r4 = this.shadowRoot?.querySelector(".progress-ring");
4853
- r4 && (r4.style.strokeDashoffset = this.indeterminate ? "" : String(100 * (1 - this._percent / 100)));
4855
+ const r5 = this.shadowRoot?.querySelector(".progress-ring");
4856
+ r5 && (r5.style.strokeDashoffset = this.indeterminate ? "" : String(100 * (1 - this._percent / 100)));
4854
4857
  } else {
4855
- const r4 = this.shadowRoot?.querySelector(".bar");
4856
- r4 && (r4.style.width = this.indeterminate ? "" : `${this._percent}%`);
4858
+ const r5 = this.shadowRoot?.querySelector(".bar");
4859
+ r5 && (r5.style.width = this.indeterminate ? "" : `${this._percent}%`);
4857
4860
  }
4858
- this.indeterminate ? this.removeAttribute("aria-valuenow") : this.setAttribute("aria-valuenow", String(this._percent));
4861
+ const r4 = this._progressbarEl;
4862
+ r4 && (this.indeterminate ? r4.removeAttribute("aria-valuenow") : r4.setAttribute("aria-valuenow", String(this._percent)));
4859
4863
  }
4860
4864
  _syncTicker() {
4861
4865
  const r4 = Number(this.getAttribute("rate")), n3 = this.isConnected && !this.indeterminate && Number.isFinite(r4) && 0 !== r4;
@@ -4870,7 +4874,8 @@ var t = class extends HTMLElement {
4870
4874
  }
4871
4875
  render() {
4872
4876
  const n3 = this.mode;
4873
- this._renderedMode !== n3 && (this._renderedMode = n3, this.shadowRoot.adoptedStyleSheets = [(r || (r = new CSSStyleSheet(), r.replaceSync(`
4877
+ if (this._renderedMode === n3) return;
4878
+ this._renderedMode = n3, this.shadowRoot.adoptedStyleSheets = [(r || (r = new CSSStyleSheet(), r.replaceSync(`
4874
4879
  :host {
4875
4880
  --progress-color: #2E7D32;
4876
4881
  --error-color: #7a242f;
@@ -5012,7 +5017,9 @@ var t = class extends HTMLElement {
5012
5017
  :host([error]) .progress-ring { display: none; }
5013
5018
  :host([error]) .ring { animation: none; }
5014
5019
  :host([error]) .error-mark { display: block; }
5015
- `)), r)], this.shadowRoot.innerHTML = "circular" === n3 ? '\n <div class="circular">\n <svg class="ring" viewBox="0 0 100 100">\n <circle class="track" cx="50" cy="50" r="40"></circle>\n <circle class="progress-ring" cx="50" cy="50" r="40" pathLength="100"></circle>\n <path class="error-mark" d="M37 37 L63 63 M63 37 L37 63"></path>\n </svg>\n <span class="label"><slot></slot></span>\n </div>\n' : '\n <div class="bar"></div>\n <div class="text"><slot></slot></div>\n');
5020
+ `)), r)], this.shadowRoot.innerHTML = "circular" === n3 ? '\n <div class="circular">\n <svg class="ring" viewBox="0 0 100 100">\n <circle class="track" cx="50" cy="50" r="40"></circle>\n <circle class="progress-ring" cx="50" cy="50" r="40" pathLength="100"></circle>\n <path class="error-mark" d="M37 37 L63 63 M63 37 L37 63"></path>\n </svg>\n <span class="label" id="label"><slot></slot></span>\n </div>\n' : '\n <div class="bar"></div>\n <div class="text" id="label"><slot></slot></div>\n';
5021
+ const e3 = this._progressbarEl;
5022
+ e3.setAttribute("role", "progressbar"), e3.setAttribute("aria-valuemin", "0"), e3.setAttribute("aria-valuemax", "100"), e3.setAttribute("aria-labelledby", "label");
5016
5023
  }
5017
5024
  };
5018
5025
  customElements.get("progress-bar") || customElements.define("progress-bar", t);
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@botandrose/file-drop": "^0.1.1",
37
- "@botandrose/progress-bar": "^0.6.0",
37
+ "@botandrose/progress-bar": "^0.6.1",
38
38
  "@rails/activestorage": "^8.1.0",
39
39
  "@rails/request.js": "0.0.13",
40
40
  "@stencil/core": "^4.43.2",
@@ -8,4 +8,31 @@ describe('attachment-preview', () => {
8
8
  const element = await page.find('attachment-preview');
9
9
  expect(element).toHaveClass('hydrated');
10
10
  });
11
+
12
+ it('does not bubble video preview clicks to ancestor upload handlers', async () => {
13
+ const page = await newE2EPage();
14
+ await page.setContent(`
15
+ <div id="drop">
16
+ <attachment-preview filetype="video" src="data:video/mp4;base64,AAAA"></attachment-preview>
17
+ </div>
18
+ `);
19
+ await page.evaluate(() => {
20
+ (window as any).ancestorClicked = false;
21
+ document
22
+ .getElementById('drop')
23
+ .addEventListener('click', () => { (window as any).ancestorClicked = true; });
24
+ const video = document
25
+ .querySelector('attachment-preview')
26
+ .shadowRoot.querySelector('video') as any;
27
+ video.play = () => Promise.resolve();
28
+ video.pause = () => {};
29
+ });
30
+
31
+ const video = await page.find('attachment-preview >>> video');
32
+ await video.click();
33
+ await page.waitForChanges();
34
+
35
+ const ancestorClicked = await page.evaluate(() => (window as any).ancestorClicked);
36
+ expect(ancestorClicked).toBe(false);
37
+ });
11
38
  });
@@ -39,4 +39,7 @@ export class AttachmentPreview {
39
39
  }
40
40
  }
41
41
 
42
- const toggle = function() { this.paused ? this.play() : this.pause(); return false }
42
+ const toggle = function(event) {
43
+ event.stopPropagation()
44
+ this.paused ? this.play() : this.pause()
45
+ }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module AttachmentField
5
- VERSION = "0.6.0"
5
+ VERSION = "0.6.2"
6
6
  end
7
7
  end
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.0
4
+ version: 0.6.2
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-06-11 00:00:00.000000000 Z
11
+ date: 2026-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage