@uppy/dashboard
Advanced tools
Comparing version 1.21.0 to 1.21.1
@@ -13,4 +13,2 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
var cuid = require('cuid'); | ||
var getFileTypeIcon = require('../../utils/getFileTypeIcon'); | ||
@@ -38,4 +36,2 @@ | ||
_this.form = document.createElement('form'); | ||
_this.handleSave = function (e) { | ||
@@ -52,2 +48,12 @@ e.preventDefault(); | ||
_this.saveOnEnter = function (ev) { | ||
if (ev.keyCode === 13) { | ||
ev.stopPropagation(); | ||
ev.preventDefault(); | ||
var file = _this.props.files[_this.props.fileCardFor]; | ||
_this.props.saveFileCard(_this.state.formState, file.id); | ||
} | ||
}; | ||
_this.renderMetaFields = function () { | ||
@@ -75,8 +81,6 @@ var metaFields = _this.getMetaFields() || []; | ||
fieldCSSClasses: fieldCSSClasses, | ||
required: required, | ||
form: _this.form.id | ||
required: required | ||
}, h) : h("input", { | ||
className: fieldCSSClasses.text, | ||
id: id, | ||
form: _this.form.id, | ||
type: field.type || 'text', | ||
@@ -86,2 +90,5 @@ required: required, | ||
placeholder: field.placeholder, | ||
onKeyUp: _this.saveOnEnter, | ||
onKeyDown: _this.saveOnEnter, | ||
onKeyPress: _this.saveOnEnter, | ||
onInput: function onInput(ev) { | ||
@@ -95,3 +102,3 @@ return _this.updateMeta(ev.target.value, field.id); | ||
var file = _this.props.files[_this.props.fileCardFor]; | ||
var _file = _this.props.files[_this.props.fileCardFor]; | ||
@@ -103,3 +110,3 @@ var _metaFields = _this.getMetaFields() || []; | ||
_metaFields.forEach(function (field) { | ||
storedMetaData[field.id] = file.meta[field.id] || ''; | ||
storedMetaData[field.id] = _file.meta[field.id] || ''; | ||
}); | ||
@@ -110,3 +117,2 @@ | ||
}; | ||
_this.form.id = cuid(); | ||
return _this; | ||
@@ -117,13 +123,2 @@ } | ||
// TODO(aduh95): move this to `UNSAFE_componentWillMount` when updating to Preact X+. | ||
_proto.componentWillMount = function componentWillMount() { | ||
this.form.addEventListener('submit', this.handleSave); | ||
document.body.appendChild(this.form); | ||
}; | ||
_proto.componentWillUnmount = function componentWillUnmount() { | ||
this.form.removeEventListener('submit', this.handleSave); | ||
document.body.removeChild(this.form); | ||
}; | ||
_proto.getMetaFields = function getMetaFields() { | ||
@@ -158,3 +153,2 @@ return typeof this.props.metaFields === 'function' ? this.props.metaFields(this.props.files[this.props.fileCardFor]) : this.props.metaFields; | ||
type: "button", | ||
form: this.form.id, | ||
title: this.props.i18n('finishEditingFile'), | ||
@@ -176,4 +170,3 @@ onClick: this.handleCancel | ||
return _this2.props.openFileEditor(file); | ||
}, | ||
form: this.form.id | ||
} | ||
}, this.props.i18n('editFile'))), h("div", { | ||
@@ -184,10 +177,11 @@ className: "uppy-Dashboard-FileCard-info" | ||
}, h("button", { | ||
className: "uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Dashboard-FileCard-actionsBtn", | ||
type: "submit", | ||
form: this.form.id | ||
className: "uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Dashboard-FileCard-actionsBtn" // If `form` attribute is not in Preact 8, we can’t trigger the form validation. | ||
// We use a classic button with a onClick event handler. | ||
, | ||
type: "button", | ||
onClick: this.handleSave | ||
}, this.props.i18n('saveChanges')), h("button", { | ||
className: "uppy-u-reset uppy-c-btn uppy-c-btn-link uppy-Dashboard-FileCard-actionsBtn", | ||
type: "button", | ||
onClick: this.handleCancel, | ||
form: this.form.id | ||
onClick: this.handleCancel | ||
}, this.props.i18n('cancel'))))); | ||
@@ -194,0 +188,0 @@ }; |
@@ -1280,2 +1280,2 @@ var _class, _temp; | ||
return Dashboard; | ||
}(Plugin), _class.VERSION = "1.21.0", _temp); | ||
}(Plugin), _class.VERSION = "1.21.1", _temp); |
{ | ||
"name": "@uppy/dashboard", | ||
"description": "Universal UI plugin for Uppy.", | ||
"version": "1.21.0", | ||
"version": "1.21.1", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "28997bc5c733e3f7ab7183d6cd61d2dfd74f71e4" | ||
"gitHead": "bba47cd86b94ae313ab448599f867d3e2850ca94" | ||
} |
const { h, Component } = require('preact') | ||
const classNames = require('classnames') | ||
const cuid = require('cuid') | ||
const getFileTypeIcon = require('../../utils/getFileTypeIcon') | ||
@@ -23,4 +22,2 @@ const ignoreEvent = require('../../utils/ignoreEvent.js') | ||
} | ||
this.form.id = cuid() | ||
} | ||
@@ -37,4 +34,2 @@ | ||
form = document.createElement('form'); | ||
handleSave = (e) => { | ||
@@ -50,13 +45,11 @@ e.preventDefault() | ||
// TODO(aduh95): move this to `UNSAFE_componentWillMount` when updating to Preact X+. | ||
componentWillMount () { | ||
this.form.addEventListener('submit', this.handleSave) | ||
document.body.appendChild(this.form) | ||
saveOnEnter = (ev) => { | ||
if (ev.keyCode === 13) { | ||
ev.stopPropagation() | ||
ev.preventDefault() | ||
const file = this.props.files[this.props.fileCardFor] | ||
this.props.saveFileCard(this.state.formState, file.id) | ||
} | ||
} | ||
componentWillUnmount () { | ||
this.form.removeEventListener('submit', this.handleSave) | ||
document.body.removeChild(this.form) | ||
} | ||
renderMetaFields = () => { | ||
@@ -80,3 +73,2 @@ const metaFields = this.getMetaFields() || [] | ||
required, | ||
form: this.form.id, | ||
}, h) | ||
@@ -87,3 +79,2 @@ : ( | ||
id={id} | ||
form={this.form.id} | ||
type={field.type || 'text'} | ||
@@ -93,2 +84,5 @@ required={required} | ||
placeholder={field.placeholder} | ||
onKeyUp={this.saveOnEnter} | ||
onKeyDown={this.saveOnEnter} | ||
onKeyPress={this.saveOnEnter} | ||
onInput={ev => this.updateMeta(ev.target.value, field.id)} | ||
@@ -131,3 +125,2 @@ data-uppy-super-focusable | ||
type="button" | ||
form={this.form.id} | ||
title={this.props.i18n('finishEditingFile')} | ||
@@ -149,3 +142,2 @@ onClick={this.handleCancel} | ||
onClick={() => this.props.openFileEditor(file)} | ||
form={this.form.id} | ||
> | ||
@@ -164,4 +156,6 @@ {this.props.i18n('editFile')} | ||
className="uppy-u-reset uppy-c-btn uppy-c-btn-primary uppy-Dashboard-FileCard-actionsBtn" | ||
type="submit" | ||
form={this.form.id} | ||
// If `form` attribute is not in Preact 8, we can’t trigger the form validation. | ||
// We use a classic button with a onClick event handler. | ||
type="button" | ||
onClick={this.handleSave} | ||
> | ||
@@ -174,3 +168,2 @@ {this.props.i18n('saveChanges')} | ||
onClick={this.handleCancel} | ||
form={this.form.id} | ||
> | ||
@@ -177,0 +170,0 @@ {this.props.i18n('cancel')} |
@@ -9,3 +9,3 @@ import Uppy = require('@uppy/core') | ||
fieldCSSClasses: { text: string } | ||
required?: boolean | ||
required: boolean | ||
} | ||
@@ -12,0 +12,0 @@ |
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
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
639932
9086