@instructure/ui-file-drop 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +41 -296
  2. package/es/FileDrop/{index.js → v1/index.js} +3 -3
  3. package/es/FileDrop/v2/index.js +371 -0
  4. package/es/FileDrop/v2/props.js +26 -0
  5. package/es/FileDrop/v2/styles.js +111 -0
  6. package/es/FileDrop/v2/utils/accepts.js +51 -0
  7. package/es/FileDrop/v2/utils/getEventFiles.js +41 -0
  8. package/es/{index.js → exports/a.js} +1 -1
  9. package/{src/index.ts → es/exports/b.js} +1 -3
  10. package/lib/FileDrop/v1/index.js +379 -0
  11. package/lib/FileDrop/{index.js → v2/index.js} +9 -9
  12. package/lib/FileDrop/v2/props.js +31 -0
  13. package/lib/FileDrop/v2/styles.js +117 -0
  14. package/lib/FileDrop/v2/utils/accepts.js +58 -0
  15. package/lib/FileDrop/v2/utils/getEventFiles.js +47 -0
  16. package/lib/{index.js → exports/a.js} +2 -2
  17. package/lib/exports/b.js +12 -0
  18. package/package.json +42 -20
  19. package/src/FileDrop/{index.tsx → v1/index.tsx} +4 -4
  20. package/src/FileDrop/{props.ts → v1/props.ts} +1 -1
  21. package/src/FileDrop/{styles.ts → v1/styles.ts} +2 -6
  22. package/src/FileDrop/v2/README.md +177 -0
  23. package/src/FileDrop/v2/index.tsx +419 -0
  24. package/src/FileDrop/v2/props.ts +211 -0
  25. package/src/FileDrop/v2/styles.ts +140 -0
  26. package/src/FileDrop/v2/utils/accepts.ts +54 -0
  27. package/src/FileDrop/v2/utils/getEventFiles.ts +47 -0
  28. package/src/exports/a.ts +26 -0
  29. package/src/exports/b.ts +26 -0
  30. package/tsconfig.build.tsbuildinfo +1 -1
  31. package/types/FileDrop/{index.d.ts → v1/index.d.ts} +1 -1
  32. package/types/FileDrop/v1/index.d.ts.map +1 -0
  33. package/types/FileDrop/{props.d.ts → v1/props.d.ts} +1 -1
  34. package/types/FileDrop/v1/props.d.ts.map +1 -0
  35. package/types/FileDrop/v1/styles.d.ts.map +1 -0
  36. package/types/FileDrop/v1/theme.d.ts.map +1 -0
  37. package/types/FileDrop/v1/utils/accepts.d.ts.map +1 -0
  38. package/types/FileDrop/v1/utils/getEventFiles.d.ts.map +1 -0
  39. package/types/FileDrop/v2/index.d.ts +89 -0
  40. package/types/FileDrop/v2/index.d.ts.map +1 -0
  41. package/types/FileDrop/v2/props.d.ts +134 -0
  42. package/types/FileDrop/v2/props.d.ts.map +1 -0
  43. package/types/FileDrop/v2/styles.d.ts +17 -0
  44. package/types/FileDrop/v2/styles.d.ts.map +1 -0
  45. package/types/FileDrop/v2/utils/accepts.d.ts +5 -0
  46. package/types/FileDrop/v2/utils/accepts.d.ts.map +1 -0
  47. package/types/FileDrop/v2/utils/getEventFiles.d.ts +5 -0
  48. package/types/FileDrop/v2/utils/getEventFiles.d.ts.map +1 -0
  49. package/types/exports/a.d.ts +3 -0
  50. package/types/exports/a.d.ts.map +1 -0
  51. package/types/exports/b.d.ts +3 -0
  52. package/types/exports/b.d.ts.map +1 -0
  53. package/types/FileDrop/index.d.ts.map +0 -1
  54. package/types/FileDrop/props.d.ts.map +0 -1
  55. package/types/FileDrop/styles.d.ts.map +0 -1
  56. package/types/FileDrop/theme.d.ts.map +0 -1
  57. package/types/FileDrop/utils/accepts.d.ts.map +0 -1
  58. package/types/FileDrop/utils/getEventFiles.d.ts.map +0 -1
  59. package/types/index.d.ts +0 -3
  60. package/types/index.d.ts.map +0 -1
  61. /package/es/FileDrop/{props.js → v1/props.js} +0 -0
  62. /package/es/FileDrop/{styles.js → v1/styles.js} +0 -0
  63. /package/es/FileDrop/{theme.js → v1/theme.js} +0 -0
  64. /package/es/FileDrop/{utils → v1/utils}/accepts.js +0 -0
  65. /package/es/FileDrop/{utils → v1/utils}/getEventFiles.js +0 -0
  66. /package/lib/FileDrop/{props.js → v1/props.js} +0 -0
  67. /package/lib/FileDrop/{styles.js → v1/styles.js} +0 -0
  68. /package/lib/FileDrop/{theme.js → v1/theme.js} +0 -0
  69. /package/lib/FileDrop/{utils → v1/utils}/accepts.js +0 -0
  70. /package/lib/FileDrop/{utils → v1/utils}/getEventFiles.js +0 -0
  71. /package/src/FileDrop/{README.md → v1/README.md} +0 -0
  72. /package/src/FileDrop/{theme.ts → v1/theme.ts} +0 -0
  73. /package/src/FileDrop/{utils → v1/utils}/accepts.ts +0 -0
  74. /package/src/FileDrop/{utils → v1/utils}/getEventFiles.ts +0 -0
  75. /package/types/FileDrop/{styles.d.ts → v1/styles.d.ts} +0 -0
  76. /package/types/FileDrop/{theme.d.ts → v1/theme.d.ts} +0 -0
  77. /package/types/FileDrop/{utils → v1/utils}/accepts.d.ts +0 -0
  78. /package/types/FileDrop/{utils → v1/utils}/getEventFiles.d.ts +0 -0
