@instructure/ui-file-drop 8.8.1-snapshot.7 → 8.9.1-snapshot.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 CHANGED
@@ -3,6 +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
+ # [8.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
7
+
8
+ ### Bug Fixes
9
+
10
+ - fix shared-types TS errors ([7b83164](https://github.com/instructure/instructure-ui/commit/7b83164f4c5872f3a217e010563f59bf584ae4fc))
11
+
6
12
  # [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
7
13
 
8
14
  **Note:** Version bump only for package @instructure/ui-file-drop
@@ -30,9 +30,8 @@ var _dec, _dec2, _class, _class2, _temp;
30
30
 
31
31
  /** @jsx jsx */
32
32
  import { Component } from 'react';
33
- import PropTypes from 'prop-types';
34
33
  import keycode from 'keycode';
35
- import { FormPropTypes, FormFieldMessages } from '@instructure/ui-form-field';
34
+ import { FormFieldMessages } from '@instructure/ui-form-field';
36
35
  import { View } from '@instructure/ui-view';
37
36
  import { uid } from '@instructure/uid';
38
37
  import { testable } from '@instructure/ui-testable';
@@ -40,9 +39,10 @@ import { callRenderProp, passthroughProps, getInteraction } from '@instructure/u
40
39
  import { isEdge } from '@instructure/ui-utils';
41
40
  import { accepts, getAcceptList } from './utils/accepts';
42
41
  import { getEventFiles } from './utils/getEventFiles';
43
- import { withStyle, jsx, ThemeablePropTypes } from '@instructure/emotion';
42
+ import { withStyle, jsx } from '@instructure/emotion';
44
43
  import generateStyle from './styles';
45
44
  import generateComponentTheme from './theme';
45
+ import { propTypes, allowedProps } from './props';
46
46
 
47
47
  function keyEventIsClickButton(e) {
48
48
  return e.keyCode === keycode.codes.space || e.keyCode === keycode.codes.enter;
@@ -386,133 +386,7 @@ let FileDrop = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
386
386
  })) : null);
387
387
  }
388
388
 
389
- }, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = {
390
- /**
391
- * The id of the input (to link it to its label for a11y)
392
- */
393
- id: PropTypes.string,
394
-
395
- /**
396
- * The content of FileDrop; can be a component or React node.
397
- * Components receive `isDragAccepted` and `isDragRejected` as props.
398
- */
399
- renderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
400
-
401
- /**
402
- * The mime media type/s or file extension/s allowed to be dropped inside
403
- */
404
- accept: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
405
-
406
- /**
407
- * object with shape: `{
408
- * text: PropTypes.string,
409
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
410
- * }`
411
- */
412
- messages: PropTypes.arrayOf(FormPropTypes.message),
413
-
414
- /**
415
- * Called when clicking on drop area to select files to upload
416
- */
417
- onClick: PropTypes.func,
418
-
419
- /**
420
- * Called when dropping files or when file dialog window exits successfully
421
- */
422
- onDrop: PropTypes.func,
423
-
424
- /**
425
- * Called when dropping allowed files
426
- */
427
- onDropAccepted: PropTypes.func,
428
-
429
- /**
430
- * Called when dropping rejected files
431
- */
432
- onDropRejected: PropTypes.func,
433
-
434
- /**
435
- * Called when dragging files
436
- * and passing through FileDrop's content for the first time
437
- */
438
- onDragEnter: PropTypes.func,
439
-
440
- /**
441
- * Called when dragging files and passing through FileDrop's content
442
- */
443
- onDragOver: PropTypes.func,
444
-
445
- /**
446
- * Called when dragging files and leaving FileDrop's content
447
- */
448
- onDragLeave: PropTypes.func,
449
-
450
- /**
451
- * Flag to use window.URL.createObjectURL for each dropped file and pass it through file.preview
452
- */
453
- shouldEnablePreview: PropTypes.bool,
454
-
455
- /**
456
- * Flag to allow multiple files to drop at once
457
- */
458
- shouldAllowMultiple: PropTypes.bool,
459
-
460
- /**
461
- * Flag to allow upload of the same file more than once
462
- */
463
- shouldAllowRepeats: PropTypes.bool,
464
-
465
- /**
466
- * the maximum file size allowed
467
- */
468
- maxSize: PropTypes.number,
469
-
470
- /**
471
- * the minimum file size allowed
472
- */
473
- minSize: PropTypes.number,
474
-
475
- /**
476
- * Specifies if interaction with the input is enabled, disabled, or readonly.
477
- */
478
- interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
479
-
480
- /**
481
- * Set the CSS `display` property on FileInput's outermost element
482
- */
483
- display: PropTypes.oneOf(['block', 'inline-block']),
484
-
485
- /**
486
- * Set the CSS `height` property on FileInput's outermost element
487
- */
488
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
489
-
490
- /**
491
- * Set the CSS `width` property on FileInput's outermost element
492
- */
493
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
494
-
495
- /**
496
- * Set the CSS `maxWidth` property on FileInput's outermost element
497
- */
498
- maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
499
-
500
- /**
501
- * Set the CSS `minWidth` property on FileInput's outermost element
502
- */
503
- minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
504
-
505
- /**
506
- * Valid values are 0, none, auto, xxx-small, xx-small, x-small, small,
507
- * medium, large, x-large, xx-large. Apply these values via familiar
508
- * CSS-like shorthand. For example: margin="small auto large".
509
- */
510
- margin: ThemeablePropTypes.spacing,
511
- // eslint-disable-next-line react/require-default-props
512
- makeStyles: PropTypes.func,
513
- // eslint-disable-next-line react/require-default-props
514
- styles: PropTypes.object
515
- }, _class2.defaultProps = {
389
+ }, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
516
390
  onClick: function (e) {},
