@uploadcare/file-uploader 1.4.1-alpha.0 → 1.4.1-alpha.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"UploaderPublicApi.d.ts","sourceRoot":"","sources":["UploaderPublicApi.js"],"names":[],"mappings":"AAYA;IAOE,8DAA8D;IAC9D,iBADY,OAAO,oBAAoB,EAAE,aAAa,EAGrD;IATD;;;OAGG;IACH,aAAK;IAOL,eAAe;IACf,gCAEC;IAED,yCAEC;IAED;;iBAEC;IAED;;;;;;OAMG;IACH,sBAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAUrD;IAEF;;;;OAIG;IACH,wBAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAUrD;IAEF;;;;OAIG;IACH,4BAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAgBrD;IAEF;;;;OAIG;IACH,0BAJW,IAAI;;;;;sBAEF,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAcrD;IAEF,iCAAiC;IACjC,qCADY,MAAM,UAMhB;IAEF,uBAEC;IAED,sBAeE;IAEF,mDAAmD;IACnD,6BADY;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,UAsCrC;IAEF;;;;OAIG;IACH,8EAHW,MAAM,iDA6Cf;IAEF,oEAAoE;IACpE,oKAIE;IAEF,+BAA+B;IAC/B,gDAsCE;IAEF,qBAQE;IAEF;;;OAGG;IACH,mCAHW,OAAO,oBAAoB,EAAE,YAAY,yGAYlD;IAEF,8BAA8B;IAC9B,wBADY,OAAO,UAOjB;IAEF;;;OAGG;IACH,0BAOC;CACF"}
1
+ {"version":3,"file":"UploaderPublicApi.d.ts","sourceRoot":"","sources":["UploaderPublicApi.js"],"names":[],"mappings":"AAYA;IAOE,8DAA8D;IAC9D,iBADY,OAAO,oBAAoB,EAAE,aAAa,EAGrD;IATD;;;OAGG;IACH,aAAK;IAOL,eAAe;IACf,gCAEC;IAED,yCAEC;IAED;;iBAEC;IAED;;;;;;OAMG;IACH,sBAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAUrD;IAEF;;;;OAIG;IACH,wBAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAUrD;IAEF;;;;OAIG;IACH,4BAJW,MAAM;;;;sBAEJ,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAgBrD;IAEF;;;;OAIG;IACH,0BAJW,IAAI;;;;;sBAEF,OAAO,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAcrD;IAEF,iCAAiC;IACjC,qCADY,MAAM,UAMhB;IAEF,uBAEC;IAED,sBAeE;IAEF,mDAAmD;IACnD,6BADY;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,UA+CrC;IAEF;;;;OAIG;IACH,8EAHW,MAAM,iDA6Cf;IAEF,oEAAoE;IACpE,oKAIE;IAEF,+BAA+B;IAC/B,gDAsCE;IAEF,qBAQE;IAEF;;;OAGG;IACH,mCAHW,OAAO,oBAAoB,EAAE,YAAY,yGAYlD;IAEF,8BAA8B;IAC9B,wBADY,OAAO,UAOjB;IAEF;;;OAGG;IACH,0BAOC;CACF"}
@@ -147,7 +147,12 @@ export class UploaderPublicApi {
147
147
  'The value of `accept` will be concatenated with the internal image mime types list.',
148
148
  );
149
149
  }
150
- const fileInput = document.createElement('input');
150
+
151
+ const INPUT_DATA_ATTR = 'data-uploadcare-temporary-input';
152
+
153
+ let fileInput = document.createElement('input');
154
+ fileInput.setAttribute(INPUT_DATA_ATTR, '');
155
+ fileInput.style.display = 'none';
151
156
  fileInput.type = 'file';
152
157
  fileInput.multiple = this.cfg.multiple;
153
158
  if (options.captureCamera) {
@@ -159,20 +164,24 @@ export class UploaderPublicApi {
159
164
  fileInput.addEventListener(
160
165
  'change',
161
166
  () => {
162
- // @ts-ignore TODO: fix this
163
- [...fileInput['files']].forEach((file) =>
167
+ if (!fileInput.files) {
168
+ return;
169
+ }
170
+ [...fileInput.files].forEach((file) =>
164
171
  this.addFileFromObject(file, { source: options.captureCamera ? UploadSource.CAMERA : UploadSource.LOCAL }),
165
172
  );
166
173
  // To call uploadTrigger UploadList should draw file items first:
167
174
  this._ctx.$['*currentActivity'] = ActivityBlock.activities.UPLOAD_LIST;
168
175
  this._ctx.setOrAddState('*modalActive', true);
169
- // @ts-ignore TODO: fix this
170
- fileInput['value'] = '';
176
+ fileInput.remove();
171
177
  },
172
178
  {
173
179
  once: true,
174
180
  },
175
181
  );
182
+
183
+ document.querySelectorAll(`[${INPUT_DATA_ATTR}]`).forEach((el) => el.remove());
184
+ document.body.appendChild(fileInput);
176
185
  fileInput.dispatchEvent(new MouseEvent('click'));
177
186
  };
178
187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadcare/file-uploader",
3
- "version": "1.4.1-alpha.0",
3
+ "version": "1.4.1-alpha.1",
4
4
  "description": "Building blocks for Uploadcare products integration",
5
5
  "keywords": [
6
6
  "web components",