@@ -0,0 +1,47 @@
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;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "FileDrop", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _FileDrop.FileDrop;
9
+ return _v.FileDrop;
10
10
  }
11
11
  });
12
- var _FileDrop = require("./FileDrop");
12
+ var _v = require("../FileDrop/v1");
@@ -0,0 +1,12 @@
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 _v.FileDrop;
10
+ }
11
+ });
12
+ var _v = require("../FileDrop/v2");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-file-drop",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-snapshot-129",
4
4
  "description": "A flexible facade for an HTML file input",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -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/emotion": "11.6.1-snapshot-129",
20
+ "@instructure/console": "11.6.1-snapshot-129",
21
+ "@instructure/shared-types": "11.6.1-snapshot-129",
22
+ "@instructure/ui-color-utils": "11.6.1-snapshot-129",
23
+ "@instructure/ui-form-field": "11.6.1-snapshot-129",
24
+ "@instructure/ui-react-utils": "11.6.1-snapshot-129",
25
+ "@instructure/ui-view": "11.6.1-snapshot-129",
26
+ "@instructure/uid": "11.6.1-snapshot-129",
27
+ "@instructure/ui-utils": "11.6.1-snapshot-129"
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-babel-preset": "11.6.1-snapshot-129",
34
+ "@instructure/ui-themes": "11.6.1-snapshot-129",
35
+ "@instructure/ui-axe-check": "11.6.1-snapshot-129"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=18 <=19"
@@ -42,17 +42,39 @@
42
42
  },
43
43
  "sideEffects": false,
44
44
  "exports": {
45
- ".": {
46
- "types": "./types/index.d.ts",
47
- "import": "./es/index.js",
48
- "require": "./lib/index.js",
49
- "default": "./es/index.js"
50
- },
51
45
  "./lib/*": "./lib/*",
52
46
  "./es/*": "./es/*",
53
47
  "./types/*": "./types/*",
54
48
  "./package.json": "./package.json",
55
- "./src/*": "./src/*"
49
+ "./src/*": "./src/*",
50
+ ".": {
51
+ "src": "./src/exports/a.ts",
52
+ "types": "./types/exports/a.d.ts",
53
+ "import": "./es/exports/a.js",
54
+ "require": "./lib/exports/a.js",
55
+ "default": "./es/exports/a.js"
56
+ },
57
+ "./v11_6": {
58
+ "src": "./src/exports/a.ts",
59
+ "types": "./types/exports/a.d.ts",
60
+ "import": "./es/exports/a.js",
61
+ "require": "./lib/exports/a.js",
62
+ "default": "./es/exports/a.js"
63
+ },
64
+ "./v11_7": {
65
+ "src": "./src/exports/b.ts",
66
+ "types": "./types/exports/b.d.ts",
67
+ "import": "./es/exports/b.js",
68
+ "require": "./lib/exports/b.js",
69
+ "default": "./es/exports/b.js"
70
+ },
71
+ "./latest": {
72
+ "src": "./src/exports/b.ts",
73
+ "types": "./types/exports/b.d.ts",
74
+ "import": "./es/exports/b.js",
75
+ "require": "./lib/exports/b.js",
76
+ "default": "./es/exports/b.js"
77
+ }
56
78
  },
