@cocreate/file
Advanced tools
Comparing version 1.17.4 to 1.17.5
@@ -0,1 +1,10 @@ | ||
## [1.17.5](https://github.com/CoCreate-app/CoCreate-file/compare/v1.17.4...v1.17.5) (2024-06-19) | ||
### Bug Fixes | ||
* getFileId uses pathname as id ([be330a5](https://github.com/CoCreate-app/CoCreate-file/commit/be330a54324ae878a8afadc68bdae1684e944b45)) | ||
* observer target selector ([50dc031](https://github.com/CoCreate-app/CoCreate-file/commit/50dc0318b7c9c02c2d610fe86158d47e6277e667)) | ||
* replace selected file if multiple false ([d419dc3](https://github.com/CoCreate-app/CoCreate-file/commit/d419dc38f223d1d809bcf014dd2fadb0a629fae7)) | ||
## [1.17.4](https://github.com/CoCreate-app/CoCreate-file/compare/v1.17.3...v1.17.4) (2024-06-12) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "@cocreate/file", | ||
"version": "1.17.4", | ||
"version": "1.17.5", | ||
"description": "A versatile, configurable headless file uploader supporting local and server operations. Accessible via a JavaScript API and HTML5 attributes, it provides seamless file reading, writing, and uploading with fallbacks to the standard HTML5 file input API. Ideal for developers needing robust file management in headless environments.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -111,3 +111,13 @@ /******************************************************************************** | ||
try { | ||
const input = event.target; | ||
const input = event.currentTarget; | ||
let multiple = input.multiple | ||
if (!multiple) { | ||
multiple = input.getAttribute('multiple'); | ||
if (multiple !== null && multiple !== "false") { | ||
multiple = true; | ||
} else { | ||
multiple = false; | ||
} | ||
} | ||
let selected = inputs.get(input) || new Map() | ||
@@ -117,3 +127,2 @@ let files = input.files; | ||
event.preventDefault() | ||
const multiple = input.multiple | ||
if (input.hasAttribute('directory')) { | ||
@@ -135,2 +144,10 @@ let handle = await window.showDirectoryPicker(); | ||
file.handle = handle | ||
if (!multiple) { | ||
for (let [id] of selected) { | ||
Files.delete(id); | ||
} | ||
selected.clear(); | ||
} | ||
selected.set(file.id, file) | ||
@@ -175,2 +192,9 @@ Files.set(file.id, file) | ||
if (!multiple) { | ||
for (let [id] of selected) { | ||
Files.delete(id); | ||
} | ||
selected.clear(); | ||
} | ||
selected.set(files[i].id, files[i]) | ||
@@ -227,10 +251,7 @@ Files.set(files[i].id, files[i]) | ||
if (file.id = file.path || file.webkitRelativePath) { | ||
if (file.id = file.pathname) { | ||
return file.id; | ||
} else { | ||
const { name, size, type, lastModified } = file; | ||
const key = `${name}${size}${type}${lastModified}`; | ||
file.id = key | ||
return key; | ||
file.id = `${file.name}${file.size}${file.type}${file.lastModified}`; | ||
return file.id; | ||
} | ||
@@ -542,3 +563,3 @@ } | ||
// Append the first segment to start | ||
appendSegmfent(0); | ||
appendSegment(0); | ||
}); | ||
@@ -886,3 +907,3 @@ | ||
observe: ['addedNodes'], | ||
target: 'input[type="file"]', | ||
target: '[type="file"]', | ||
callback: mutation => init(mutation.target) | ||
@@ -896,3 +917,3 @@ | ||
attributeName: ['type'], | ||
target: 'input[type="file"]', | ||
target: '[type="file"]', | ||
callback: mutation => init(mutation.target) | ||
@@ -903,3 +924,3 @@ }); | ||
{ | ||
name: ["upload", "download", "saveLocally", "import", "export"], | ||
name: ["upload", "download", "saveLocally", "asveAs", "import", "export"], | ||
callback: (action) => { | ||
@@ -906,0 +927,0 @@ if (action.name === 'upload') |
@@ -337,3 +337,3 @@ const crud = require('@cocreate/crud-client') | ||
return content | ||
return content; | ||
} | ||
@@ -340,0 +340,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152830
1376