@instructure/ui-file-drop 11.7.3-snapshot-25 → 11.7.3-snapshot-27
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 +5 -2
- package/es/FileDrop/v1/index.js +187 -190
- package/es/FileDrop/v1/styles.js +9 -5
- package/es/FileDrop/v1/theme.js +12 -11
- package/es/FileDrop/v2/index.js +188 -191
- package/es/FileDrop/v2/styles.js +7 -5
- package/lib/FileDrop/v1/index.js +187 -190
- package/lib/FileDrop/v1/styles.js +9 -5
- package/lib/FileDrop/v1/theme.js +12 -11
- package/lib/FileDrop/v2/index.js +188 -191
- package/lib/FileDrop/v2/styles.js +7 -5
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [11.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-27](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-27) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/FileDrop/v1/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
const _excluded = ["display", "height", "width", "minWidth", "maxWidth", "margin", "onDropAccepted", "onDropRejected", "styles"];
|
|
4
|
-
var _dec, _dec2, _class, _FileDrop;
|
|
1
|
+
var _dec, _dec2, _class;
|
|
5
2
|
/*
|
|
6
3
|
* The MIT License (MIT)
|
|
7
4
|
*
|
|
@@ -47,171 +44,57 @@ function keyEventIsClickButton(e) {
|
|
|
47
44
|
category: components
|
|
48
45
|
---
|
|
49
46
|
**/
|
|
50
|
-
let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class =
|
|
47
|
+
let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class FileDrop extends Component {
|
|
48
|
+
static displayName = "FileDrop";
|
|
49
|
+
static componentId = 'FileDrop';
|
|
50
|
+
static allowedProps = allowedProps;
|
|
51
|
+
static defaultProps = {
|
|
52
|
+
onClick: function (_e) {},
|
|
53
|
+
shouldEnablePreview: false,
|
|
54
|
+
shouldAllowMultiple: false,
|
|
55
|
+
shouldAllowRepeats: true,
|
|
56
|
+
maxSize: Infinity,
|
|
57
|
+
minSize: 0,
|
|
58
|
+
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
59
|
+
messages: [],
|
|
60
|
+
display: 'block'
|
|
61
|
+
};
|
|
51
62
|
constructor(props) {
|
|
52
63
|
super(props);
|
|
53
|
-
this.makeStyleProps = () => {
|
|
54
|
-
return {
|
|
55
|
-
functionallyDisabled: this.functionallyDisabled,
|
|
56
|
-
visuallyDisabled: this.interaction === 'disabled',
|
|
57
|
-
dragRejected: this.state.isDragRejected || this.invalid,
|
|
58
|
-
dragAccepted: this.state.isDragAccepted
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
this.state = {
|
|
62
|
-
isDragAccepted: false,
|
|
63
|
-
isDragRejected: false,
|
|
64
|
-
isFocused: false,
|
|
65
|
-
isFileBrowserDisplayed: false
|
|
66
|
-
};
|
|
67
|
-
this.enterCounter = 0;
|
|
68
|
-
this.fileInputEl = void 0;
|
|
69
|
-
this.defaultId = null;
|
|
70
|
-
this.messagesId = '';
|
|
71
|
-
this.ref = null;
|
|
72
|
-
this.handleElementRef = el => {
|
|
73
|
-
this.ref = el;
|
|
74
|
-
};
|
|
75
|
-
this.handleDragEnter = e => {
|
|
76
|
-
var _this$props$onDragEnt, _this$props;
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
// Count the dropzone and any children that are entered.
|
|
79
|
-
this.enterCounter += 1;
|
|
80
|
-
// Don't trigger onDragEnter for each children after the first one
|
|
81
|
-
if (this.enterCounter > 1) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const allFilesAccepted = this.allFilesAccepted(this.getDataTransferItems(e));
|
|
85
|
-
this.setState({
|
|
86
|
-
isDragAccepted: allFilesAccepted,
|
|
87
|
-
isDragRejected: !allFilesAccepted
|
|
88
|
-
});
|
|
89
|
-
(_this$props$onDragEnt = (_this$props = this.props).onDragEnter) === null || _this$props$onDragEnt === void 0 ? void 0 : _this$props$onDragEnt.call(_this$props, e);
|
|
90
|
-
};
|
|
91
|
-
this.handleDragOver = e => {
|
|
92
|
-
var _this$props$onDragOve, _this$props2;
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
try {
|
|
96
|
-
const event = e;
|
|
97
|
-
event.dataTransfer.dropEffect = 'copy';
|
|
98
|
-
} catch (err) {
|
|
99
|
-
// continue regardless of error
|
|
100
|
-
}
|
|
101
|
-
(_this$props$onDragOve = (_this$props2 = this.props).onDragOver) === null || _this$props$onDragOve === void 0 ? void 0 : _this$props$onDragOve.call(_this$props2, e);
|
|
102
|
-
return false;
|
|
103
|
-
};
|
|
104
|
-
this.handleDragLeave = e => {
|
|
105
|
-
var _this$props$onDragLea, _this$props3;
|
|
106
|
-
e.preventDefault();
|
|
107
|
-
this.enterCounter -= 1;
|
|
108
|
-
// Only deactivate once the dropzone and all children was left
|
|
109
|
-
if (this.enterCounter > 0) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.setState({
|
|
113
|
-
isDragAccepted: false,
|
|
114
|
-
isDragRejected: false
|
|
115
|
-
});
|
|
116
|
-
(_this$props$onDragLea = (_this$props3 = this.props).onDragLeave) === null || _this$props$onDragLea === void 0 ? void 0 : _this$props$onDragLea.call(_this$props3, e);
|
|
117
|
-
};
|
|
118
|
-
this.handleChange = e => {
|
|
119
|
-
const _this$props4 = this.props,
|
|
120
|
-
onDrop = _this$props4.onDrop,
|
|
121
|
-
onDropAccepted = _this$props4.onDropAccepted,
|
|
122
|
-
onDropRejected = _this$props4.onDropRejected,
|
|
123
|
-
shouldEnablePreview = _this$props4.shouldEnablePreview;
|
|
124
|
-
const fileList = this.getDataTransferItems(e, shouldEnablePreview);
|
|
125
|
-
const _this$parseFiles = this.parseFiles(fileList),
|
|
126
|
-
_this$parseFiles2 = _slicedToArray(_this$parseFiles, 2),
|
|
127
|
-
accepted = _this$parseFiles2[0],
|
|
128
|
-
rejected = _this$parseFiles2[1];
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
this.enterCounter = 0;
|
|
131
|
-
// When dropping a file the browser does not populate the input's
|
|
132
|
-
// 'files' property, so we need to do it manually. This will also populate
|
|
133
|
-
// the input's 'value' prop, which contains the first file's path
|
|
134
|
-
if (accepted.length > 0 && 'dataTransfer' in e) {
|
|
135
|
-
this.fileInputEl.files = e.dataTransfer.files;
|
|
136
|
-
}
|
|
137
|
-
onDrop && onDrop(accepted, rejected, e);
|
|
138
|
-
if (rejected.length > 0 && onDropRejected) {
|
|
139
|
-
onDropRejected(rejected, e);
|
|
140
|
-
}
|
|
141
|
-
if (accepted.length > 0 && onDropAccepted) {
|
|
142
|
-
onDropAccepted(accepted, e);
|
|
143
|
-
}
|
|
144
|
-
this.setState({
|
|
145
|
-
isDragAccepted: false,
|
|
146
|
-
isDragRejected: false,
|
|
147
|
-
isFileBrowserDisplayed: false
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
this.fileAccepted = file => {
|
|
151
|
-
if (this.props.accept) return accepts(file, this.props.accept);else return true;
|
|
152
|
-
};
|
|
153
|
-
this.handleRef = el => {
|
|
154
|
-
this.fileInputEl = el;
|
|
155
|
-
if (typeof this.props.inputRef === 'function') {
|
|
156
|
-
this.props.inputRef(el);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
this.handleBlur = () => {
|
|
160
|
-
this.setState({
|
|
161
|
-
isFocused: false,
|
|
162
|
-
isFileBrowserDisplayed: false
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
this.handleFocus = () => {
|
|
166
|
-
this.setState({
|
|
167
|
-
isFocused: true,
|
|
168
|
-
isFileBrowserDisplayed: false
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
this.handleClick = e => {
|
|
172
|
-
var _this$fileInputEl;
|
|
173
|
-
if (this.fileInputEl.value && this.props.shouldAllowRepeats) {
|
|
174
|
-
this.fileInputEl.value = null;
|
|
175
|
-
}
|
|
176
|
-
// focus the input (because FF won't)
|
|
177
|
-
(_this$fileInputEl = this.fileInputEl) === null || _this$fileInputEl === void 0 ? void 0 : _this$fileInputEl.focus();
|
|
178
|
-
this.props.onClick(e);
|
|
179
|
-
this.setState({
|
|
180
|
-
isFileBrowserDisplayed: true
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
this.handleKeyDown = e => {
|
|
184
|
-
if (this.state.isFocused && keyEventIsClickButton(e)) {
|
|
185
|
-
if (this.props.shouldAllowRepeats) {
|
|
186
|
-
this.fileInputEl.value = null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
this.handleKeyUp = e => {
|
|
191
|
-
// This is to handle the case where ESC is pressed inside a Dialog so that
|
|
192
|
-
// closing the file browser dialog doesn't also close the Dialog.
|
|
193
|
-
if (e.keyCode === keycode.codes.esc && this.state.isFileBrowserDisplayed) {
|
|
194
|
-
e.stopPropagation();
|
|
195
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
196
|
-
this.setState({
|
|
197
|
-
isFileBrowserDisplayed: false
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
64
|
this.defaultId = props.deterministicId();
|
|
202
65
|
this.messagesId = props.deterministicId('FileDrop-messages');
|
|
203
66
|
}
|
|
204
67
|
componentDidMount() {
|
|
205
|
-
|
|
206
|
-
(_this$props$makeStyle = (_this$props5 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props5, this.makeStyleProps());
|
|
68
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
207
69
|
}
|
|
208
70
|
componentDidUpdate() {
|
|
209
|
-
|
|
210
|
-
(_this$props$makeStyle2 = (_this$props6 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props6, this.makeStyleProps());
|
|
71
|
+
this.props.makeStyles?.(this.makeStyleProps());
|
|
211
72
|
}
|
|
212
73
|
convertToFile(fileLikeItem) {
|
|
213
74
|
if (fileLikeItem instanceof DataTransferItem) return fileLikeItem.getAsFile();else return fileLikeItem;
|
|
214
75
|
}
|
|
76
|
+
makeStyleProps = () => {
|
|
77
|
+
return {
|
|
78
|
+
functionallyDisabled: this.functionallyDisabled,
|
|
79
|
+
visuallyDisabled: this.interaction === 'disabled',
|
|
80
|
+
dragRejected: this.state.isDragRejected || this.invalid,
|
|
81
|
+
dragAccepted: this.state.isDragAccepted
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
state = {
|
|
85
|
+
isDragAccepted: false,
|
|
86
|
+
isDragRejected: false,
|
|
87
|
+
isFocused: false,
|
|
88
|
+
isFileBrowserDisplayed: false
|
|
89
|
+
};
|
|
90
|
+
enterCounter = 0;
|
|
91
|
+
fileInputEl;
|
|
92
|
+
defaultId = null;
|
|
93
|
+
messagesId = '';
|
|
94
|
+
ref = null;
|
|
95
|
+
handleElementRef = el => {
|
|
96
|
+
this.ref = el;
|
|
97
|
+
};
|
|
215
98
|
get functionallyDisabled() {
|
|
216
99
|
return this.interaction === 'disabled' || this.interaction === 'readonly';
|
|
217
100
|
}
|
|
@@ -247,6 +130,46 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
247
130
|
}
|
|
248
131
|
return list;
|
|
249
132
|
}
|
|
133
|
+
handleDragEnter = e => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
// Count the dropzone and any children that are entered.
|
|
136
|
+
this.enterCounter += 1;
|
|
137
|
+
// Don't trigger onDragEnter for each children after the first one
|
|
138
|
+
if (this.enterCounter > 1) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const allFilesAccepted = this.allFilesAccepted(this.getDataTransferItems(e));
|
|
142
|
+
this.setState({
|
|
143
|
+
isDragAccepted: allFilesAccepted,
|
|
144
|
+
isDragRejected: !allFilesAccepted
|
|
145
|
+
});
|
|
146
|
+
this.props.onDragEnter?.(e);
|
|
147
|
+
};
|
|
148
|
+
handleDragOver = e => {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
try {
|
|
152
|
+
const event = e;
|
|
153
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
154
|
+
} catch (err) {
|
|
155
|
+
// continue regardless of error
|
|
156
|
+
}
|
|
157
|
+
this.props.onDragOver?.(e);
|
|
158
|
+
return false;
|
|
159
|
+
};
|
|
160
|
+
handleDragLeave = e => {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
this.enterCounter -= 1;
|
|
163
|
+
// Only deactivate once the dropzone and all children was left
|
|
164
|
+
if (this.enterCounter > 0) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.setState({
|
|
168
|
+
isDragAccepted: false,
|
|
169
|
+
isDragRejected: false
|
|
170
|
+
});
|
|
171
|
+
this.props.onDragLeave?.(e);
|
|
172
|
+
};
|
|
250
173
|
parseFiles(fileList) {
|
|
251
174
|
const accepted = [];
|
|
252
175
|
const rejected = [];
|
|
@@ -260,6 +183,39 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
260
183
|
});
|
|
261
184
|
return [accepted, rejected];
|
|
262
185
|
}
|
|
186
|
+
handleChange = e => {
|
|
187
|
+
const {
|
|
188
|
+
onDrop,
|
|
189
|
+
onDropAccepted,
|
|
190
|
+
onDropRejected,
|
|
191
|
+
shouldEnablePreview
|
|
192
|
+
} = this.props;
|
|
193
|
+
const fileList = this.getDataTransferItems(e, shouldEnablePreview);
|
|
194
|
+
const [accepted, rejected] = this.parseFiles(fileList);
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
this.enterCounter = 0;
|
|
197
|
+
// When dropping a file the browser does not populate the input's
|
|
198
|
+
// 'files' property, so we need to do it manually. This will also populate
|
|
199
|
+
// the input's 'value' prop, which contains the first file's path
|
|
200
|
+
if (accepted.length > 0 && 'dataTransfer' in e) {
|
|
201
|
+
this.fileInputEl.files = e.dataTransfer.files;
|
|
202
|
+
}
|
|
203
|
+
onDrop && onDrop(accepted, rejected, e);
|
|
204
|
+
if (rejected.length > 0 && onDropRejected) {
|
|
205
|
+
onDropRejected(rejected, e);
|
|
206
|
+
}
|
|
207
|
+
if (accepted.length > 0 && onDropAccepted) {
|
|
208
|
+
onDropAccepted(accepted, e);
|
|
209
|
+
}
|
|
210
|
+
this.setState({
|
|
211
|
+
isDragAccepted: false,
|
|
212
|
+
isDragRejected: false,
|
|
213
|
+
isFileBrowserDisplayed: false
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
fileAccepted = file => {
|
|
217
|
+
if (this.props.accept) return accepts(file, this.props.accept);else return true;
|
|
218
|
+
};
|
|
263
219
|
fileMatchSize(file) {
|
|
264
220
|
return file.size <= this.props.maxSize && file.size >= this.props.minSize;
|
|
265
221
|
}
|
|
@@ -267,32 +223,83 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
267
223
|
return files.every(this.fileAccepted);
|
|
268
224
|
}
|
|
269
225
|
acceptStr() {
|
|
270
|
-
const
|
|
271
|
-
|
|
226
|
+
const {
|
|
227
|
+
accept
|
|
228
|
+
} = this.props;
|
|
229
|
+
return accept ? getAcceptList(accept).join(',') : undefined;
|
|
272
230
|
}
|
|
273
231
|
renderLabel() {
|
|
274
|
-
const
|
|
232
|
+
const {
|
|
233
|
+
renderLabel
|
|
234
|
+
} = this.props;
|
|
275
235
|
return callRenderProp(renderLabel, {
|
|
276
236
|
isDragAccepted: this.state.isDragAccepted,
|
|
277
237
|
isDragRejected: this.state.isDragRejected,
|
|
278
238
|
interaction: this.interaction
|
|
279
239
|
});
|
|
280
240
|
}
|
|
241
|
+
handleRef = el => {
|
|
242
|
+
this.fileInputEl = el;
|
|
243
|
+
if (typeof this.props.inputRef === 'function') {
|
|
244
|
+
this.props.inputRef(el);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
handleBlur = () => {
|
|
248
|
+
this.setState({
|
|
249
|
+
isFocused: false,
|
|
250
|
+
isFileBrowserDisplayed: false
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
handleFocus = () => {
|
|
254
|
+
this.setState({
|
|
255
|
+
isFocused: true,
|
|
256
|
+
isFileBrowserDisplayed: false
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
handleClick = e => {
|
|
260
|
+
if (this.fileInputEl.value && this.props.shouldAllowRepeats) {
|
|
261
|
+
this.fileInputEl.value = null;
|
|
262
|
+
}
|
|
263
|
+
// focus the input (because FF won't)
|
|
264
|
+
this.fileInputEl?.focus();
|
|
265
|
+
this.props.onClick(e);
|
|
266
|
+
this.setState({
|
|
267
|
+
isFileBrowserDisplayed: true
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
handleKeyDown = e => {
|
|
271
|
+
if (this.state.isFocused && keyEventIsClickButton(e)) {
|
|
272
|
+
if (this.props.shouldAllowRepeats) {
|
|
273
|
+
this.fileInputEl.value = null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
handleKeyUp = e => {
|
|
278
|
+
// This is to handle the case where ESC is pressed inside a Dialog so that
|
|
279
|
+
// closing the file browser dialog doesn't also close the Dialog.
|
|
280
|
+
if (e.keyCode === keycode.codes.esc && this.state.isFileBrowserDisplayed) {
|
|
281
|
+
e.stopPropagation();
|
|
282
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
283
|
+
this.setState({
|
|
284
|
+
isFileBrowserDisplayed: false
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
};
|
|
281
288
|
render() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
289
|
+
const {
|
|
290
|
+
display,
|
|
291
|
+
height,
|
|
292
|
+
width,
|
|
293
|
+
minWidth,
|
|
294
|
+
maxWidth,
|
|
295
|
+
margin,
|
|
296
|
+
onDropAccepted,
|
|
297
|
+
onDropRejected,
|
|
298
|
+
styles,
|
|
299
|
+
...props
|
|
300
|
+
} = this.props;
|
|
294
301
|
const id = this.props.id || this.defaultId;
|
|
295
|
-
const focusColor = this.state.isDragRejected || this.invalid ? 'danger' :
|
|
302
|
+
const focusColor = this.state.isDragRejected || this.invalid ? 'danger' : undefined;
|
|
296
303
|
return _jsxs(View, {
|
|
297
304
|
display: display,
|
|
298
305
|
position: "relative" // contain visually hidden file input element
|
|
@@ -305,23 +312,23 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
305
312
|
elementRef: this.handleElementRef,
|
|
306
313
|
"data-cid": "FileDrop",
|
|
307
314
|
children: [_jsx("label", {
|
|
308
|
-
css:
|
|
315
|
+
css: this.props.styles?.fileDropLabel,
|
|
309
316
|
htmlFor: id,
|
|
310
317
|
onDragEnter: this.handleDragEnter,
|
|
311
318
|
onDragOver: this.handleDragOver,
|
|
312
319
|
onDragLeave: this.handleDragLeave,
|
|
313
320
|
onDrop: this.handleChange,
|
|
314
321
|
children: _jsx(View, {
|
|
315
|
-
borderRadius: String(styles
|
|
322
|
+
borderRadius: String(styles?.fileDropLayout?.borderRadius),
|
|
316
323
|
display: "block",
|
|
317
324
|
position: "relative",
|
|
318
325
|
withFocusOutline: this.state.isFocused,
|
|
319
326
|
focusColor: focusColor,
|
|
320
327
|
height: height,
|
|
321
328
|
children: _jsx("span", {
|
|
322
|
-
css:
|
|
329
|
+
css: this.props.styles?.fileDropLabelContent,
|
|
323
330
|
children: _jsx("span", {
|
|
324
|
-
css:
|
|
331
|
+
css: this.props.styles?.fileDropLayout,
|
|
325
332
|
children: _jsx(View, {
|
|
326
333
|
height: height,
|
|
327
334
|
children: this.renderLabel()
|
|
@@ -333,7 +340,7 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
333
340
|
...passthroughProps(props),
|
|
334
341
|
onClick: this.handleClick,
|
|
335
342
|
type: "file",
|
|
336
|
-
css:
|
|
343
|
+
css: this.props.styles?.fileDropInput,
|
|
337
344
|
id: id,
|
|
338
345
|
ref: this.handleRef,
|
|
339
346
|
onFocus: this.handleFocus,
|
|
@@ -343,7 +350,7 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
343
350
|
multiple: this.props.shouldAllowMultiple,
|
|
344
351
|
accept: this.acceptStr(),
|
|
345
352
|
onChange: this.handleChange,
|
|
346
|
-
"aria-describedby": this.hasMessages ? this.messagesId :
|
|
353
|
+
"aria-describedby": this.hasMessages ? this.messagesId : undefined,
|
|
347
354
|
"aria-invalid": this.invalid,
|
|
348
355
|
disabled: this.functionallyDisabled
|
|
349
356
|
}), this.hasMessages ? _jsx(View, {
|
|
@@ -356,16 +363,6 @@ let FileDrop = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
356
363
|
}) : null]
|
|
357
364
|
});
|
|
358
365
|
}
|
|
359
|
-
}
|
|
360
|
-
onClick: function (_e) {},
|
|
361
|
-
shouldEnablePreview: false,
|
|
362
|
-
shouldAllowMultiple: false,
|
|
363
|
-
shouldAllowRepeats: true,
|
|
364
|
-
maxSize: Infinity,
|
|
365
|
-
minSize: 0,
|
|
366
|
-
// Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
|
|
367
|
-
messages: [],
|
|
368
|
-
display: 'block'
|
|
369
|
-
}, _FileDrop)) || _class) || _class);
|
|
366
|
+
}) || _class) || _class);
|
|
370
367
|
export default FileDrop;
|
|
371
368
|
export { FileDrop };
|
package/es/FileDrop/v1/styles.js
CHANGED
|
@@ -33,11 +33,15 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const {
|
|
37
|
+
height
|
|
38
|
+
} = props;
|
|
39
|
+
const {
|
|
40
|
+
functionallyDisabled,
|
|
41
|
+
visuallyDisabled,
|
|
42
|
+
dragRejected,
|
|
43
|
+
dragAccepted
|
|
44
|
+
} = state;
|
|
41
45
|
const dragAcceptedStyle = dragAccepted ? {
|
|
42
46
|
borderColor: componentTheme.acceptedColor
|
|
43
47
|
} : {};
|
package/es/FileDrop/v1/theme.js
CHANGED
|
@@ -28,10 +28,11 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
borders
|
|
34
|
-
themeName
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
borders,
|
|
34
|
+
key: themeName
|
|
35
|
+
} = theme;
|
|
35
36
|
const themeSpecificStyle = {
|
|
36
37
|
canvas: {
|
|
37
38
|
hoverBorderColor: theme['ic-brand-primary'],
|
|
@@ -39,14 +40,14 @@ const generateComponentTheme = theme => {
|
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
const componentVariables = {
|
|
42
|
-
backgroundColor: colors
|
|
43
|
-
borderRadius: borders
|
|
44
|
-
borderWidth: borders
|
|
43
|
+
backgroundColor: colors?.contrasts?.white1010,
|
|
44
|
+
borderRadius: borders?.radiusLarge,
|
|
45
|
+
borderWidth: borders?.widthMedium,
|
|
45
46
|
borderStyle: 'dashed',
|
|
46
|
-
borderColor: colors
|
|
47
|
-
hoverBorderColor: colors
|
|
48
|
-
acceptedColor: colors
|
|
49
|
-
rejectedColor: colors
|
|
47
|
+
borderColor: colors?.contrasts?.grey1424,
|
|
48
|
+
hoverBorderColor: colors?.contrasts?.blue4570,
|
|
49
|
+
acceptedColor: colors?.contrasts?.blue4570,
|
|
50
|
+
rejectedColor: colors?.contrasts?.red4570
|
|
50
51
|
};
|
|
51
52
|
return {
|
|
52
53
|
...componentVariables,
|