@instructure/ui-file-drop 8.25.1-snapshot.0 → 8.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/es/FileDrop/index.js +61 -69
- package/es/FileDrop/props.js +0 -98
- package/es/FileDrop/utils/getEventFiles.js +8 -6
- package/lib/FileDrop/index.js +63 -70
- package/lib/FileDrop/props.js +0 -98
- package/lib/FileDrop/utils/getEventFiles.js +8 -6
- package/package.json +16 -17
- package/src/FileDrop/index.tsx +75 -106
- package/src/FileDrop/props.ts +91 -76
- package/src/FileDrop/utils/accepts.ts +4 -4
- package/src/FileDrop/utils/getEventFiles.ts +13 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/FileDrop/FileDropLocator.d.ts +4 -4
- package/types/FileDrop/index.d.ts +48 -43
- package/types/FileDrop/index.d.ts.map +1 -1
- package/types/FileDrop/props.d.ts +89 -8
- package/types/FileDrop/props.d.ts.map +1 -1
- package/types/FileDrop/utils/accepts.d.ts +2 -2
- package/types/FileDrop/utils/accepts.d.ts.map +1 -1
- package/types/FileDrop/utils/getEventFiles.d.ts +2 -1
- package/types/FileDrop/utils/getEventFiles.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/lib/FileDrop/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -11,7 +13,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
11
13
|
|
|
12
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
15
|
|
|
14
|
-
var _react = require("react");
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
17
|
|
|
16
18
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
17
19
|
|
|
@@ -29,8 +31,6 @@ var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js
|
|
|
29
31
|
|
|
30
32
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
31
33
|
|
|
32
|
-
var _isEdge = require("@instructure/ui-utils/lib/isEdge.js");
|
|
33
|
-
|
|
34
34
|
var _accepts = require("./utils/accepts");
|
|
35
35
|
|
|
36
36
|
var _getEventFiles = require("./utils/getEventFiles");
|
|
@@ -49,27 +49,15 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
49
49
|
|
|
50
50
|
function keyEventIsClickButton(e) {
|
|
51
51
|
return e.keyCode === _keycode.default.codes.space || e.keyCode === _keycode.default.codes.enter;
|
|
52
|
-
} // Used try-catch due to missing document/navigator references in Jenkins
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function isBrowserMS() {
|
|
56
|
-
let result = false;
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
result = document.documentMode || _isEdge.isEdge;
|
|
60
|
-
} catch (e) {} // eslint-disable-line no-empty
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return result;
|
|
64
52
|
}
|
|
65
|
-
|
|
66
|
-
const IS_MS = isBrowserMS();
|
|
67
53
|
/**
|
|
68
54
|
---
|
|
69
55
|
category: components
|
|
70
56
|
---
|
|
57
|
+
@tsProps
|
|
71
58
|
**/
|
|
72
59
|
|
|
60
|
+
|
|
73
61
|
let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class FileDrop extends _react.Component {
|
|
74
62
|
constructor(props) {
|
|
75
63
|
super(props);
|
|
@@ -100,6 +88,8 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
100
88
|
};
|
|
101
89
|
|
|
102
90
|
this.handleDragEnter = e => {
|
|
91
|
+
var _this$props$onDragEnt, _this$props;
|
|
92
|
+
|
|
103
93
|
e.preventDefault(); // Count the dropzone and any children that are entered.
|
|
104
94
|
|
|
105
95
|
this.enterCounter += 1; // Don't trigger onDragEnter for each children after the first one
|
|
@@ -113,10 +103,12 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
113
103
|
isDragAccepted: allFilesAccepted,
|
|
114
104
|
isDragRejected: !allFilesAccepted
|
|
115
105
|
});
|
|
116
|
-
this.props.onDragEnter(e);
|
|
106
|
+
(_this$props$onDragEnt = (_this$props = this.props).onDragEnter) === null || _this$props$onDragEnt === void 0 ? void 0 : _this$props$onDragEnt.call(_this$props, e);
|
|
117
107
|
};
|
|
118
108
|
|
|
119
109
|
this.handleDragOver = e => {
|
|
110
|
+
var _this$props$onDragOve, _this$props2;
|
|
111
|
+
|
|
120
112
|
e.preventDefault();
|
|
121
113
|
e.stopPropagation();
|
|
122
114
|
|
|
@@ -126,12 +118,13 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
126
118
|
} catch (err) {// continue regardless of error
|
|
127
119
|
}
|
|
128
120
|
|
|
129
|
-
;
|
|
130
|
-
this.props.onDragOver(e);
|
|
121
|
+
(_this$props$onDragOve = (_this$props2 = this.props).onDragOver) === null || _this$props$onDragOve === void 0 ? void 0 : _this$props$onDragOve.call(_this$props2, e);
|
|
131
122
|
return false;
|
|
132
123
|
};
|
|
133
124
|
|
|
134
125
|
this.handleDragLeave = e => {
|
|
126
|
+
var _this$props$onDragLea, _this$props3;
|
|
127
|
+
|
|
135
128
|
e.preventDefault();
|
|
136
129
|
this.enterCounter -= 1; // Only deactivate once the dropzone and all children was left
|
|
137
130
|
|
|
@@ -143,15 +136,15 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
143
136
|
isDragAccepted: false,
|
|
144
137
|
isDragRejected: false
|
|
145
138
|
});
|
|
146
|
-
this.props.onDragLeave(e);
|
|
139
|
+
(_this$props$onDragLea = (_this$props3 = this.props).onDragLeave) === null || _this$props$onDragLea === void 0 ? void 0 : _this$props$onDragLea.call(_this$props3, e);
|
|
147
140
|
};
|
|
148
141
|
|
|
149
142
|
this.handleChange = e => {
|
|
150
|
-
const _this$
|
|
151
|
-
onDrop = _this$
|
|
152
|
-
onDropAccepted = _this$
|
|
153
|
-
onDropRejected = _this$
|
|
154
|
-
shouldEnablePreview = _this$
|
|
143
|
+
const _this$props4 = this.props,
|
|
144
|
+
onDrop = _this$props4.onDrop,
|
|
145
|
+
onDropAccepted = _this$props4.onDropAccepted,
|
|
146
|
+
onDropRejected = _this$props4.onDropRejected,
|
|
147
|
+
shouldEnablePreview = _this$props4.shouldEnablePreview;
|
|
155
148
|
const fileList = this.getDataTransferItems(e, shouldEnablePreview);
|
|
156
149
|
|
|
157
150
|
const _this$parseFiles = this.parseFiles(fileList),
|
|
@@ -161,13 +154,13 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
161
154
|
|
|
162
155
|
e.preventDefault();
|
|
163
156
|
this.enterCounter = 0;
|
|
164
|
-
onDrop(accepted, rejected, e);
|
|
157
|
+
onDrop && onDrop(accepted, rejected, e);
|
|
165
158
|
|
|
166
|
-
if (rejected.length > 0) {
|
|
159
|
+
if (rejected.length > 0 && onDropRejected) {
|
|
167
160
|
onDropRejected(rejected, e);
|
|
168
161
|
}
|
|
169
162
|
|
|
170
|
-
if (accepted.length > 0) {
|
|
163
|
+
if (accepted.length > 0 && onDropAccepted) {
|
|
171
164
|
onDropAccepted(accepted, e);
|
|
172
165
|
}
|
|
173
166
|
|
|
@@ -179,7 +172,7 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
179
172
|
};
|
|
180
173
|
|
|
181
174
|
this.fileAccepted = file => {
|
|
182
|
-
return (0, _accepts.accepts)(file, this.props.accept);
|
|
175
|
+
if (this.props.accept) return (0, _accepts.accepts)(file, this.props.accept);else return true;
|
|
183
176
|
};
|
|
184
177
|
|
|
185
178
|
this.handleRef = el => {
|
|
@@ -201,12 +194,14 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
201
194
|
};
|
|
202
195
|
|
|
203
196
|
this.handleClick = e => {
|
|
197
|
+
var _this$fileInputEl;
|
|
198
|
+
|
|
204
199
|
if (this.fileInputEl.value && this.props.shouldAllowRepeats) {
|
|
205
200
|
this.fileInputEl.value = null;
|
|
206
201
|
} // focus the input (because FF won't)
|
|
207
202
|
|
|
208
203
|
|
|
209
|
-
this.fileInputEl.focus();
|
|
204
|
+
(_this$fileInputEl = this.fileInputEl) === null || _this$fileInputEl === void 0 ? void 0 : _this$fileInputEl.focus();
|
|
210
205
|
this.props.onClick(e);
|
|
211
206
|
this.setState({
|
|
212
207
|
isFileBrowserDisplayed: true
|
|
@@ -217,16 +212,6 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
217
212
|
if (this.state.isFocused && keyEventIsClickButton(e)) {
|
|
218
213
|
if (this.props.shouldAllowRepeats) {
|
|
219
214
|
this.fileInputEl.value = null;
|
|
220
|
-
} // This bit of logic is necessary for MS browsers but causes unwanted warnings in Firefox
|
|
221
|
-
// So we need to apply this logic only on MS browsers
|
|
222
|
-
|
|
223
|
-
/* istanbul ignore if */
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (IS_MS) {
|
|
227
|
-
e.stopPropagation();
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
this.fileInputEl.click();
|
|
230
215
|
}
|
|
231
216
|
}
|
|
232
217
|
};
|
|
@@ -248,13 +233,19 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
248
233
|
}
|
|
249
234
|
|
|
250
235
|
componentDidMount() {
|
|
251
|
-
;
|
|
252
|
-
|
|
236
|
+
var _this$props$makeStyle, _this$props5;
|
|
237
|
+
|
|
238
|
+
(_this$props$makeStyle = (_this$props5 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props5, this.makeStyleProps());
|
|
253
239
|
}
|
|
254
240
|
|
|
255
241
|
componentDidUpdate() {
|
|
256
|
-
;
|
|
257
|
-
|
|
242
|
+
var _this$props$makeStyle2, _this$props6;
|
|
243
|
+
|
|
244
|
+
(_this$props$makeStyle2 = (_this$props6 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props6, this.makeStyleProps());
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
convertToFile(fileLikeItem) {
|
|
248
|
+
if (fileLikeItem instanceof DataTransferItem) return fileLikeItem.getAsFile();else return fileLikeItem;
|
|
258
249
|
}
|
|
259
250
|
|
|
260
251
|
get functionallyDisabled() {
|
|
@@ -278,7 +269,11 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
278
269
|
}
|
|
279
270
|
|
|
280
271
|
getDataTransferItems(e, shouldEnablePreview) {
|
|
281
|
-
let list =
|
|
272
|
+
let list = [];
|
|
273
|
+
Array.from((0, _getEventFiles.getEventFiles)(e, this.fileInputEl)).forEach(file => {
|
|
274
|
+
const fileObj = this.convertToFile(file);
|
|
275
|
+
if (fileObj) list.push(fileObj);
|
|
276
|
+
});
|
|
282
277
|
|
|
283
278
|
if (list.length > 1) {
|
|
284
279
|
list = this.props.shouldAllowMultiple ? list : [list[0]];
|
|
@@ -297,7 +292,9 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
297
292
|
const accepted = [];
|
|
298
293
|
const rejected = [];
|
|
299
294
|
fileList.forEach(file => {
|
|
300
|
-
|
|
295
|
+
const fileObj = this.convertToFile(file);
|
|
296
|
+
|
|
297
|
+
if (fileObj && this.fileAccepted(fileObj) && this.fileMatchSize(fileObj)) {
|
|
301
298
|
accepted.push(file);
|
|
302
299
|
} else {
|
|
303
300
|
rejected.push(file);
|
|
@@ -316,7 +313,7 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
316
313
|
|
|
317
314
|
acceptStr() {
|
|
318
315
|
const accept = this.props.accept;
|
|
319
|
-
return accept ? (0, _accepts.getAcceptList)(accept).join(',') :
|
|
316
|
+
return accept ? (0, _accepts.getAcceptList)(accept).join(',') : void 0;
|
|
320
317
|
}
|
|
321
318
|
|
|
322
319
|
renderLabel() {
|
|
@@ -329,16 +326,18 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
329
326
|
}
|
|
330
327
|
|
|
331
328
|
render() {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
329
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
330
|
+
|
|
331
|
+
const _this$props7 = this.props,
|
|
332
|
+
display = _this$props7.display,
|
|
333
|
+
height = _this$props7.height,
|
|
334
|
+
width = _this$props7.width,
|
|
335
|
+
minWidth = _this$props7.minWidth,
|
|
336
|
+
maxWidth = _this$props7.maxWidth,
|
|
337
|
+
margin = _this$props7.margin,
|
|
338
|
+
onDropAccepted = _this$props7.onDropAccepted,
|
|
339
|
+
onDropRejected = _this$props7.onDropRejected,
|
|
340
|
+
props = (0, _objectWithoutProperties2.default)(_this$props7, _excluded);
|
|
342
341
|
const id = this.props.id || this.defaultId;
|
|
343
342
|
const focusColor = this.state.isDragRejected || this.invalid ? 'danger' : void 0;
|
|
344
343
|
return (0, _emotion.jsx)(_View.View, {
|
|
@@ -352,7 +351,7 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
352
351
|
height: height,
|
|
353
352
|
elementRef: this.handleElementRef
|
|
354
353
|
}, (0, _emotion.jsx)("label", {
|
|
355
|
-
css: this.props.styles.fileDropLabel,
|
|
354
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.fileDropLabel,
|
|
356
355
|
htmlFor: id,
|
|
357
356
|
onDragEnter: this.handleDragEnter,
|
|
358
357
|
onDragOver: this.handleDragOver,
|
|
@@ -366,15 +365,15 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
366
365
|
focusColor: focusColor,
|
|
367
366
|
height: height
|
|
368
367
|
}, (0, _emotion.jsx)("span", {
|
|
369
|
-
css: this.props.styles.fileDropLabelContent
|
|
368
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.fileDropLabelContent
|
|
370
369
|
}, (0, _emotion.jsx)("span", {
|
|
371
|
-
css: this.props.styles.fileDropLayout
|
|
370
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.fileDropLayout
|
|
372
371
|
}, (0, _emotion.jsx)(_View.View, {
|
|
373
372
|
height: height
|
|
374
373
|
}, this.renderLabel()))))), (0, _emotion.jsx)("input", Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
375
374
|
onClick: this.handleClick,
|
|
376
375
|
type: "file",
|
|
377
|
-
css: this.props.styles.fileDropInput,
|
|
376
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.fileDropInput,
|
|
378
377
|
id: id,
|
|
379
378
|
ref: this.handleRef,
|
|
380
379
|
onFocus: this.handleFocus,
|
|
@@ -384,7 +383,7 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
384
383
|
multiple: this.props.shouldAllowMultiple,
|
|
385
384
|
accept: this.acceptStr(),
|
|
386
385
|
onChange: this.handleChange,
|
|
387
|
-
"aria-describedby": this.hasMessages ? this.messagesId :
|
|
386
|
+
"aria-describedby": this.hasMessages ? this.messagesId : void 0,
|
|
388
387
|
disabled: this.functionallyDisabled
|
|
389
388
|
})), this.hasMessages ? (0, _emotion.jsx)(_View.View, {
|
|
390
389
|
display: "block",
|
|
@@ -396,13 +395,7 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
396
395
|
}
|
|
397
396
|
|
|
398
397
|
}, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
399
|
-
onClick: function (
|
|
400
|
-
onDrop: function (accepted, rejected, e) {},
|
|
401
|
-
onDropAccepted: function (accepted, e) {},
|
|
402
|
-
onDropRejected: function (rejected, e) {},
|
|
403
|
-
onDragEnter: function (e) {},
|
|
404
|
-
onDragOver: function (e) {},
|
|
405
|
-
onDragLeave: function (e) {},
|
|
398
|
+
onClick: function (_e) {},
|
|
406
399
|
shouldEnablePreview: false,
|
|
407
400
|
shouldAllowMultiple: false,
|
|
408
401
|
shouldAllowRepeats: true,
|
package/lib/FileDrop/props.js
CHANGED
|
@@ -37,126 +37,28 @@ var _emotion = require("@instructure/emotion");
|
|
|
37
37
|
* SOFTWARE.
|
|
38
38
|
*/
|
|
39
39
|
const propTypes = {
|
|
40
|
-
/**
|
|
41
|
-
* The id of the input (to link it to its label for a11y)
|
|
42
|
-
*/
|
|
43
40
|
id: _propTypes.default.string,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The content of FileDrop; can be a component or React node.
|
|
47
|
-
* Components receive `isDragAccepted` and `isDragRejected` as props.
|
|
48
|
-
*/
|
|
49
41
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]).isRequired,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The mime media type/s or file extension/s allowed to be dropped inside
|
|
53
|
-
*/
|
|
54
42
|
accept: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* object with shape: `{
|
|
58
|
-
* text: PropTypes.node,
|
|
59
|
-
* type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
|
|
60
|
-
* }`
|
|
61
|
-
*/
|
|
62
43
|
messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Called when clicking on drop area to select files to upload
|
|
66
|
-
*/
|
|
67
44
|
onClick: _propTypes.default.func,
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Called when dropping files or when file dialog window exits successfully
|
|
71
|
-
*/
|
|
72
45
|
onDrop: _propTypes.default.func,
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Called when dropping allowed files
|
|
76
|
-
*/
|
|
77
46
|
onDropAccepted: _propTypes.default.func,
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Called when dropping rejected files
|
|
81
|
-
*/
|
|
82
47
|
onDropRejected: _propTypes.default.func,
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Called when dragging files
|
|
86
|
-
* and passing through FileDrop's content for the first time
|
|
87
|
-
*/
|
|
88
48
|
onDragEnter: _propTypes.default.func,
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Called when dragging files and passing through FileDrop's content
|
|
92
|
-
*/
|
|
93
49
|
onDragOver: _propTypes.default.func,
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Called when dragging files and leaving FileDrop's content
|
|
97
|
-
*/
|
|
98
50
|
onDragLeave: _propTypes.default.func,
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Flag to use window.URL.createObjectURL for each dropped file and pass it through file.preview
|
|
102
|
-
*/
|
|
103
51
|
shouldEnablePreview: _propTypes.default.bool,
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Flag to allow multiple files to drop at once
|
|
107
|
-
*/
|
|
108
52
|
shouldAllowMultiple: _propTypes.default.bool,
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Flag to allow upload of the same file more than once
|
|
112
|
-
*/
|
|
113
53
|
shouldAllowRepeats: _propTypes.default.bool,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* the maximum file size allowed
|
|
117
|
-
*/
|
|
118
54
|
maxSize: _propTypes.default.number,
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* the minimum file size allowed
|
|
122
|
-
*/
|
|
123
55
|
minSize: _propTypes.default.number,
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Specifies if interaction with the input is enabled, disabled, or readonly.
|
|
127
|
-
*/
|
|
128
56
|
interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Set the CSS `display` property on FileInput's outermost element
|
|
132
|
-
*/
|
|
133
57
|
display: _propTypes.default.oneOf(['block', 'inline-block']),
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Set the CSS `height` property on FileInput's outermost element
|
|
137
|
-
*/
|
|
138
58
|
height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Set the CSS `width` property on FileInput's outermost element
|
|
142
|
-
*/
|
|
143
59
|
width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Set the CSS `maxWidth` property on FileInput's outermost element
|
|
147
|
-
*/
|
|
148
60
|
maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Set the CSS `minWidth` property on FileInput's outermost element
|
|
152
|
-
*/
|
|
153
61
|
minWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Valid values are 0, none, auto, xxx-small, xx-small, x-small, small,
|
|
157
|
-
* medium, large, x-large, xx-large. Apply these values via familiar
|
|
158
|
-
* CSS-like shorthand. For example: margin="small auto large".
|
|
159
|
-
*/
|
|
160
62
|
margin: _emotion.ThemeablePropTypes.spacing
|
|
161
63
|
};
|
|
162
64
|
exports.propTypes = propTypes;
|
|
@@ -30,13 +30,15 @@ exports.getEventFiles = getEventFiles;
|
|
|
30
30
|
* SOFTWARE.
|
|
31
31
|
*/
|
|
32
32
|
function getEventFiles(event, inputEl) {
|
|
33
|
-
|
|
33
|
+
if ('dataTransfer' in event) {
|
|
34
|
+
const dt = event.dataTransfer;
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if (dt) {
|
|
37
|
+
if (dt.files && dt.files.length) {
|
|
38
|
+
return dt.files;
|
|
39
|
+
} else if (dt.items && dt.items.length) {
|
|
40
|
+
return dt.items;
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
} else if (inputEl && inputEl.files) {
|
|
42
44
|
return inputEl.files;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-file-drop",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.26.0",
|
|
4
4
|
"description": "A flexible facade for an HTML file input",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,24 +24,24 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.
|
|
28
|
-
"@instructure/emotion": "8.
|
|
29
|
-
"@instructure/shared-types": "8.
|
|
30
|
-
"@instructure/ui-color-utils": "8.
|
|
31
|
-
"@instructure/ui-form-field": "8.
|
|
32
|
-
"@instructure/ui-react-utils": "8.
|
|
33
|
-
"@instructure/ui-testable": "8.
|
|
34
|
-
"@instructure/ui-utils": "8.
|
|
35
|
-
"@instructure/ui-view": "8.
|
|
36
|
-
"@instructure/uid": "8.
|
|
27
|
+
"@instructure/console": "8.26.0",
|
|
28
|
+
"@instructure/emotion": "8.26.0",
|
|
29
|
+
"@instructure/shared-types": "8.26.0",
|
|
30
|
+
"@instructure/ui-color-utils": "8.26.0",
|
|
31
|
+
"@instructure/ui-form-field": "8.26.0",
|
|
32
|
+
"@instructure/ui-react-utils": "8.26.0",
|
|
33
|
+
"@instructure/ui-testable": "8.26.0",
|
|
34
|
+
"@instructure/ui-utils": "8.26.0",
|
|
35
|
+
"@instructure/ui-view": "8.26.0",
|
|
36
|
+
"@instructure/uid": "8.26.0",
|
|
37
37
|
"keycode": "^2",
|
|
38
38
|
"prop-types": "^15"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@instructure/ui-babel-preset": "8.
|
|
42
|
-
"@instructure/ui-test-locator": "8.
|
|
43
|
-
"@instructure/ui-test-utils": "8.
|
|
44
|
-
"@instructure/ui-themes": "8.
|
|
41
|
+
"@instructure/ui-babel-preset": "8.26.0",
|
|
42
|
+
"@instructure/ui-test-locator": "8.26.0",
|
|
43
|
+
"@instructure/ui-test-utils": "8.26.0",
|
|
44
|
+
"@instructure/ui-themes": "8.26.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8 <=17"
|
|
@@ -49,6 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"sideEffects": false
|
|
53
|
-
"gitHead": "59b6babce07a9242111475156f544ec11c1a9283"
|
|
52
|
+
"sideEffects": false
|
|
54
53
|
}
|