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