bard-attachment_field 0.5.7 → 0.6.0

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.
Binary file
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@botandrose/file-drop": "^0.1.1",
37
- "@botandrose/progress-bar": "^0.5.0",
37
+ "@botandrose/progress-bar": "^0.6.0",
38
38
  "@rails/activestorage": "^8.1.0",
39
39
  "@rails/request.js": "0.0.13",
40
40
  "@stencil/core": "^4.43.2",
@@ -17,4 +17,26 @@ describe('attachment-file', () => {
17
17
  // Just check that it renders without error
18
18
  expect(page.root.tagName).toBe('ATTACHMENT-FILE');
19
19
  });
20
+
21
+ it('links the download link to src by default', async () => {
22
+ const page = await newSpecPage({
23
+ components: [AttachmentFile],
24
+ html: `<attachment-file src="/preview.jpg" filename="image.jpg"></attachment-file>`,
25
+ });
26
+
27
+ const link = page.root.shadowRoot.querySelector('a.download-link');
28
+ expect(link.getAttribute('href')).toBe('/preview.jpg');
29
+ expect(link.getAttribute('download')).toBe('image.jpg');
30
+ });
31
+
32
+ it('links the download link to href and download when provided', async () => {
33
+ const page = await newSpecPage({
34
+ components: [AttachmentFile],
35
+ html: `<attachment-file src="/preview.jpg" href="/master.jpg" download="original.jpg" filename="image.jpg"></attachment-file>`,
36
+ });
37
+
38
+ const link = page.root.shadowRoot.querySelector('a.download-link');
39
+ expect(link.getAttribute('href')).toBe('/master.jpg');
40
+ expect(link.getAttribute('download')).toBe('original.jpg');
41
+ });
20
42
  });
@@ -22,6 +22,8 @@ export class AttachmentFile {
22
22
  @Prop({ reflect: true, mutable: true }) value: string = ""
23
23
  @Prop({ reflect: true, mutable: true }) filename: string
24
24
  @Prop({ reflect: true, mutable: true }) src: string
25
+ @Prop({ reflect: true, mutable: true }) href: string
26
+ @Prop({ reflect: true, mutable: true }) download: string
25
27
  @Prop({ reflect: true, mutable: true }) filetype: string
26
28
  @Prop({ reflect: true, mutable: true }) size: number
27
29
  @Prop({ reflect: true, mutable: true }) state: string = "complete"
@@ -132,7 +134,7 @@ export class AttachmentFile {
132
134
  <figure>
133
135
  <div class="progress-details">
134
136
  <progress-bar percent={this.percent} class={this.state} error={this.state === "error"}>
135
- <a class="download-link" href={this.src} download={this.filename} onClick={e => e.stopPropagation()}>
137
+ <a class="download-link" href={this.href || this.src} download={this.download || this.filename} onClick={e => e.stopPropagation()}>
136
138
  {this.filename}
137
139
  </a>
138
140
  </progress-bar>
@@ -10,8 +10,10 @@
10
10
  | Property | Attribute | Description | Type | Default |
11
11
  | ------------------- | -------------------- | ----------- | --------- | ------------ |
12
12
  | `accepts` | `accepts` | | `string` | `undefined` |
13
+ | `download` | `download` | | `string` | `undefined` |
13
14
  | `filename` | `filename` | | `string` | `undefined` |
14
15
  | `filetype` | `filetype` | | `string` | `undefined` |
16
+ | `href` | `href` | | `string` | `undefined` |
15
17
  | `max` | `max` | | `number` | `undefined` |
16
18
  | `name` | `name` | | `string` | `undefined` |
17
19
  | `percent` | `percent` | | `number` | `100` |
@@ -73,6 +73,8 @@ export class InputAttachment {
73
73
  value: f.value,
74
74
  filename: f.filename,
75
75
  src: f.src,
76
+ href: f.href,
77
+ download: f.download,
76
78
  state: f.state,
77
79
  percent: f.percent,
78
80
  size: f.size,
@@ -93,6 +95,8 @@ export class InputAttachment {
93
95
  attachmentFile.value = item.value
94
96
  attachmentFile.filename = item.filename
95
97
  attachmentFile.src = item.src
98
+ attachmentFile.href = item.href
99
+ attachmentFile.download = item.download
96
100
  attachmentFile.state = item.state || 'complete'
97
101
  attachmentFile.percent = item.percent || 100
98
102
  attachmentFile.size = item.size
@@ -8,8 +8,10 @@ import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
8
8
  export namespace Components {
9
9
  interface AttachmentFile {
10
10
  "accepts": string;
11
+ "download": string;
11
12
  "filename": string;
12
13
  "filetype": string;
14
+ "href": string;
13
15
  "max": number;
14
16
  "name": string;
15
17
  /**
@@ -126,8 +128,10 @@ declare global {
126
128
  declare namespace LocalJSX {
127
129
  interface AttachmentFile {
128
130
  "accepts"?: string;
131
+ "download"?: string;
129
132
  "filename"?: string;
130
133
  "filetype"?: string;
134
+ "href"?: string;
131
135
  "max"?: number;
132
136
  "name"?: string;
133
137
  "onAttachment-file:ready"?: (event: AttachmentFileCustomEvent<any>) => void;
@@ -199,6 +203,8 @@ declare namespace LocalJSX {
199
203
  "value": string;
200
204
  "filename": string;
201
205
  "src": string;
206
+ "href": string;
207
+ "download": string;
202
208
  "filetype": string;
203
209
  "size": number;
204
210
  "state": string;
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module AttachmentField
5
- VERSION = "0.5.7"
5
+ VERSION = "0.6.0"
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.5.7
4
+ version: 0.6.0
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-08 00:00:00.000000000 Z
11
+ date: 2026-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage