@uppy/form
Advanced tools
Comparing version 3.1.1 to 3.2.0
# @uppy/form | ||
## 3.2.0 | ||
Released: 2024-02-28 | ||
Included in: Uppy v3.23.0 | ||
- @uppy/form: migrate to TS (Merlijn Vos / #4937) | ||
## 3.1.0 | ||
@@ -4,0 +11,0 @@ |
import BasePlugin from '@uppy/core/lib/BasePlugin.js'; | ||
import findDOMElement from '@uppy/utils/lib/findDOMElement'; | ||
import toArray from '@uppy/utils/lib/toArray'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore untyped | ||
import getFormData from 'get-form-data'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore We don't want TS to generate types for the package.json | ||
const packageJson = { | ||
"version": "3.1.1" | ||
"version": "3.2.0" | ||
}; | ||
/** | ||
* Form | ||
*/ | ||
const defaultOptions = { | ||
resultName: 'uppyResult', | ||
getMetaFromForm: true, | ||
addResultToForm: true, | ||
submitOnSuccess: false, | ||
triggerUploadOnSubmit: false | ||
}; | ||
function assertHTMLFormElement(input) { | ||
if (input == null || input.nodeName !== 'FORM') { | ||
throw new Error('ASSERTION FAILED: the target is not a <form> element', { | ||
cause: input | ||
}); | ||
} | ||
return input; | ||
} | ||
export default class Form extends BasePlugin { | ||
@@ -15,24 +32,8 @@ // TODO: make this private (or at least, mark it as readonly) | ||
constructor(uppy, opts) { | ||
super(uppy, opts); | ||
/** @type {HTMLFormElement} */ | ||
this.form = void 0; | ||
super(uppy, { | ||
...defaultOptions, | ||
...opts | ||
}); | ||
this.type = 'acquirer'; | ||
this.id = this.opts.id || 'Form'; | ||
this.title = 'Form'; | ||
// set default options | ||
const defaultOptions = { | ||
target: null, | ||
resultName: 'uppyResult', | ||
getMetaFromForm: true, | ||
addResultToForm: true, | ||
submitOnSuccess: false, | ||
triggerUploadOnSubmit: false | ||
}; | ||
// merge default options with the ones set by user | ||
this.opts = { | ||
...defaultOptions, | ||
...opts | ||
}; | ||
this.handleFormSubmit = this.handleFormSubmit.bind(this); | ||
@@ -65,2 +66,3 @@ this.handleUploadStart = this.handleUploadStart.bind(this); | ||
if (isButton && !el.disabled) { | ||
; | ||
el.disabled = true; // eslint-disable-line no-param-reassign | ||
@@ -119,7 +121,3 @@ disabledByUppy.push(el); | ||
install() { | ||
this.form = findDOMElement(this.opts.target); | ||
if (!this.form || this.form.nodeName !== 'FORM') { | ||
this.uppy.log('Form plugin requires a <form> target element passed in options to operate, none was found', 'error'); | ||
return; | ||
} | ||
this.form = assertHTMLFormElement(findDOMElement(this.opts.target)); | ||
this.form.addEventListener('submit', this.handleFormSubmit); | ||
@@ -126,0 +124,0 @@ this.uppy.on('upload', this.handleUploadStart); |
{ | ||
"name": "@uppy/form", | ||
"description": "Connect Uppy to an existing HTML <form>.", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"license": "MIT", | ||
@@ -24,8 +24,8 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/utils": "^5.7.2", | ||
"@uppy/utils": "^5.7.4", | ||
"get-form-data": "^3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@uppy/core": "^3.9.1" | ||
"@uppy/core": "^3.9.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
26102
290
2
Updated@uppy/utils@^5.7.4