517
391
  onDrop: function (accepted, rejected, e) {},
518
392
  onDropAccepted: function (accepted, e) {},
@@ -526,16 +400,8 @@ let FileDrop = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
526
400
  maxSize: Infinity,
527
401
  minSize: 0,
528
402
  // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
529
- interaction: void 0,
530
403
  messages: [],
531
- id: void 0,
532
- accept: void 0,
533
- display: 'block',
534
- height: void 0,
535
- width: void 0,
536
- minWidth: void 0,
537
- maxWidth: void 0,
538
- margin: void 0
404
+ display: 'block'
539
405
  }, _temp)) || _class) || _class);
540
406
  export default FileDrop;
541
407
  export { FileDrop };
@@ -0,0 +1,151 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import PropTypes from 'prop-types';
25
+ import { FormPropTypes } from '@instructure/ui-form-field';
26
+ import { ThemeablePropTypes } from '@instructure/emotion';
27
+ const propTypes = {
28
+ /**
29
+ * The id of the input (to link it to its label for a11y)
30
+ */
31
+ id: PropTypes.string,
32
+
33
+ /**
34
+ * The content of FileDrop; can be a component or React node.
35
+ * Components receive `isDragAccepted` and `isDragRejected` as props.
36
+ */
37
+ renderLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.node]).isRequired,
38
+
39
+ /**
40
+ * The mime media type/s or file extension/s allowed to be dropped inside
41
+ */
42
+ accept: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
43
+
44
+ /**
45
+ * object with shape: `{
46
+ * text: PropTypes.string,
47
+ * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
48
+ * }`
49
+ */
50
+ messages: PropTypes.arrayOf(FormPropTypes.message),
51
+
52
+ /**
53
+ * Called when clicking on drop area to select files to upload
54
+ */
55
+ onClick: PropTypes.func,
56
+
57
+ /**
58
+ * Called when dropping files or when file dialog window exits successfully
59
+ */
60
+ onDrop: PropTypes.func,
61
+
62
+ /**
63
+ * Called when dropping allowed files
64
+ */
65
+ onDropAccepted: PropTypes.func,
66
+
67
+ /**
68
+ * Called when dropping rejected files
69
+ */
70
+ onDropRejected: PropTypes.func,
71
+
72
+ /**
73
+ * Called when dragging files
74
+ * and passing through FileDrop's content for the first time
75
+ */
76
+ onDragEnter: PropTypes.func,
77
+
78
+ /**
79
+ * Called when dragging files and passing through FileDrop's content
80
+ */
81
+ onDragOver: PropTypes.func,
82
+
83
+ /**
84
+ * Called when dragging files and leaving FileDrop's content
85
+ */
86
+ onDragLeave: PropTypes.func,
87
+
88
+ /**
89
+ * Flag to use window.URL.createObjectURL for each dropped file and pass it through file.preview
90
+ */
91
+ shouldEnablePreview: PropTypes.bool,
92
+
93
+ /**
94
+ * Flag to allow multiple files to drop at once
95
+ */
96
+ shouldAllowMultiple: PropTypes.bool,
97
+
98
+ /**
99
+ * Flag to allow upload of the same file more than once
100
+ */
101
+ shouldAllowRepeats: PropTypes.bool,
102
+
103
+ /**
104
+ * the maximum file size allowed
105
+ */
106
+ maxSize: PropTypes.number,
107
+
108
+ /**
109
+ * the minimum file size allowed
110
+ */
111
+ minSize: PropTypes.number,
112
+
113
+ /**
114
+ * Specifies if interaction with the input is enabled, disabled, or readonly.
115
+ */
116
+ interaction: PropTypes.oneOf(['enabled', 'disabled', 'readonly']),
117
+
118
+ /**
119
+ * Set the CSS `display` property on FileInput's outermost element
120
+ */
121
+ display: PropTypes.oneOf(['block', 'inline-block']),
122
+
123
+ /**
124
+ * Set the CSS `height` property on FileInput's outermost element
125
+ */
126
+ height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
127
+
128
+ /**
129
+ * Set the CSS `width` property on FileInput's outermost element
130
+ */
131
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
132
+
133
+ /**
134
+ * Set the CSS `maxWidth` property on FileInput's outermost element
135
+ */
136
+ maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
137
+
138
+ /**
139
+ * Set the CSS `minWidth` property on FileInput's outermost element
140
+ */
141
+ minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
142
+
143
+ /**
144
+ * Valid values are 0, none, auto, xxx-small, xx-small, x-small, small,
145
+ * medium, large, x-large, xx-large. Apply these values via familiar
146
+ * CSS-like shorthand. For example: margin="small auto large".
147
+ */
148
+ margin: ThemeablePropTypes.spacing
149
+ };
150
+ const allowedProps = ['id', 'renderLabel', 'accept', 'messages', 'onClick', 'onDrop', 'onDropAccepted', 'onDropRejected', 'onDragEnter', 'onDragOver', 'onDragLeave', 'shouldEnablePreview', 'shouldAllowMultiple', 'shouldAllowRepeats', 'maxSize', 'minSize', 'interaction', 'display', 'height', 'width', 'maxWidth', 'minWidth', 'margin'];
151
+ export { propTypes, allowedProps };
@@ -13,12 +13,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
13
13
 
14
14
  var _react = require("react");
15
15
 
16
- var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
16
  var _keycode = _interopRequireDefault(require("keycode"));
19
17
 
20
- var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
21
-
22
18
  var _FormFieldMessages = require("@instructure/ui-form-field/lib/FormFieldMessages");
23
19
 
24
20
  var _View = require("@instructure/ui-view/lib/View");
@@ -45,6 +41,8 @@ var _styles = _interopRequireDefault(require("./styles"));
45
41
 
46
42
  var _theme = _interopRequireDefault(require("./theme"));
47
43
 
44
+ var _props = require("./props");
45
+
48
46
  const _excluded = ["display", "height", "width", "minWidth", "maxWidth", "margin", "onDropAccepted", "onDropRejected"];
49
47
 
50
48
  var _dec, _dec2, _class, _class2, _temp;
@@ -390,133 +388,7 @@ let FileDrop = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
390
388
  })) : null);
391
389
  }
392
390
 
393
- }, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = {
394
- /**
395
- * The id of the input (to link it to its label for a11y)
396
- */
397
- id: _propTypes.default.string,
398
-
399
- /**
400
- * The content of FileDrop; can be a component or React node.
401
- * Components receive `isDragAccepted` and `isDragRejected` as props.
402
- */
403
- renderLabel: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]).isRequired,
404
-
405
- /**
406
- * The mime media type/s or file extension/s allowed to be dropped inside
407
- */
408
- accept: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
409
-
410
- /**
411
- * object with shape: `{
412
- * text: PropTypes.string,
413
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
414
- * }`
415
- */
416
- messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
417
-
418
- /**
419
- * Called when clicking on drop area to select files to upload
420
- */
421
- onClick: _propTypes.default.func,
422
-
423
- /**
424
- * Called when dropping files or when file dialog window exits successfully
425
- */
426
- onDrop: _propTypes.default.func,
427
-
428
- /**
429
- * Called when dropping allowed files
430
- */
431
- onDropAccepted: _propTypes.default.func,
432
-
433
- /**
434
- * Called when dropping rejected files
435
- */
436
- onDropRejected: _propTypes.default.func,
437
-
438
- /**
439
- * Called when dragging files
440
- * and passing through FileDrop's content for the first time
441
- */
442
- onDragEnter: _propTypes.default.func,
443
-
444
- /**
445
- * Called when dragging files and passing through FileDrop's content
446
- */
447
- onDragOver: _propTypes.default.func,
448
-
449
- /**
450
- * Called when dragging files and leaving FileDrop's content
451
- */
452
- onDragLeave: _propTypes.default.func,
453
-
454
- /**
455
- * Flag to use window.URL.createObjectURL for each dropped file and pass it through file.preview
456
- */
457
- shouldEnablePreview: _propTypes.default.bool,
458
-
459
- /**
460
- * Flag to allow multiple files to drop at once
461
- */
462
- shouldAllowMultiple: _propTypes.default.bool,
463
-
464
- /**
465
- * Flag to allow upload of the same file more than once
466
- */
467
- shouldAllowRepeats: _propTypes.default.bool,
468
-
469
- /**
470
- * the maximum file size allowed
471
- */
472
- maxSize: _propTypes.default.number,
473
-
474
- /**
475
- * the minimum file size allowed
476
- */
477
- minSize: _propTypes.default.number,
478
-
479
- /**
480
- * Specifies if interaction with the input is enabled, disabled, or readonly.
481
- */
482
- interaction: _propTypes.default.oneOf(['enabled', 'disabled', 'readonly']),
483
-
484
- /**
485
- * Set the CSS `display` property on FileInput's outermost element
486
- */
487
- display: _propTypes.default.oneOf(['block', 'inline-block']),
488
-
489
- /**
490
- * Set the CSS `height` property on FileInput's outermost element
491
- */
492
- height: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
493
-
494
- /**
495
- * Set the CSS `width` property on FileInput's outermost element
496
- */
497
- width: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
498
-
499
- /**
500
- * Set the CSS `maxWidth` property on FileInput's outermost element
501
- */
502
- maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
503
-
504
- /**
505
- * Set the CSS `minWidth` property on FileInput's outermost element
506
- */
507
- minWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
508
-
509
- /**
510
- * Valid values are 0, none, auto, xxx-small, xx-small, x-small, small,
511
- * medium, large, x-large, xx-large. Apply these values via familiar
512
- * CSS-like shorthand. For example: margin="small auto large".
513
- */
514
- margin: _emotion.ThemeablePropTypes.spacing,
515
- // eslint-disable-next-line react/require-default-props
516
- makeStyles: _propTypes.default.func,
517
- // eslint-disable-next-line react/require-default-props
518
- styles: _propTypes.default.object
519
- }, _class2.defaultProps = {
391
+ }, _class2.displayName = "FileDrop", _class2.componentId = 'FileDrop', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
520
392
  onClick: function (e) {},
521
393
  onDrop: function (accepted, rejected, e) {},
522
394
  onDropAccepted: function (accepted, e) {},
@@ -530,16 +402,8 @@ let FileDrop = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
530
402
  maxSize: Infinity,
531
403
  minSize: 0,
532
404
  // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
533
- interaction: void 0,
534
405
  messages: [],
535
- id: void 0,
536
- accept: void 0,
537
- display: 'block',
538
- height: void 0,
539
- width: void 0,
540
- minWidth: void 0,
541
- maxWidth: void 0,
542
- margin: void 0
406
+ display: 'block'
543
407
  }, _temp)) || _class) || _class);
544
408
  exports.FileDrop = FileDrop;
545
409
  var _default = FileDrop;