57
79
  "scripts": {
58
80
  "lint": "ui-scripts lint",
@@ -24,9 +24,9 @@
24
24
 
25
25
  import { Component } from 'react'
26
26
  import keycode from 'keycode'
27
- import { FormFieldMessages } from '@instructure/ui-form-field'
28
- import type { FormMessage } from '@instructure/ui-form-field'
29
- import { View } from '@instructure/ui-view'
27
+ import { FormFieldMessages } from '@instructure/ui-form-field/v11_6'
28
+ import type { FormMessage } from '@instructure/ui-form-field/v11_6'
29
+ import { View } from '@instructure/ui-view/v11_6'
30
30
  import {
31
31
  callRenderProp,
32
32
  passthroughProps,
@@ -37,7 +37,7 @@ import {
37
37
  import { accepts, getAcceptList } from './utils/accepts'
38
38
  import { getEventFiles } from './utils/getEventFiles'
39
39
 
40
- import { withStyle } from '@instructure/emotion'
40
+ import { withStyleLegacy as withStyle } from '@instructure/emotion'
41
41
  import generateStyle from './styles'
42
42
  import generateComponentTheme from './theme'
43
43
 
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import type { FormMessage } from '@instructure/ui-form-field'
25
+ import type { FormMessage } from '@instructure/ui-form-field/v11_6'
26
26
  import type {
27
27
  Spacing,
28
28
  WithStyleProps,
@@ -41,12 +41,8 @@ const generateStyle = (
41
41
  state: FileDropStyleProps
42
42
  ): FileDropStyle => {
43
43
  const { height } = props
44
- const {
45
- functionallyDisabled,
46
- visuallyDisabled,
47
- dragRejected,
48
- dragAccepted
49
- } = state
44
+ const { functionallyDisabled, visuallyDisabled, dragRejected, dragAccepted } =
45
+ state
50
46
 
51
47
  const dragAcceptedStyle = dragAccepted
52
48
  ? {
@@ -0,0 +1,177 @@
1
+ ---
2
+ describes: FileDrop
3
+ ---
4
+
5
+ `FileDrop` is a consistent way to drag and drop, as well as browse your computer to upload a media file.
6
+
7
+ The `isDragAccepted` and `isDragRejected` props can be used to signal to the user if
8
+ the dragged files are going to be accepted or not (unfortunately, this only works as intended in Chrome
9
+ and Firefox).
10
+
11
+ ```js
12
+ ---
13
+ type: example
14
+ ---
15
+ <FileDrop
16
+ accept="image/*"
17
+ onDropAccepted={([file]) => { console.log(`File accepted ${file.name}`) }}
18
+ onDropRejected={([file]) => { console.log(`File rejected ${file.name}`) }}
19
+ renderLabel={
20
+ <View as="div" padding="xx-large large" background="primary">
21
+ <IconModuleLine size="large" />
22
+ <Heading>Drop files here to add them to module</Heading>
23
+ <Text color="brand">
24
+ Drag and drop, or click to browse your computer
25
+ </Text>
26
+ </View>
27
+ }
28
+ />
29
+ ```
30
+
31
+ A disabled FileDrop
32
+
33
+ ```js
34
+ ---
35
+ type: example
36
+ ---
37
+ <FileDrop
38
+ renderLabel={
39
+ <Billboard
40
+ heading="Upload your image"
41
+ message="Drag and drop, or click to browse your computer"
42
+ hero={<Img src={placeholderImage(1200, 300)} />}
43
+ />
44
+ }
45
+ interaction="disabled"
46
+ />
47
+ ```
48
+
49
+ ### Accept
50
+
51
+ The `accept` prop dictates what type of files are allowed. It can be an array or comma-separated string of
52
+ [MIME type formats](https://en.wikipedia.org/wiki/Media_type#Common_examples) and/or file extensions.
53
+
54
+ ```js
55
+ ---
56
+ type: example
57
+ ---
58
+ <div>
59
+ <FileDrop
60
+ accept=".csv"
61
+ onDropAccepted={([file]) => { console.log(`File accepted ${file.name}`) }}
62
+ onDropRejected={([file]) => { console.log(`File rejected ${file.name}`) }}
63
+ renderLabel={
64
+ <View background="secondary" as="div" textAlign="center" padding="x-large large">
65
+ <IconUploadSolid />
66
+ <Text as="div" weight="bold">
67
+ Upload document
68
+ </Text>
69
+ <Text>Drag and drop or <Text color="brand">browse your files</Text></Text>
70
+ <Text size="small" as="div" lineHeight="double">A single CSV document</Text>
71
+ </View>
72
+ }
73
+ display="inline-block"
74
+ width="24rem"
75
+ margin="x-small"
76
+ />
77
+ <FileDrop
78
+ accept="video/*"
79
+ onDropAccepted={([file]) => { console.log(`File accepted ${file.name}`) }}
80
+ onDropRejected={([file]) => { console.log(`File rejected ${file.name}`) }}
81
+ renderLabel={
82
+ <Billboard
83
+ size="small"
84
+ message="All video file types"
85
+ hero={<IconVideoLine />}
86
+ />
87
+ }
88
+ display="inline-block"
89
+ width="12rem"
90
+ margin="x-small"
91
+ />
92
+ </div>
93
+ ```
94
+
95
+ FileDrop accepts the same `messages` prop as the other Instructure UI input components for providing
96
+ form validation feedback. If there are `error` messages in the `messages` array, FileDrop's border
97
+ will turn the theme's `rejectedColor`.
98
+
99
+ ```js
100
+ ---
101
+ type: example
102
+ ---
103
+ <FileDrop
104
+ accept=".jpg"
105
+ onDropAccepted={([file]) => { console.log(`File accepted ${file.name}`) }}
106
+ onDropRejected={([file]) => { console.log(`File rejected ${file.name}`) }}
107
+ messages={[{ text: 'Invalid file type', type: 'error' }]}
108
+ renderLabel={
109
+ <Billboard
110
+ size="small"
111
+ message="Only .jpg files"
112
+ hero={<IconImageLine />}
113
+ />
114
+ }
115
+ maxWidth="15rem"
116
+ margin="0 auto"
117
+ />
118
+ ```
119
+
120
+ ### shouldAllowMultiple
121
+
122
+ If the `shouldAllowMultiple` prop is `true`, FileDrop accepts multiple files.
123
+
124
+ ```js
125
+ ---
126
+ type: example
127
+ ---
128
+ <FileDrop
129
+ shouldAllowMultiple={true}
130
+ onDropAccepted={(files) => {
131
+ console.log(`Files accepted ${files.map((f) => f.name).join(',')}`)
132
+ }}
133
+ renderLabel={
134
+ <View as="div" textAlign="center" padding="large" margin="large 0 0 0">
135
+ <IconAnnotateLine color="brand" size="large" />
136
+ <Text as="div" color="brand">
137
+ Drag and Drop or Click to Browser your Computer
138
+ </Text>
139
+ </View>
140
+ }
141
+ width="18rem"
142
+ height="16rem"
143
+ margin="x-small"
144
+ />
145
+ ```
146
+
147
+ ### height Property
148
+
149
+ If the `height` property is set to `100%`, the FileDrop container will fill the available vertical space.
150
+
151
+ ```js
152
+ ---
153
+ type: example
154
+ ---
155
+ <div style={{height: '30rem'}}>
156
+ <FileDrop
157
+ height="100%"
158
+ renderLabel={
159
+ <Flex direction="column" height="100%" alignItems="center" justifyItems="center">
160
+ <Flex.Item padding="small">
161
+ <IconPdfLine size="large" />
162
+ </Flex.Item>
163
+ <Flex.Item padding="small">
164
+ <Text size="large">
165
+ Drag and Drop or Click to Browser your Computer
166
+ </Text>
167
+ </Flex.Item>
168
+ <Flex.Item padding="small">
169
+ <Text color="secondary" size="small">
170
+ Accepted File Type is PDF
171
+ </Text>
172
+ </Flex.Item>
173
+ </Flex>
174
+ }
175
+ />
176
+ </div>
177
+ ```