react-ui-basics 0.0.213 → 0.0.214
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/Checkbox.d.ts +2 -2
- package/DropFileInput.d.ts +2 -2
- package/Dropzone.d.ts +18 -0
- package/Dropzone.js +71 -108
- package/Dropzone.js.map +1 -1
- package/bundle.css +499 -499
- package/package.json +1 -1
- package/src/Checkbox.tsx +2 -2
- package/src/DropFileInput.tsx +1 -1
- package/src/{Dropzone.js → Dropzone.tsx} +33 -33
package/package.json
CHANGED
package/src/Checkbox.tsx
CHANGED
|
@@ -6,8 +6,8 @@ import {PureComponent, render, propsGetter} from "./ReactConstants";
|
|
|
6
6
|
|
|
7
7
|
export interface CheckboxProps {
|
|
8
8
|
value: boolean,
|
|
9
|
-
onChange: ChangeEventHandler
|
|
10
|
-
label
|
|
9
|
+
onChange: ChangeEventHandler<HTMLInputElement>,
|
|
10
|
+
label?: string | ReactElement,
|
|
11
11
|
name?: string,
|
|
12
12
|
id?: string | number,
|
|
13
13
|
disabled?: boolean,
|
package/src/DropFileInput.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, {ReactElement, ReactNode} from 'react';
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import ReactCreateElement from './ReactCreateElement';
|
|
4
4
|
import './Dropzone.css'
|
|
@@ -10,7 +10,7 @@ const toArray = (o) => {
|
|
|
10
10
|
return o;
|
|
11
11
|
|
|
12
12
|
const l = [];
|
|
13
|
-
for (let i = 0; i <
|
|
13
|
+
for (let i = 0; i < o.length; i++) {
|
|
14
14
|
l.push(o[i])
|
|
15
15
|
}
|
|
16
16
|
return l;
|
|
@@ -30,7 +30,19 @@ const ignoredTypes = setOf([
|
|
|
30
30
|
|
|
31
31
|
const ignore = dt => dt && (!dt.types[0] || ignoredTypes[dt.types[0]]);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
export interface DropzoneProps {
|
|
34
|
+
onDrop: (files: File[]) => void,
|
|
35
|
+
className?: string,
|
|
36
|
+
overlayLabel?: string | ReactElement,
|
|
37
|
+
clickable?: boolean,
|
|
38
|
+
droppable?: boolean,
|
|
39
|
+
multiple?: boolean,
|
|
40
|
+
disabled?: boolean,
|
|
41
|
+
accept?: string,
|
|
42
|
+
children?: ReactNode
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
class Dropzone extends PureComponent<DropzoneProps> {
|
|
34
46
|
|
|
35
47
|
constructor(properties) {
|
|
36
48
|
super(properties);
|
|
@@ -40,11 +52,11 @@ class Dropzone extends PureComponent {
|
|
|
40
52
|
let entries = [];
|
|
41
53
|
|
|
42
54
|
const props = propsGetter(that);
|
|
43
|
-
const isDragging = stateGS(that);
|
|
55
|
+
const isDragging = stateGS<boolean>(that);
|
|
44
56
|
|
|
45
57
|
const onDrop = (e) => {
|
|
46
58
|
const dt = e.dataTransfer;
|
|
47
|
-
const files = toArray(dt && dt.files ||
|
|
59
|
+
const files = toArray(dt && dt.files || e.target.files);
|
|
48
60
|
props().onDrop(files);
|
|
49
61
|
isDragging(false);
|
|
50
62
|
entries = [];
|
|
@@ -61,8 +73,9 @@ class Dropzone extends PureComponent {
|
|
|
61
73
|
const onDragEnter = (e) => {
|
|
62
74
|
const dt = e.dataTransfer;
|
|
63
75
|
if (ignore(dt)) return;
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
|
|
77
|
+
if (entries.indexOf(e.target) === -1) {
|
|
78
|
+
entries.push(e.target)
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
dt && (dt.dropEffect = 'copy');
|
|
@@ -70,9 +83,9 @@ class Dropzone extends PureComponent {
|
|
|
70
83
|
prevent(e);
|
|
71
84
|
};
|
|
72
85
|
const onDragLeave = (e) => {
|
|
73
|
-
entries = entries.filter(el => el !==
|
|
86
|
+
entries = entries.filter(el => el !== e.target);
|
|
74
87
|
|
|
75
|
-
if (
|
|
88
|
+
if (entries.length === 0)
|
|
76
89
|
isDragging(false);
|
|
77
90
|
|
|
78
91
|
prevent(e)
|
|
@@ -80,8 +93,17 @@ class Dropzone extends PureComponent {
|
|
|
80
93
|
|
|
81
94
|
const inputRef = createRef()
|
|
82
95
|
|
|
83
|
-
that[
|
|
84
|
-
const {
|
|
96
|
+
that[render] = () => {
|
|
97
|
+
const {
|
|
98
|
+
children,
|
|
99
|
+
className,
|
|
100
|
+
disabled,
|
|
101
|
+
clickable = true,
|
|
102
|
+
multiple = true,
|
|
103
|
+
droppable = true,
|
|
104
|
+
overlayLabel,
|
|
105
|
+
accept
|
|
106
|
+
} = props();
|
|
85
107
|
|
|
86
108
|
return <div className={classNames('Dropzone', className, isDragging() && 'dragging')}
|
|
87
109
|
onDragLeave={!disabled && droppable && onDragLeave || UNDEFINED}
|
|
@@ -109,26 +131,4 @@ class Dropzone extends PureComponent {
|
|
|
109
131
|
}
|
|
110
132
|
}
|
|
111
133
|
|
|
112
|
-
Dropzone.defaultProps = {
|
|
113
|
-
clickable: true,
|
|
114
|
-
multiple: true,
|
|
115
|
-
droppable: true,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
119
|
-
Dropzone.propTypes = {
|
|
120
|
-
[ReactConstants[5]]: PropTypes.string,
|
|
121
|
-
overlayLabel: PropTypes.oneOfType([
|
|
122
|
-
PropTypes.string,
|
|
123
|
-
PropTypes.element
|
|
124
|
-
]),
|
|
125
|
-
clickable: PropTypes.bool,
|
|
126
|
-
droppable: PropTypes.bool,
|
|
127
|
-
multiple: PropTypes.bool,
|
|
128
|
-
disabled: PropTypes.bool,
|
|
129
|
-
onDrop: PropTypes.func.isRequired,
|
|
130
|
-
accept: PropTypes.string,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
134
|
export default Dropzone;
|