@instructure/ui-file-drop 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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 CHANGED
@@ -3,6 +3,14 @@
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.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-file-drop
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-file-drop
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
31
- const allowedProps = exports.allowedProps = ['id', 'renderLabel', 'accept', 'messages', 'onClick', 'onDrop', 'onDropAccepted', 'onDropRejected', 'onDragEnter', 'onDragOver', 'onDragLeave', 'shouldEnablePreview', 'shouldAllowMultiple', 'shouldAllowRepeats', 'maxSize', 'minSize', 'interaction', 'display', 'height', 'width', 'maxWidth', 'minWidth', 'margin', 'inputRef'];
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-file-drop",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A flexible facade for an HTML file input",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -16,23 +16,23 @@
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
18
  "keycode": "^2",
19
- "@instructure/console": "11.6.0",
20
- "@instructure/emotion": "11.6.0",
21
- "@instructure/shared-types": "11.6.0",
22
- "@instructure/ui-color-utils": "11.6.0",
23
- "@instructure/ui-form-field": "11.6.0",
24
- "@instructure/ui-react-utils": "11.6.0",
25
- "@instructure/ui-utils": "11.6.0",
26
- "@instructure/ui-view": "11.6.0",
27
- "@instructure/uid": "11.6.0"
19
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
26
+ "@instructure/uid": "11.6.1-pr-snapshot-1779894247159",
27
+ "@instructure/ui-view": "11.6.1-pr-snapshot-1779894247159"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@testing-library/jest-dom": "^6.6.3",
31
31
  "@testing-library/react": "15.0.7",
32
32
  "vitest": "^3.2.2",
33
- "@instructure/ui-axe-check": "11.6.0",
34
- "@instructure/ui-babel-preset": "11.6.0",
35
- "@instructure/ui-themes": "11.6.0"
33
+ "@instructure/ui-axe-check": "11.6.1-pr-snapshot-1779894247159",
34
+ "@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159",
35
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=18 <=19"
@@ -45,10 +45,8 @@
45
45
  ".": {
46
46
  "types": "./types/index.d.ts",
47
47
  "import": "./es/index.js",
48
- "require": "./lib/index.js",
49
48
  "default": "./es/index.js"
50
49
  },
51
- "./lib/*": "./lib/*",
52
50
  "./es/*": "./es/*",
53
51
  "./types/*": "./types/*",
54
52
  "./package.json": "./package.json",
@@ -58,7 +56,7 @@
58
56
  "lint": "ui-scripts lint",
59
57
  "lint:fix": "ui-scripts lint --fix",
60
58
  "clean": "ui-scripts clean",
61
- "build": "ui-scripts build --modules es,cjs",
59
+ "build": "ui-scripts build",
62
60
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
63
61
  "build:types": "tsc -p tsconfig.build.json",
