@dile/ui 3.13.1 → 3.14.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.
@@ -30,4 +30,52 @@ describe('dile-drop-file', () => {
30
30
 
31
31
  expect(el.fileName).toBe('');
32
32
  });
33
+
34
+ it('renders accept attribute when accept property is defined', async () => {
35
+ const el = await renderDropFile('<dile-drop-file accept="application/pdf,image/*"></dile-drop-file>');
36
+ const fileInput = el.shadowRoot.querySelector('input[type="file"]');
37
+ expect(fileInput.getAttribute('accept')).toBe('application/pdf,image/*');
38
+ });
39
+
40
+ it('does not render accept attribute when accept property is empty', async () => {
41
+ const el = await renderDropFile('<dile-drop-file accept=""></dile-drop-file>');
42
+ const fileInput = el.shadowRoot.querySelector('input[type="file"]');
43
+ expect(fileInput.getAttribute('accept')).toBeNull();
44
+ });
45
+
46
+ it('renders capture attribute when capture property is defined', async () => {
47
+ const el = await renderDropFile('<dile-drop-file capture="environment"></dile-drop-file>');
48
+ const fileInput = el.shadowRoot.querySelector('input[type="file"]');
49
+ expect(fileInput.getAttribute('capture')).toBe('environment');
50
+ });
51
+
52
+ it('does not render capture attribute when capture property is empty', async () => {
53
+ const el = await renderDropFile('<dile-drop-file capture=""></dile-drop-file>');
54
+ const fileInput = el.shadowRoot.querySelector('input[type="file"]');
55
+ expect(fileInput.getAttribute('capture')).toBeNull();
56
+ });
57
+
58
+ it('updates accept attribute when property changes after render', async () => {
59
+ const el = await renderDropFile('<dile-drop-file></dile-drop-file>');
60
+ let fileInput = el.shadowRoot.querySelector('input[type="file"]');
61
+ expect(fileInput.getAttribute('accept')).toBeNull();
62
+
63
+ el.accept = 'image/*';
64
+ await el.updateComplete;
65
+
66
+ fileInput = el.shadowRoot.querySelector('input[type="file"]');
67
+ expect(fileInput.getAttribute('accept')).toBe('image/*');
68
+ });
69
+
70
+ it('updates capture attribute when property changes after render', async () => {
71
+ const el = await renderDropFile('<dile-drop-file></dile-drop-file>');
72
+ let fileInput = el.shadowRoot.querySelector('input[type="file"]');
73
+ expect(fileInput.getAttribute('capture')).toBeNull();
74
+
75
+ el.capture = 'user';
76
+ await el.updateComplete;
77
+
78
+ fileInput = el.shadowRoot.querySelector('input[type="file"]');
79
+ expect(fileInput.getAttribute('capture')).toBe('user');
80
+ });
33
81
  });
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
2
3
  import '../file-preview.js';
3
4
  import '../../button/button.js';
4
5
  import { labelStyles } from '../../input/src/label-styles.js';
@@ -61,6 +62,8 @@ export class DileDropFile extends DileEmmitChange(LitElement) {
61
62
  allowedExtensions: { type: Array },
62
63
  extensionErrorMessage: { type: String },
63
64
  name: { type: String, reflect: true },
65
+ accept: { type: String },
66
+ capture: { type: String },
64
67
  };
65
68
  }
66
69
 
@@ -78,6 +81,8 @@ export class DileDropFile extends DileEmmitChange(LitElement) {
78
81
  this.selectedFileLabel = "Selected file";
79
82
  this.extensionErrorMessage = "Only this file extensions are allowed: "
80
83
  this.allowedExtensions = [];
84
+ this.accept = '';
85
+ this.capture = '';
81
86
  this.internals = this.attachInternals();
82
87
  }
83
88
 
@@ -104,7 +109,7 @@ export class DileDropFile extends DileEmmitChange(LitElement) {
104
109
  ${this.dropLabelTemplate}
105
110
  </div>
106
111
  ${this.messageTemplate}
107
- <input type="file" id="fileInput" @change=${this._handleFileInput}>
112
+ <input type="file" id="fileInput" @change=${this._handleFileInput} accept=${ifDefined(this.accept || undefined)} capture=${ifDefined(this.capture || undefined)}>
108
113
  <dile-file-preview
109
114
  fileName="${this.fileName}"
110
115
  selectedFileLabel="${this.selectedFileLabel}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "3.13.1",
3
+ "version": "3.14.0",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "ca740f524209d56344b4b0090d9a82c8f1c0782f"
31
+ "gitHead": "2dbcfcfc126715e1f21c28806714f5f59b89d93b"
32
32
  }