@uppy/dashboard
Advanced tools
Comparing version 1.7.0 to 1.8.0
@@ -35,7 +35,7 @@ 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); } | ||
_this.tempStoreMeta = function (ev, name) { | ||
_this.updateMeta = function (newVal, name) { | ||
var _extends2; | ||
_this.setState({ | ||
formState: _extends({}, _this.state.formState, (_extends2 = {}, _extends2[name] = ev.target.value, _extends2)) | ||
formState: _extends({}, _this.state.formState, (_extends2 = {}, _extends2[name] = newVal, _extends2)) | ||
}); | ||
@@ -56,2 +56,5 @@ }; | ||
var metaFields = _this.props.metaFields || []; | ||
var fieldCSSClasses = { | ||
text: 'uppy-u-reset uppy-c-textInput uppy-Dashboard-FileCard-input' | ||
}; | ||
return metaFields.map(function (field) { | ||
@@ -65,6 +68,12 @@ var id = "uppy-Dashboard-FileCard-input-" + field.id; | ||
for: id | ||
}, field.name), h("input", { | ||
class: "uppy-u-reset uppy-c-textInput uppy-Dashboard-FileCard-input", | ||
}, field.name), field.render !== undefined ? field.render({ | ||
value: _this.state.formState[field.id], | ||
onChange: function onChange(newVal) { | ||
return _this.updateMeta(newVal, field.id); | ||
}, | ||
fieldCSSClasses: fieldCSSClasses | ||
}, h) : h("input", { | ||
class: fieldCSSClasses.text, | ||
id: id, | ||
type: "text", | ||
type: field.type || 'text', | ||
value: _this.state.formState[field.id], | ||
@@ -76,3 +85,3 @@ placeholder: field.placeholder, | ||
oninput: function oninput(ev) { | ||
return _this.tempStoreMeta(ev, field.id); | ||
return _this.updateMeta(ev.target.value, field.id); | ||
}, | ||
@@ -79,0 +88,0 @@ "data-uppy-super-focusable": true |
@@ -1059,2 +1059,2 @@ var _class, _temp; | ||
return Dashboard; | ||
}(Plugin), _class.VERSION = "1.7.0", _temp); | ||
}(Plugin), _class.VERSION = "1.8.0", _temp); |
{ | ||
"name": "@uppy/dashboard", | ||
"description": "Universal UI plugin for Uppy.", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "main": "lib/index.js", | ||
"@uppy/status-bar": "^1.6.0", | ||
"@uppy/thumbnail-generator": "^1.5.6", | ||
"@uppy/thumbnail-generator": "^1.5.7", | ||
"@uppy/utils": "^2.3.0", | ||
@@ -44,3 +44,3 @@ "classnames": "^2.2.6", | ||
}, | ||
"gitHead": "fa32da7cf3b1a518a86304ae169c657f2622e5cd" | ||
"gitHead": "700863e46e309916e851588fe4cb697e42c73f00" | ||
} |
@@ -32,7 +32,7 @@ const { h, Component } = require('preact') | ||
tempStoreMeta = (ev, name) => { | ||
updateMeta = (newVal, name) => { | ||
this.setState({ | ||
formState: { | ||
...this.state.formState, | ||
[name]: ev.target.value | ||
[name]: newVal | ||
} | ||
@@ -53,2 +53,5 @@ }) | ||
const metaFields = this.props.metaFields || [] | ||
const fieldCSSClasses = { | ||
text: 'uppy-u-reset uppy-c-textInput uppy-Dashboard-FileCard-input' | ||
} | ||
@@ -60,14 +63,22 @@ return metaFields.map((field) => { | ||
<label class="uppy-Dashboard-FileCard-label" for={id}>{field.name}</label> | ||
<input | ||
class="uppy-u-reset uppy-c-textInput uppy-Dashboard-FileCard-input" | ||
id={id} | ||
type="text" | ||
value={this.state.formState[field.id]} | ||
placeholder={field.placeholder} | ||
onkeyup={this.saveOnEnter} | ||
onkeydown={this.saveOnEnter} | ||
onkeypress={this.saveOnEnter} | ||
oninput={ev => this.tempStoreMeta(ev, field.id)} | ||
data-uppy-super-focusable | ||
/> | ||
{field.render !== undefined | ||
? field.render({ | ||
value: this.state.formState[field.id], | ||
onChange: (newVal) => this.updateMeta(newVal, field.id), | ||
fieldCSSClasses: fieldCSSClasses | ||
}, h) | ||
: ( | ||
<input | ||
class={fieldCSSClasses.text} | ||
id={id} | ||
type={field.type || 'text'} | ||
value={this.state.formState[field.id]} | ||
placeholder={field.placeholder} | ||
onkeyup={this.saveOnEnter} | ||
onkeydown={this.saveOnEnter} | ||
onkeypress={this.saveOnEnter} | ||
oninput={ev => this.updateMeta(ev.target.value, field.id)} | ||
data-uppy-super-focusable | ||
/> | ||
)} | ||
</fieldset> | ||
@@ -74,0 +85,0 @@ ) |
@@ -5,2 +5,9 @@ import Uppy = require('@uppy/core') | ||
type FieldRenderOptions = { | ||
value: string, | ||
onChange: (newVal: string) => void | ||
} | ||
type PreactRender = (node: any, params: object | null, ...children: any[]) => any | ||
interface MetaField { | ||
@@ -10,2 +17,3 @@ id: string | ||
placeholder?: string | ||
render?: (field: FieldRenderOptions, h: PreactRender) => any | ||
} | ||
@@ -12,0 +20,0 @@ |
@@ -28,2 +28,22 @@ import { expectType, expectError } from 'tsd' | ||
placeholder: 'Creative Commons, Apache 2.0, ...' | ||
}, | ||
{ | ||
id: 'public', | ||
name: 'Public', | ||
render ({ value, onChange }, h) { | ||
expectType<string>(value) | ||
expectType<(val: string) => void>(onChange) | ||
// `h` should be the Preact `h` | ||
expectError(h([], 'error')) | ||
/* Currently `h` typings are limited because of a JSX type conflict between React and Preact. | ||
return h('input', { | ||
type: 'checkbox', | ||
checked: value === 'yes', | ||
onChange: (event) => { | ||
expectType<Event>(event) | ||
onChange((event.target as HTMLInputElement).checked ? 'yes' : 'no') | ||
} | ||
}) | ||
*/ | ||
} | ||
} | ||
@@ -30,0 +50,0 @@ ] |
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
342355
6926
0