64
62
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,379 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = exports.FileDrop = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = require("react");
11
- var _keycode = _interopRequireDefault(require("keycode"));
12
- var _FormFieldMessages = require("@instructure/ui-form-field/lib/FormFieldMessages");
13
- var _View = require("@instructure/ui-view/lib/View");
14
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
15
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
16
- var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
17
- var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
18
- var _accepts = require("./utils/accepts");
19
- var _getEventFiles = require("./utils/getEventFiles");
20
- var _emotion = require("@instructure/emotion");
21
- var _styles = _interopRequireDefault(require("./styles"));
22
- var _theme = _interopRequireDefault(require("./theme"));
23
- var _props = require("./props");
24
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
25
- const _excluded = ["display", "height", "width", "minWidth", "maxWidth", "margin", "onDropAccepted", "onDropRejected", "styles"];
26
- var _dec, _dec2, _class, _FileDrop;
27
- /*
28
- * The MIT License (MIT)
29
- *
30
- * Copyright (c) 2015 - present Instructure, Inc.
31
- *
32
- * Permission is hereby granted, free of charge, to any person obtaining a copy
33
- * of this software and associated documentation files (the "Software"), to deal
34
- * in the Software without restriction, including without limitation the rights
35
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
- * copies of the Software, and to permit persons to whom the Software is
37
- * furnished to do so, subject to the following conditions:
38
- *
39
- * The above copyright notice and this permission notice shall be included in all
40
- * copies or substantial portions of the Software.
41
- *
42
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
- * SOFTWARE.
49
- */
50
- function keyEventIsClickButton(e) {
51
- return e.keyCode === _keycode.default.codes.space || e.keyCode === _keycode.default.codes.enter;
52
- }
53
-
54
- /**
55
- ---
56
- category: components
57
- ---
58
- **/
59
- let FileDrop = exports.FileDrop = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_FileDrop = class FileDrop extends _react.Component {
60
- constructor(props) {
61
- super(props);
62
- this.makeStyleProps = () => {
63
- return {
64
- functionallyDisabled: this.functionallyDisabled,
65
- visuallyDisabled: this.interaction === 'disabled',
66
- dragRejected: this.state.isDragRejected || this.invalid,
67
- dragAccepted: this.state.isDragAccepted
68
- };
69
- };
70
- this.state = {
71
- isDragAccepted: false,
72
- isDragRejected: false,
73
- isFocused: false,
74
- isFileBrowserDisplayed: false
75
- };
76
- this.enterCounter = 0;
77
- this.fileInputEl = void 0;
78
- this.defaultId = null;
79
- this.messagesId = '';
80
- this.ref = null;
81
- this.handleElementRef = el => {
82
- this.ref = el;
83
- };
84
- this.handleDragEnter = e => {
85
- var _this$props$onDragEnt, _this$props;
86
- e.preventDefault();
87
- // Count the dropzone and any children that are entered.
88
- this.enterCounter += 1;
89
- // Don't trigger onDragEnter for each children after the first one
90
- if (this.enterCounter > 1) {
91
- return;
92
- }
93
- const allFilesAccepted = this.allFilesAccepted(this.getDataTransferItems(e));
94
- this.setState({
95
- isDragAccepted: allFilesAccepted,
96
- isDragRejected: !allFilesAccepted
97
- });
98
- (_this$props$onDragEnt = (_this$props = this.props).onDragEnter) === null || _this$props$onDragEnt === void 0 ? void 0 : _this$props$onDragEnt.call(_this$props, e);
99
- };
100
- this.handleDragOver = e => {
101
- var _this$props$onDragOve, _this$props2;
102
- e.preventDefault();
103
- e.stopPropagation();
104
- try {
105
- const event = e;
106
- event.dataTransfer.dropEffect = 'copy';
107
- } catch (err) {
108
- // continue regardless of error
109
- }
110
- (_this$props$onDragOve = (_this$props2 = this.props).onDragOver) === null || _this$props$onDragOve === void 0 ? void 0 : _this$props$onDragOve.call(_this$props2, e);
111
- return false;
112
- };
113
- this.handleDragLeave = e => {
114
- var _this$props$onDragLea, _this$props3;
115
- e.preventDefault();
116
- this.enterCounter -= 1;
117
- // Only deactivate once the dropzone and all children was left
118
- if (this.enterCounter > 0) {
119
- return;
120
- }
121
- this.setState({
122
- isDragAccepted: false,
123
- isDragRejected: false
124
- });
125
- (_this$props$onDragLea = (_this$props3 = this.props).onDragLeave) === null || _this$props$onDragLea === void 0 ? void 0 : _this$props$onDragLea.call(_this$props3, e);
126
- };
127
- this.handleChange = e => {
128
- const _this$props4 = this.props,
129
- onDrop = _this$props4.onDrop,
130
- onDropAccepted = _this$props4.onDropAccepted,
131
- onDropRejected = _this$props4.onDropRejected,
132
- shouldEnablePreview = _this$props4.shouldEnablePreview;
133
- const fileList = this.getDataTransferItems(e, shouldEnablePreview);
134
- const _this$parseFiles = this.parseFiles(fileList),
135
- _this$parseFiles2 = (0, _slicedToArray2.default)(_this$parseFiles, 2),
136
- accepted = _this$parseFiles2[0],
137
- rejected = _this$parseFiles2[1];
138
- e.preventDefault();
139
- this.enterCounter = 0;
140
- // When dropping a file the browser does not populate the input's
141
- // 'files' property, so we need to do it manually. This will also populate
142
- // the input's 'value' prop, which contains the first file's path
143
- if (accepted.length > 0 && 'dataTransfer' in e) {
144
- this.fileInputEl.files = e.dataTransfer.files;
145
- }
146
- onDrop && onDrop(accepted, rejected, e);
147
- if (rejected.length > 0 && onDropRejected) {
148
- onDropRejected(rejected, e);
149
- }
150
- if (accepted.length > 0 && onDropAccepted) {
151
- onDropAccepted(accepted, e);
152
- }
153
- this.setState({
154
- isDragAccepted: false,
155
- isDragRejected: false,
156
- isFileBrowserDisplayed: false
157
- });
158
- };
159
- this.fileAccepted = file => {
160
- if (this.props.accept) return (0, _accepts.accepts)(file, this.props.accept);else return true;
161
- };
162
- this.handleRef = el => {
163
- this.fileInputEl = el;
164
- if (typeof this.props.inputRef === 'function') {
165
- this.props.inputRef(el);
166
- }
167
- };
168
- this.handleBlur = () => {
169
- this.setState({
170
- isFocused: false,
171
- isFileBrowserDisplayed: false
172
- });
173
- };
174
- this.handleFocus = () => {
175
- this.setState({
176
- isFocused: true,
177
- isFileBrowserDisplayed: false
178
- });
179
- };
180
- this.handleClick = e => {
181
- var _this$fileInputEl;
182
- if (this.fileInputEl.value && this.props.shouldAllowRepeats) {
183
- this.fileInputEl.value = null;
184
- }
185
- // focus the input (because FF won't)
186
- (_this$fileInputEl = this.fileInputEl) === null || _this$fileInputEl === void 0 ? void 0 : _this$fileInputEl.focus();
187
- this.props.onClick(e);
188
- this.setState({
189
- isFileBrowserDisplayed: true
190
- });
191
- };
192
- this.handleKeyDown = e => {
193
- if (this.state.isFocused && keyEventIsClickButton(e)) {
194
- if (this.props.shouldAllowRepeats) {
195
- this.fileInputEl.value = null;
196
- }
197
- }
198
- };
199
- this.handleKeyUp = e => {
200
- // This is to handle the case where ESC is pressed inside a Dialog so that
201
- // closing the file browser dialog doesn't also close the Dialog.
202
- if (e.keyCode === _keycode.default.codes.esc && this.state.isFileBrowserDisplayed) {
203
- e.stopPropagation();
204
- e.nativeEvent.stopImmediatePropagation();
205
- this.setState({
206
- isFileBrowserDisplayed: false
207
- });
208
- }
209
- };
210
- this.defaultId = props.deterministicId();
211
- this.messagesId = props.deterministicId('FileDrop-messages');
212
- }
213
- componentDidMount() {
214
- var _this$props$makeStyle, _this$props5;
215
- (_this$props$makeStyle = (_this$props5 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props5, this.makeStyleProps());
216
- }
217
- componentDidUpdate() {
218
- var _this$props$makeStyle2, _this$props6;
219
- (_this$props$makeStyle2 = (_this$props6 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props6, this.makeStyleProps());
220
- }
221
- convertToFile(fileLikeItem) {
222
- if (fileLikeItem instanceof DataTransferItem) return fileLikeItem.getAsFile();else return fileLikeItem;
223
- }
224
- get functionallyDisabled() {
225
- return this.interaction === 'disabled' || this.interaction === 'readonly';
226
- }
227
- get interaction() {
228
- return (0, _getInteraction.getInteraction)({
229
- props: this.props
230
- });
231
- }
232
- get hasMessages() {
233
- return this.props.messages ? this.props.messages.length > 0 : false;
234
- }
235
- get invalid() {
236
- if (this.hasMessages) {
237
- return this.props.messages.findIndex(message => {
238
- return message.type === 'error' || message.type === 'newError';
239
- }) >= 0;
240
- }
241
- return false;
242
- }
243
- getDataTransferItems(e, shouldEnablePreview) {
244
- let list = [];
245
- Array.from((0, _getEventFiles.getEventFiles)(e, this.fileInputEl)).forEach(file => {
246
- const fileObj = this.convertToFile(file);
247
- if (fileObj) list.push(fileObj);
248
- });
249
- if (list.length > 1) {
250
- list = this.props.shouldAllowMultiple ? list : [list[0]];
251
- }
252
- if (shouldEnablePreview) {
253
- return list.map(file => Object.assign(file, {
254
- preview: window.URL.createObjectURL(file)
255
- }));
256
- }
257
- return list;
258
- }
259
- parseFiles(fileList) {
260
- const accepted = [];
261
- const rejected = [];
262
- fileList.forEach(file => {
263
- const fileObj = this.convertToFile(file);
264
- if (fileObj && this.fileAccepted(fileObj) && this.fileMatchSize(fileObj)) {
265
- accepted.push(file);
266
- } else {
267
- rejected.push(file);
268
- }
269
- });
270
- return [accepted, rejected];
271
- }
272
- fileMatchSize(file) {
273
- return file.size <= this.props.maxSize && file.size >= this.props.minSize;
274
- }
275
- allFilesAccepted(files) {
276
- return files.every(this.fileAccepted);
277
- }
278
- acceptStr() {
279
- const accept = this.props.accept;
280
- return accept ? (0, _accepts.getAcceptList)(accept).join(',') : void 0;
281
- }
282
- renderLabel() {
283
- const renderLabel = this.props.renderLabel;
284
- return (0, _callRenderProp.callRenderProp)(renderLabel, {
285
- isDragAccepted: this.state.isDragAccepted,
286
- isDragRejected: this.state.isDragRejected,
287
- interaction: this.interaction
288
- });
289
- }
290
- render() {
291
- var _this$props$styles, _styles$fileDropLayou, _this$props$styles2, _this$props$styles3, _this$props$styles4;
292
- const _this$props7 = this.props,
293
- display = _this$props7.display,
294
- height = _this$props7.height,
295
- width = _this$props7.width,
296
- minWidth = _this$props7.minWidth,
297
- maxWidth = _this$props7.maxWidth,
298
- margin = _this$props7.margin,
299
- onDropAccepted = _this$props7.onDropAccepted,
300
- onDropRejected = _this$props7.onDropRejected,
301
- styles = _this$props7.styles,
302
- props = (0, _objectWithoutProperties2.default)(_this$props7, _excluded);
303
- const id = this.props.id || this.defaultId;
304
- const focusColor = this.state.isDragRejected || this.invalid ? 'danger' : void 0;
305
- return (0, _jsxRuntime.jsxs)(_View.View, {
306
- display: display,
307
- position: "relative" // contain visually hidden file input element
308
- ,
309
- width: width,
310
- minWidth: minWidth,
311
- maxWidth: maxWidth,
312
- margin: margin,
313
- height: height,
314
- elementRef: this.handleElementRef,
315
- "data-cid": "FileDrop",
316
- children: [(0, _jsxRuntime.jsx)("label", {
317
- css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.fileDropLabel,
318
- htmlFor: id,
319
- onDragEnter: this.handleDragEnter,
320
- onDragOver: this.handleDragOver,
321
- onDragLeave: this.handleDragLeave,
322
- onDrop: this.handleChange,
323
- children: (0, _jsxRuntime.jsx)(_View.View, {
324
- borderRadius: String(styles === null || styles === void 0 ? void 0 : (_styles$fileDropLayou = styles.fileDropLayout) === null || _styles$fileDropLayou === void 0 ? void 0 : _styles$fileDropLayou.borderRadius),
325
- display: "block",
326
- position: "relative",
327
- withFocusOutline: this.state.isFocused,
328
- focusColor: focusColor,
329
- height: height,
330
- children: (0, _jsxRuntime.jsx)("span", {
331
- css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.fileDropLabelContent,
332
- children: (0, _jsxRuntime.jsx)("span", {
333
- css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.fileDropLayout,
334
- children: (0, _jsxRuntime.jsx)(_View.View, {
335
- height: height,
336
- children: this.renderLabel()
337
- })
338
- })
339
- })
340
- })
341
- }), (0, _jsxRuntime.jsx)("input", {
342
- ...(0, _passthroughProps.passthroughProps)(props),
343
- onClick: this.handleClick,
344
- type: "file",
345
- css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.fileDropInput,
346
- id: id,
347
- ref: this.handleRef,
348
- onFocus: this.handleFocus,
349
- onBlur: this.handleBlur,
350
- onKeyDown: this.handleKeyDown,
351
- onKeyUp: this.handleKeyUp,
352
- multiple: this.props.shouldAllowMultiple,
353
- accept: this.acceptStr(),
354
- onChange: this.handleChange,
355
- "aria-describedby": this.hasMessages ? this.messagesId : void 0,
356
- "aria-invalid": this.invalid,
357
- disabled: this.functionallyDisabled
358
- }), this.hasMessages ? (0, _jsxRuntime.jsx)(_View.View, {
359
- display: "block",
360
- margin: "small 0 0",
361
- children: (0, _jsxRuntime.jsx)(_FormFieldMessages.FormFieldMessages, {
362
- id: this.messagesId,
363
- messages: this.props.messages
364
- })
365
- }) : null]
366
- });
367
- }
368
- }, _FileDrop.displayName = "FileDrop", _FileDrop.componentId = 'FileDrop', _FileDrop.allowedProps = _props.allowedProps, _FileDrop.defaultProps = {
369
- onClick: function (_e) {},
370
- shouldEnablePreview: false,
371
- shouldAllowMultiple: false,
372
- shouldAllowRepeats: true,
373
- maxSize: Infinity,
374
- minSize: 0,
375
- // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
376
- messages: [],
377
- display: 'block'
378
- }, _FileDrop)) || _class) || _class);
379
- var _default = exports.default = FileDrop;
@@ -1,116 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props, state) => {
42
- const height = props.height;
43
- const functionallyDisabled = state.functionallyDisabled,
44
- visuallyDisabled = state.visuallyDisabled,
45
- dragRejected = state.dragRejected,
46
- dragAccepted = state.dragAccepted;
47
- const dragAcceptedStyle = dragAccepted ? {
48
- borderColor: componentTheme.acceptedColor
49
- } : {};
50
- const dragRejectedStyle = dragRejected ? {
51
- borderColor: componentTheme.rejectedColor
52
- } : {};
53
- const functionallyDisabledStyle = functionallyDisabled ? {
54
- cursor: 'not-allowed',
55
- pointerEvents: 'none'
56
- } : {};
57
- const visuallyDisabledStyle = visuallyDisabled ? {
58
- opacity: 0.5
59
- } : {};
60
-
61
- // Force the content to fill the space set with the 'height' React prop
62
- const heightStyle = height ? {
63
- height: '100%'
64
- } : {};
65
-
66
- // border color precedence: normal hover < dragRejected OR dragAccepted
67
- const hoverBorderColor = !dragAccepted && !dragRejected ? {
68
- borderColor: componentTheme.hoverBorderColor
69
- } : {};
70
- return {
71
- fileDropLabel: {
72
- label: 'fileDrop__label',
73
- display: 'block',
74
- boxSizing: 'border-box',
75
- position: 'relative',
76
- ...heightStyle,
77
- ...functionallyDisabledStyle,
78
- ...visuallyDisabledStyle
79
- },
80
- fileDropInput: {
81
- label: 'fileDrop__input',
82
- width: '0.0625rem',
83
- height: '0.0625rem',
84
- margin: '-0.0625rem',
85
- padding: 0,
86
- position: 'absolute',
87
- overflow: 'hidden',
88
- clip: 'rect(0 0 0 0)',
89
- border: 0
90
- },
91
- fileDropLabelContent: {
92
- label: 'fileDrop__labelContent',
93
- display: 'block',
94
- boxSizing: 'border-box',
95
- zIndex: 1,
96
- textAlign: 'center',
97
- borderRadius: componentTheme.borderRadius,
98
- border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
99
- cursor: 'pointer',
100
- '&:hover': {
101
- ...hoverBorderColor
102
- },
103
- ...heightStyle,
104
- ...dragAcceptedStyle,
105
- ...dragRejectedStyle
106
- },
107
- fileDropLayout: {
108
- label: 'fileDrop__layout',
109
- display: 'block',
110
- overflow: 'hidden',
111
- borderRadius: componentTheme.borderRadius,
112
- ...heightStyle
113
- }
114
- };
115
- };
116
- var _default = exports.default = generateStyle;
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5;
38
- const colors = theme.colors,
39
- borders = theme.borders,
40
- themeName = theme.key;
41
- const themeSpecificStyle = {
42
- canvas: {
43
- hoverBorderColor: theme['ic-brand-primary'],
44
- acceptedColor: theme['ic-brand-primary']
45
- }
46
- };
47
- const componentVariables = {
48
- backgroundColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.white1010,
49
- borderRadius: borders === null || borders === void 0 ? void 0 : borders.radiusLarge,
50
- borderWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
51
- borderStyle: 'dashed',
52
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey1424,
53
- hoverBorderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.blue4570,
54
- acceptedColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.blue4570,
55
- rejectedColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.red4570
56
- };
57
- return {
58
- ...componentVariables,
59
- ...themeSpecificStyle[themeName]
60
- };
61
- };
62
- var _default = exports.default = generateComponentTheme;
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.accepts = accepts;
7
- exports.default = void 0;
8
- exports.getAcceptList = getAcceptList;
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- function accepts(file, acceptProp) {
34
- if (file && acceptProp && file.type !== 'application/x-moz-file') {
35
- const acceptList = getAcceptList(acceptProp);
36
- const mimeType = file.type || '';
37
- const baseMimeType = mimeType.replace(/\/.*$/, '');
38
- return acceptList.some(type => {
39
- if (type.charAt(0) === '.') {
40
- // type is an extension like .pdf
41
- if (!file.name) {
42
- return mimeType.endsWith(type.slice(1));
43
- }
44
- return file.name.toLowerCase().endsWith(type.toLowerCase());
45
- } else if (/\/\*$/.test(type)) {
46
- // type is something like a image/* mime type
47
- return baseMimeType === type.replace(/\/.*$/, '');
48
- }
49
- return mimeType === type;
50
- });
51
- }
52
- return true;
53
- }
54
- function getAcceptList(accept) {
55
- const list = Array.isArray(accept) ? accept : accept.split(',');
56
- return list.map(a => a.trim().replace(/^\w+$/, '.$&'));
57
- }
58
- var _default = exports.default = accepts;
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.getEventFiles = getEventFiles;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- function getEventFiles(event, inputEl) {
33
- if ('dataTransfer' in event) {
34
- const dt = event.dataTransfer;
35
- if (dt) {
36
- if (dt.files && dt.files.length) {
37
- return dt.files;
38
- } else if (dt.items && dt.items.length) {
39
- return dt.items;
40
- }
41
- }
42
- } else if (inputEl && inputEl.files) {
43
- return inputEl.files;
44
- }
45
- return [];
46
- }
47
- var _default = exports.default = getEventFiles;
package/lib/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "FileDrop", {
7
- enumerable: true,
8
- get: function () {
9
- return _FileDrop.FileDrop;
10
- }
11
- });
12
- var _FileDrop = require("./FileDrop");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}