@instructure/ui-file-drop 8.33.2-snapshot-0 → 8.33.2
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 +1 -5
- package/es/FileDrop/FileDropLocator.js +6 -3
- package/es/FileDrop/__examples__/FileDrop.examples.js +1 -0
- package/es/FileDrop/index.js +27 -83
- package/es/FileDrop/locator.js +1 -0
- package/es/FileDrop/props.js +1 -0
- package/es/FileDrop/styles.js +9 -7
- package/es/FileDrop/theme.js +4 -4
- package/es/FileDrop/utils/accepts.js +1 -5
- package/es/FileDrop/utils/getEventFiles.js +1 -3
- package/es/index.js +1 -0
- package/lib/FileDrop/FileDropLocator.js +7 -6
- package/lib/FileDrop/__examples__/FileDrop.examples.js +0 -1
- package/lib/FileDrop/index.js +27 -100
- package/lib/FileDrop/locator.js +0 -2
- package/lib/FileDrop/props.js +1 -5
- package/lib/FileDrop/styles.js +9 -8
- package/lib/FileDrop/theme.js +4 -5
- package/lib/FileDrop/utils/accepts.js +1 -6
- package/lib/FileDrop/utils/getEventFiles.js +1 -4
- package/lib/index.js +0 -1
- package/package.json +15 -15
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/FileDrop/index.js
CHANGED
|
@@ -1,67 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.FileDrop = void 0;
|
|
11
|
-
|
|
12
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
19
|
-
|
|
20
13
|
var _FormFieldMessages = require("@instructure/ui-form-field/lib/FormFieldMessages");
|
|
21
|
-
|
|
22
14
|
var _View = require("@instructure/ui-view/lib/View");
|
|
23
|
-
|
|
24
15
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
25
|
-
|
|
26
16
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
27
|
-
|
|
28
17
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
29
|
-
|
|
30
18
|
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
31
|
-
|
|
32
19
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
33
|
-
|
|
34
20
|
var _accepts = require("./utils/accepts");
|
|
35
|
-
|
|
36
21
|
var _getEventFiles = require("./utils/getEventFiles");
|
|
37
|
-
|
|
38
22
|
var _emotion = require("@instructure/emotion");
|
|
39
|
-
|
|
40
23
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
41
|
-
|
|
42
24
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
43
|
-
|
|
44
25
|
var _props = require("./props");
|
|
45
|
-
|
|
46
26
|
const _excluded = ["display", "height", "width", "minWidth", "maxWidth", "margin", "onDropAccepted", "onDropRejected"];
|
|
47
|
-
|
|
48
27
|
var _dec, _dec2, _dec3, _class, _class2;
|
|
49
|
-
|
|
50
28
|
function keyEventIsClickButton(e) {
|
|
51
29
|
return e.keyCode === _keycode.default.codes.space || e.keyCode === _keycode.default.codes.enter;
|
|
52
30
|
}
|
|
31
|
+
|
|
53
32
|
/**
|
|
54
33
|
---
|
|
55
34
|
category: components
|
|
56
35
|
---
|
|
57
36
|
@tsProps
|
|
58
37
|
**/
|
|
59
|
-
|
|
60
|
-
|
|
61
38
|
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 {
|
|
62
39
|
constructor(props) {
|
|
63
40
|
super(props);
|
|
64
|
-
|
|
65
41
|
this.makeStyleProps = () => {
|
|
66
42
|
return {
|
|
67
43
|
functionallyDisabled: this.functionallyDisabled,
|
|
@@ -70,7 +46,6 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
70
46
|
dragAccepted: this.state.isDragAccepted
|
|
71
47
|
};
|
|
72
48
|
};
|
|
73
|
-
|
|
74
49
|
this.state = {
|
|
75
50
|
isDragAccepted: false,
|
|
76
51
|
isDragRejected: false,
|
|
@@ -82,22 +57,18 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
82
57
|
this.defaultId = null;
|
|
83
58
|
this.messagesId = '';
|
|
84
59
|
this.ref = null;
|
|
85
|
-
|
|
86
60
|
this.handleElementRef = el => {
|
|
87
61
|
this.ref = el;
|
|
88
62
|
};
|
|
89
|
-
|
|
90
63
|
this.handleDragEnter = e => {
|
|
91
64
|
var _this$props$onDragEnt, _this$props;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
// Count the dropzone and any children that are entered.
|
|
67
|
+
this.enterCounter += 1;
|
|
68
|
+
// Don't trigger onDragEnter for each children after the first one
|
|
97
69
|
if (this.enterCounter > 1) {
|
|
98
70
|
return;
|
|
99
71
|
}
|
|
100
|
-
|
|
101
72
|
const allFilesAccepted = this.allFilesAccepted(this.getDataTransferItems(e));
|
|
102
73
|
this.setState({
|
|
103
74
|
isDragAccepted: allFilesAccepted,
|
|
@@ -105,109 +76,89 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
105
76
|
});
|
|
106
77
|
(_this$props$onDragEnt = (_this$props = this.props).onDragEnter) === null || _this$props$onDragEnt === void 0 ? void 0 : _this$props$onDragEnt.call(_this$props, e);
|
|
107
78
|
};
|
|
108
|
-
|
|
109
79
|
this.handleDragOver = e => {
|
|
110
80
|
var _this$props$onDragOve, _this$props2;
|
|
111
|
-
|
|
112
81
|
e.preventDefault();
|
|
113
82
|
e.stopPropagation();
|
|
114
|
-
|
|
115
83
|
try {
|
|
116
84
|
const event = e;
|
|
117
85
|
event.dataTransfer.dropEffect = 'copy';
|
|
118
|
-
} catch (err) {
|
|
86
|
+
} catch (err) {
|
|
87
|
+
// continue regardless of error
|
|
119
88
|
}
|
|
120
|
-
|
|
121
89
|
(_this$props$onDragOve = (_this$props2 = this.props).onDragOver) === null || _this$props$onDragOve === void 0 ? void 0 : _this$props$onDragOve.call(_this$props2, e);
|
|
122
90
|
return false;
|
|
123
91
|
};
|
|
124
|
-
|
|
125
92
|
this.handleDragLeave = e => {
|
|
126
93
|
var _this$props$onDragLea, _this$props3;
|
|
127
|
-
|
|
128
94
|
e.preventDefault();
|
|
129
|
-
this.enterCounter -= 1;
|
|
130
|
-
|
|
95
|
+
this.enterCounter -= 1;
|
|
96
|
+
// Only deactivate once the dropzone and all children was left
|
|
131
97
|
if (this.enterCounter > 0) {
|
|
132
98
|
return;
|
|
133
99
|
}
|
|
134
|
-
|
|
135
100
|
this.setState({
|
|
136
101
|
isDragAccepted: false,
|
|
137
102
|
isDragRejected: false
|
|
138
103
|
});
|
|
139
104
|
(_this$props$onDragLea = (_this$props3 = this.props).onDragLeave) === null || _this$props$onDragLea === void 0 ? void 0 : _this$props$onDragLea.call(_this$props3, e);
|
|
140
105
|
};
|
|
141
|
-
|
|
142
106
|
this.handleChange = e => {
|
|
143
107
|
const _this$props4 = this.props,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
onDrop = _this$props4.onDrop,
|
|
109
|
+
onDropAccepted = _this$props4.onDropAccepted,
|
|
110
|
+
onDropRejected = _this$props4.onDropRejected,
|
|
111
|
+
shouldEnablePreview = _this$props4.shouldEnablePreview;
|
|
148
112
|
const fileList = this.getDataTransferItems(e, shouldEnablePreview);
|
|
149
|
-
|
|
150
113
|
const _this$parseFiles = this.parseFiles(fileList),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
114
|
+
_this$parseFiles2 = (0, _slicedToArray2.default)(_this$parseFiles, 2),
|
|
115
|
+
accepted = _this$parseFiles2[0],
|
|
116
|
+
rejected = _this$parseFiles2[1];
|
|
155
117
|
e.preventDefault();
|
|
156
118
|
this.enterCounter = 0;
|
|
157
119
|
onDrop && onDrop(accepted, rejected, e);
|
|
158
|
-
|
|
159
120
|
if (rejected.length > 0 && onDropRejected) {
|
|
160
121
|
onDropRejected(rejected, e);
|
|
161
122
|
}
|
|
162
|
-
|
|
163
123
|
if (accepted.length > 0 && onDropAccepted) {
|
|
164
124
|
onDropAccepted(accepted, e);
|
|
165
125
|
}
|
|
166
|
-
|
|
167
126
|
this.setState({
|
|
168
127
|
isDragAccepted: false,
|
|
169
128
|
isDragRejected: false,
|
|
170
129
|
isFileBrowserDisplayed: false
|
|
171
130
|
});
|
|
172
131
|
};
|
|
173
|
-
|
|
174
132
|
this.fileAccepted = file => {
|
|
175
133
|
if (this.props.accept) return (0, _accepts.accepts)(file, this.props.accept);else return true;
|
|
176
134
|
};
|
|
177
|
-
|
|
178
135
|
this.handleRef = el => {
|
|
179
136
|
this.fileInputEl = el;
|
|
180
137
|
};
|
|
181
|
-
|
|
182
138
|
this.handleBlur = () => {
|
|
183
139
|
this.setState({
|
|
184
140
|
isFocused: false,
|
|
185
141
|
isFileBrowserDisplayed: false
|
|
186
142
|
});
|
|
187
143
|
};
|
|
188
|
-
|
|
189
144
|
this.handleFocus = () => {
|
|
190
145
|
this.setState({
|
|
191
146
|
isFocused: true,
|
|
192
147
|
isFileBrowserDisplayed: false
|
|
193
148
|
});
|
|
194
149
|
};
|
|
195
|
-
|
|
196
150
|
this.handleClick = e => {
|
|
197
151
|
var _this$fileInputEl;
|
|
198
|
-
|
|
199
152
|
if (this.fileInputEl.value && this.props.shouldAllowRepeats) {
|
|
200
153
|
this.fileInputEl.value = null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
154
|
+
}
|
|
155
|
+
// focus the input (because FF won't)
|
|
204
156
|
(_this$fileInputEl = this.fileInputEl) === null || _this$fileInputEl === void 0 ? void 0 : _this$fileInputEl.focus();
|
|
205
157
|
this.props.onClick(e);
|
|
206
158
|
this.setState({
|
|
207
159
|
isFileBrowserDisplayed: true
|
|
208
160
|
});
|
|
209
161
|
};
|
|
210
|
-
|
|
211
162
|
this.handleKeyDown = e => {
|
|
212
163
|
if (this.state.isFocused && keyEventIsClickButton(e)) {
|
|
213
164
|
if (this.props.shouldAllowRepeats) {
|
|
@@ -215,7 +166,6 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
215
166
|
}
|
|
216
167
|
}
|
|
217
168
|
};
|
|
218
|
-
|
|
219
169
|
this.handleKeyUp = e => {
|
|
220
170
|
// This is to handle the case where ESC is pressed inside a Dialog so that
|
|
221
171
|
// closing the file browser dialog doesn't also close the Dialog.
|
|
@@ -227,73 +177,57 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
227
177
|
});
|
|
228
178
|
}
|
|
229
179
|
};
|
|
230
|
-
|
|
231
180
|
this.defaultId = props.deterministicId();
|
|
232
181
|
this.messagesId = props.deterministicId('FileDrop-messages');
|
|
233
182
|
}
|
|
234
|
-
|
|
235
183
|
componentDidMount() {
|
|
236
184
|
var _this$props$makeStyle, _this$props5;
|
|
237
|
-
|
|
238
185
|
(_this$props$makeStyle = (_this$props5 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props5, this.makeStyleProps());
|
|
239
186
|
}
|
|
240
|
-
|
|
241
187
|
componentDidUpdate() {
|
|
242
188
|
var _this$props$makeStyle2, _this$props6;
|
|
243
|
-
|
|
244
189
|
(_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
190
|
}
|
|
246
|
-
|
|
247
191
|
convertToFile(fileLikeItem) {
|
|
248
192
|
if (fileLikeItem instanceof DataTransferItem) return fileLikeItem.getAsFile();else return fileLikeItem;
|
|
249
193
|
}
|
|
250
|
-
|
|
251
194
|
get functionallyDisabled() {
|
|
252
195
|
return this.interaction === 'disabled' || this.interaction === 'readonly';
|
|
253
196
|
}
|
|
254
|
-
|
|
255
197
|
get hasMessages() {
|
|
256
198
|
return this.props.messages && this.props.messages.length > 0;
|
|
257
199
|
}
|
|
258
|
-
|
|
259
200
|
get interaction() {
|
|
260
201
|
return (0, _getInteraction.getInteraction)({
|
|
261
202
|
props: this.props
|
|
262
203
|
});
|
|
263
204
|
}
|
|
264
|
-
|
|
265
205
|
get invalid() {
|
|
266
206
|
return this.hasMessages && this.props.messages.findIndex(message => {
|
|
267
207
|
return message.type === 'error';
|
|
268
208
|
}) >= 0;
|
|
269
209
|
}
|
|
270
|
-
|
|
271
210
|
getDataTransferItems(e, shouldEnablePreview) {
|
|
272
211
|
let list = [];
|
|
273
212
|
Array.from((0, _getEventFiles.getEventFiles)(e, this.fileInputEl)).forEach(file => {
|
|
274
213
|
const fileObj = this.convertToFile(file);
|
|
275
214
|
if (fileObj) list.push(fileObj);
|
|
276
215
|
});
|
|
277
|
-
|
|
278
216
|
if (list.length > 1) {
|
|
279
217
|
list = this.props.shouldAllowMultiple ? list : [list[0]];
|
|
280
218
|
}
|
|
281
|
-
|
|
282
219
|
if (shouldEnablePreview) {
|
|
283
220
|
return list.map(file => Object.assign(file, {
|
|
284
221
|
preview: window.URL.createObjectURL(file)
|
|
285
222
|
}));
|
|
286
223
|
}
|
|
287
|
-
|
|
288
224
|
return list;
|
|
289
225
|
}
|
|
290
|
-
|
|
291
226
|
parseFiles(fileList) {
|
|
292
227
|
const accepted = [];
|
|
293
228
|
const rejected = [];
|
|
294
229
|
fileList.forEach(file => {
|
|
295
230
|
const fileObj = this.convertToFile(file);
|
|
296
|
-
|
|
297
231
|
if (fileObj && this.fileAccepted(fileObj) && this.fileMatchSize(fileObj)) {
|
|
298
232
|
accepted.push(file);
|
|
299
233
|
} else {
|
|
@@ -302,20 +236,16 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
302
236
|
});
|
|
303
237
|
return [accepted, rejected];
|
|
304
238
|
}
|
|
305
|
-
|
|
306
239
|
fileMatchSize(file) {
|
|
307
240
|
return file.size <= this.props.maxSize && file.size >= this.props.minSize;
|
|
308
241
|
}
|
|
309
|
-
|
|
310
242
|
allFilesAccepted(files) {
|
|
311
243
|
return files.every(this.fileAccepted);
|
|
312
244
|
}
|
|
313
|
-
|
|
314
245
|
acceptStr() {
|
|
315
246
|
const accept = this.props.accept;
|
|
316
247
|
return accept ? (0, _accepts.getAcceptList)(accept).join(',') : void 0;
|
|
317
248
|
}
|
|
318
|
-
|
|
319
249
|
renderLabel() {
|
|
320
250
|
const renderLabel = this.props.renderLabel;
|
|
321
251
|
return (0, _callRenderProp.callRenderProp)(renderLabel, {
|
|
@@ -324,20 +254,18 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
324
254
|
interaction: this.interaction
|
|
325
255
|
});
|
|
326
256
|
}
|
|
327
|
-
|
|
328
257
|
render() {
|
|
329
258
|
var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
330
|
-
|
|
331
259
|
const _this$props7 = this.props,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
260
|
+
display = _this$props7.display,
|
|
261
|
+
height = _this$props7.height,
|
|
262
|
+
width = _this$props7.width,
|
|
263
|
+
minWidth = _this$props7.minWidth,
|
|
264
|
+
maxWidth = _this$props7.maxWidth,
|
|
265
|
+
margin = _this$props7.margin,
|
|
266
|
+
onDropAccepted = _this$props7.onDropAccepted,
|
|
267
|
+
onDropRejected = _this$props7.onDropRejected,
|
|
268
|
+
props = (0, _objectWithoutProperties2.default)(_this$props7, _excluded);
|
|
341
269
|
const id = this.props.id || this.defaultId;
|
|
342
270
|
const focusColor = this.state.isDragRejected || this.invalid ? 'danger' : void 0;
|
|
343
271
|
return (0, _emotion.jsx)(_View.View, {
|
|
@@ -393,7 +321,6 @@ let FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 =
|
|
|
393
321
|
messages: this.props.messages
|
|
394
322
|
})) : null);
|
|
395
323
|
}
|
|
396
|
-
|
|
397
324
|
}, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
398
325
|
onClick: function (_e) {},
|
|
399
326
|
shouldEnablePreview: false,
|
package/lib/FileDrop/locator.js
CHANGED
package/lib/FileDrop/props.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
13
|
-
|
|
14
10
|
var _emotion = require("@instructure/emotion");
|
|
15
|
-
|
|
16
11
|
/*
|
|
17
12
|
* The MIT License (MIT)
|
|
18
13
|
*
|
|
@@ -36,6 +31,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
36
31
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
32
|
* SOFTWARE.
|
|
38
33
|
*/
|
|
34
|
+
|
|
39
35
|
const propTypes = {
|
|
40
36
|
id: _propTypes.default.string,
|
|
41
37
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]).isRequired,
|
package/lib/FileDrop/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -42,9 +41,9 @@ exports.default = void 0;
|
|
|
42
41
|
const generateStyle = (componentTheme, props, state) => {
|
|
43
42
|
const height = props.height;
|
|
44
43
|
const functionallyDisabled = state.functionallyDisabled,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
visuallyDisabled = state.visuallyDisabled,
|
|
45
|
+
dragRejected = state.dragRejected,
|
|
46
|
+
dragAccepted = state.dragAccepted;
|
|
48
47
|
const dragAcceptedStyle = dragAccepted ? {
|
|
49
48
|
borderColor: componentTheme.acceptedColor
|
|
50
49
|
} : {};
|
|
@@ -57,12 +56,14 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
57
56
|
} : {};
|
|
58
57
|
const visuallyDisabledStyle = visuallyDisabled ? {
|
|
59
58
|
opacity: 0.5
|
|
60
|
-
} : {};
|
|
59
|
+
} : {};
|
|
61
60
|
|
|
61
|
+
// Force the content to fill the space set with the 'height' React prop
|
|
62
62
|
const heightStyle = height ? {
|
|
63
63
|
height: '100%'
|
|
64
|
-
} : {};
|
|
64
|
+
} : {};
|
|
65
65
|
|
|
66
|
+
// border color precedence: normal hover < dragRejected OR dragAccepted
|
|
66
67
|
const hoverBorderColor = !dragAccepted && !dragRejected ? {
|
|
67
68
|
borderColor: componentTheme.hoverBorderColor
|
|
68
69
|
} : {};
|
|
@@ -96,7 +97,8 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
96
97
|
borderRadius: componentTheme.borderRadius,
|
|
97
98
|
border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
|
|
98
99
|
cursor: 'pointer',
|
|
99
|
-
'&:hover': {
|
|
100
|
+
'&:hover': {
|
|
101
|
+
...hoverBorderColor
|
|
100
102
|
},
|
|
101
103
|
...heightStyle,
|
|
102
104
|
...dragAcceptedStyle,
|
|
@@ -111,6 +113,5 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
111
113
|
}
|
|
112
114
|
};
|
|
113
115
|
};
|
|
114
|
-
|
|
115
116
|
var _default = generateStyle;
|
|
116
117
|
exports.default = _default;
|
package/lib/FileDrop/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,8 +35,8 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const colors = theme.colors,
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
borders = theme.borders,
|
|
39
|
+
themeName = theme.key;
|
|
41
40
|
const themeSpecificStyle = {
|
|
42
41
|
canvas: {
|
|
43
42
|
hoverBorderColor: theme['ic-brand-primary'],
|
|
@@ -55,10 +54,10 @@ const generateComponentTheme = theme => {
|
|
|
55
54
|
acceptedColor: colors === null || colors === void 0 ? void 0 : colors.textBrand,
|
|
56
55
|
rejectedColor: colors === null || colors === void 0 ? void 0 : colors.textDanger
|
|
57
56
|
};
|
|
58
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
...componentVariables,
|
|
59
59
|
...themeSpecificStyle[themeName]
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
-
|
|
63
62
|
var _default = generateComponentTheme;
|
|
64
63
|
exports.default = _default;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.accepts = accepts;
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
exports.getAcceptList = getAcceptList;
|
|
9
|
-
|
|
10
9
|
/*
|
|
11
10
|
* The MIT License (MIT)
|
|
12
11
|
*
|
|
@@ -30,6 +29,7 @@ exports.getAcceptList = getAcceptList;
|
|
|
30
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
30
|
* SOFTWARE.
|
|
32
31
|
*/
|
|
32
|
+
|
|
33
33
|
function accepts(file, acceptProp) {
|
|
34
34
|
if (file && acceptProp && file.type !== 'application/x-moz-file') {
|
|
35
35
|
const acceptList = getAcceptList(acceptProp);
|
|
@@ -41,24 +41,19 @@ function accepts(file, acceptProp) {
|
|
|
41
41
|
if (!file.name) {
|
|
42
42
|
return mimeType.endsWith(type.slice(1));
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
return file.name.toLowerCase().endsWith(type.toLowerCase());
|
|
46
45
|
} else if (/\/\*$/.test(type)) {
|
|
47
46
|
// type is something like a image/* mime type
|
|
48
47
|
return baseMimeType === type.replace(/\/.*$/, '');
|
|
49
48
|
}
|
|
50
|
-
|
|
51
49
|
return mimeType === type;
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
|
-
|
|
55
52
|
return true;
|
|
56
53
|
}
|
|
57
|
-
|
|
58
54
|
function getAcceptList(accept) {
|
|
59
55
|
const list = Array.isArray(accept) ? accept : accept.split(',');
|
|
60
56
|
return list.map(a => a.trim().replace(/^\w+$/, '.$&'));
|
|
61
57
|
}
|
|
62
|
-
|
|
63
58
|
var _default = accepts;
|
|
64
59
|
exports.default = _default;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.getEventFiles = getEventFiles;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -29,10 +28,10 @@ exports.getEventFiles = getEventFiles;
|
|
|
29
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
29
|
* SOFTWARE.
|
|
31
30
|
*/
|
|
31
|
+
|
|
32
32
|
function getEventFiles(event, inputEl) {
|
|
33
33
|
if ('dataTransfer' in event) {
|
|
34
34
|
const dt = event.dataTransfer;
|
|
35
|
-
|
|
36
35
|
if (dt) {
|
|
37
36
|
if (dt.files && dt.files.length) {
|
|
38
37
|
return dt.files;
|
|
@@ -43,9 +42,7 @@ function getEventFiles(event, inputEl) {
|
|
|
43
42
|
} else if (inputEl && inputEl.files) {
|
|
44
43
|
return inputEl.files;
|
|
45
44
|
}
|
|
46
|
-
|
|
47
45
|
return [];
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
var _default = getEventFiles;
|
|
51
48
|
exports.default = _default;
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-file-drop",
|
|
3
|
-
"version": "8.33.2
|
|
3
|
+
"version": "8.33.2",
|
|
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.33.2
|
|
28
|
-
"@instructure/emotion": "8.33.2
|
|
29
|
-
"@instructure/shared-types": "8.33.2
|
|
30
|
-
"@instructure/ui-color-utils": "8.33.2
|
|
31
|
-
"@instructure/ui-form-field": "8.33.2
|
|
32
|
-
"@instructure/ui-react-utils": "8.33.2
|
|
33
|
-
"@instructure/ui-testable": "8.33.2
|
|
34
|
-
"@instructure/ui-utils": "8.33.2
|
|
35
|
-
"@instructure/ui-view": "8.33.2
|
|
36
|
-
"@instructure/uid": "8.33.2
|
|
27
|
+
"@instructure/console": "8.33.2",
|
|
28
|
+
"@instructure/emotion": "8.33.2",
|
|
29
|
+
"@instructure/shared-types": "8.33.2",
|
|
30
|
+
"@instructure/ui-color-utils": "8.33.2",
|
|
31
|
+
"@instructure/ui-form-field": "8.33.2",
|
|
32
|
+
"@instructure/ui-react-utils": "8.33.2",
|
|
33
|
+
"@instructure/ui-testable": "8.33.2",
|
|
34
|
+
"@instructure/ui-utils": "8.33.2",
|
|
35
|
+
"@instructure/ui-view": "8.33.2",
|
|
36
|
+
"@instructure/uid": "8.33.2",
|
|
37
37
|
"keycode": "^2",
|
|
38
38
|
"prop-types": "^15"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@instructure/ui-babel-preset": "8.33.2
|
|
42
|
-
"@instructure/ui-test-locator": "8.33.2
|
|
43
|
-
"@instructure/ui-test-utils": "8.33.2
|
|
44
|
-
"@instructure/ui-themes": "8.33.2
|
|
41
|
+
"@instructure/ui-babel-preset": "8.33.2",
|
|
42
|
+
"@instructure/ui-test-locator": "8.33.2",
|
|
43
|
+
"@instructure/ui-test-utils": "8.33.2",
|
|
44
|
+
"@instructure/ui-themes": "8.33.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=16.8 <=18"
|