Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uppy/form

Package Overview
Dependencies
Maintainers
5
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/form - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

src/index.ts

7

CHANGELOG.md
# @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 @@

56

lib/index.js
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc