@elliemae/ds-uploader 2.0.0-alpha.1 → 2.0.0-alpha.10
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/cjs/DSUploader.js +22 -46
- package/cjs/index.d.js +2 -0
- package/cjs/index.js +1 -1
- package/cjs/propTypes.js +46 -0
- package/esm/DSUploader.js +6 -30
- package/esm/index.d.js +1 -0
- package/esm/propTypes.js +38 -0
- package/package.json +8 -4
- package/types/DSUploader.d.ts +10 -22
- package/types/index.d.d.ts +26 -0
- package/types/propTypes.d.ts +27 -0
package/cjs/DSUploader.js
CHANGED
|
@@ -13,6 +13,7 @@ var UploadFile = require('@elliemae/ds-icons/UploadFile');
|
|
|
13
13
|
var DSButton = require('@elliemae/ds-basic/Button');
|
|
14
14
|
var reactDropzone = require('react-dropzone');
|
|
15
15
|
var DSTooltip = require('@elliemae/ds-basic/Tooltip');
|
|
16
|
+
var propTypes = require('./propTypes.js');
|
|
16
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -32,7 +33,7 @@ const _excluded = ["labelText"],
|
|
|
32
33
|
|
|
33
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
34
35
|
|
|
35
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default[
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
36
37
|
const blockName = 'uploader';
|
|
37
38
|
const blockNameInfo = `${blockName}-info`;
|
|
38
39
|
const blockNameDragActive = `${blockName}-drag-active`;
|
|
@@ -57,15 +58,15 @@ const DividerVertical = dsClassnames.aggregatedClasses('div')('divider', null, (
|
|
|
57
58
|
vertical
|
|
58
59
|
}) => ({
|
|
59
60
|
vertical
|
|
60
|
-
}));
|
|
61
|
+
}));
|
|
61
62
|
|
|
62
63
|
function ActionButton(_ref) {
|
|
63
64
|
let {
|
|
64
65
|
labelText
|
|
65
66
|
} = _ref,
|
|
66
|
-
otherProps = _objectWithoutProperties__default[
|
|
67
|
+
otherProps = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
67
68
|
|
|
68
|
-
return /*#__PURE__*/jsxRuntime.jsx(DSButton__default[
|
|
69
|
+
return /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
69
70
|
buttonType: "text",
|
|
70
71
|
labelText: labelText
|
|
71
72
|
}));
|
|
@@ -78,11 +79,11 @@ const DSUploader = _ref2 => {
|
|
|
78
79
|
containerProps = {},
|
|
79
80
|
label = 'Browse',
|
|
80
81
|
// todo: i18n
|
|
81
|
-
icon: UploadFileIcon = UploadFile__default[
|
|
82
|
+
icon: UploadFileIcon = UploadFile__default["default"],
|
|
82
83
|
defaultActionLabel = 'LOCAL DRIVE',
|
|
83
84
|
// todo: i18n
|
|
84
85
|
dragActiveInstructionalText = 'DROP FILES HERE',
|
|
85
|
-
dragActiveIcon: DragActiveIcon = UploadFile__default[
|
|
86
|
+
dragActiveIcon: DragActiveIcon = UploadFile__default["default"],
|
|
86
87
|
altActionLabel = 'DOCUMENTS',
|
|
87
88
|
// todo: i18n
|
|
88
89
|
acceptedTypesText = 'JPG, JPEG, PNG, PDF',
|
|
@@ -91,13 +92,14 @@ const DSUploader = _ref2 => {
|
|
|
91
92
|
onDefaultHandlerClick = noop,
|
|
92
93
|
onAltHandlerClick = noop,
|
|
93
94
|
actions = {
|
|
94
|
-
defaultAction: 'LOCAL DRIVE'
|
|
95
|
+
defaultAction: 'LOCAL DRIVE',
|
|
96
|
+
altAction: 'DOCUMENTS'
|
|
95
97
|
},
|
|
96
98
|
showAltAction = false,
|
|
97
99
|
defaultActionTooltipText,
|
|
98
100
|
altActionTooltipText
|
|
99
101
|
} = _ref2,
|
|
100
|
-
dropzoneProps = _objectWithoutProperties__default[
|
|
102
|
+
dropzoneProps = _objectWithoutProperties__default["default"](_ref2, _excluded2);
|
|
101
103
|
|
|
102
104
|
const {
|
|
103
105
|
getRootProps,
|
|
@@ -109,11 +111,11 @@ const DSUploader = _ref2 => {
|
|
|
109
111
|
{
|
|
110
112
|
onClick: onOpenFile
|
|
111
113
|
} = _getRootProps,
|
|
112
|
-
rootProps = _objectWithoutProperties__default[
|
|
114
|
+
rootProps = _objectWithoutProperties__default["default"](_getRootProps, _excluded3);
|
|
113
115
|
|
|
114
116
|
const disabledAll = disabledDefault && disabledAlt;
|
|
115
117
|
|
|
116
|
-
const delfaultActionButton = /*#__PURE__*/_jsx2__default[
|
|
118
|
+
const delfaultActionButton = /*#__PURE__*/_jsx2__default["default"](ActionButton, {
|
|
117
119
|
variant: disabledDefault && DSButton.BUTTON_VARIANT.DISABLED,
|
|
118
120
|
labelText: actions.defaultAction ? actions.defaultAction : defaultActionLabel,
|
|
119
121
|
onClick: (...args) => {
|
|
@@ -121,7 +123,7 @@ const DSUploader = _ref2 => {
|
|
|
121
123
|
}
|
|
122
124
|
});
|
|
123
125
|
|
|
124
|
-
const altActionButton = /*#__PURE__*/_jsx2__default[
|
|
126
|
+
const altActionButton = /*#__PURE__*/_jsx2__default["default"](ActionButton, {
|
|
125
127
|
variant: disabledAlt && DSButton.BUTTON_VARIANT.DISABLED,
|
|
126
128
|
labelText: actions.altAction ? actions.altAction : altActionLabel,
|
|
127
129
|
onClick: (...args) => {
|
|
@@ -129,7 +131,7 @@ const DSUploader = _ref2 => {
|
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
|
|
132
|
-
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /*#__PURE__*/_jsx2__default[
|
|
134
|
+
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /*#__PURE__*/_jsx2__default["default"](DSTooltip__default["default"], {
|
|
133
135
|
containerProps: {
|
|
134
136
|
id: 'default-action-tooltip'
|
|
135
137
|
},
|
|
@@ -137,7 +139,7 @@ const DSUploader = _ref2 => {
|
|
|
137
139
|
title: defaultActionTooltipText,
|
|
138
140
|
triggerComponent: delfaultActionButton
|
|
139
141
|
});
|
|
140
|
-
const altAction = !altActionTooltipText ? altActionButton : /*#__PURE__*/_jsx2__default[
|
|
142
|
+
const altAction = !altActionTooltipText ? altActionButton : /*#__PURE__*/_jsx2__default["default"](DSTooltip__default["default"], {
|
|
141
143
|
containerProps: {
|
|
142
144
|
id: 'alt-action-tooltip'
|
|
143
145
|
},
|
|
@@ -153,12 +155,12 @@ const DSUploader = _ref2 => {
|
|
|
153
155
|
classProps: {
|
|
154
156
|
isDragActive
|
|
155
157
|
},
|
|
156
|
-
children: [/*#__PURE__*/_jsx2__default[
|
|
158
|
+
children: [/*#__PURE__*/_jsx2__default["default"](UploaderIconArea, {}, void 0, /*#__PURE__*/_jsx2__default["default"](UploadFileIcon, {
|
|
157
159
|
size: "l"
|
|
158
|
-
})), _DividerVertical || (_DividerVertical = /*#__PURE__*/_jsx2__default[
|
|
159
|
-
children: [actions.defaultAction && (_DividerVertical2 || (_DividerVertical2 = /*#__PURE__*/_jsx2__default[
|
|
160
|
-
}))), !disabledAll && /*#__PURE__*/_jsx2__default[
|
|
161
|
-
})), typeof acceptedTypesText === 'string' && /*#__PURE__*/_jsx2__default[
|
|
160
|
+
})), _DividerVertical || (_DividerVertical = /*#__PURE__*/_jsx2__default["default"](DividerVertical, {})), /*#__PURE__*/_jsx2__default["default"](UploaderInfo, {}, void 0, /*#__PURE__*/_jsx2__default["default"](InfoText, {}, void 0, label), /*#__PURE__*/_jsx2__default["default"](UploaderActions, {}, void 0, actions.defaultAction && defaultAction, (actions.altAction || showAltAction) && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
161
|
+
children: [actions.defaultAction && (_DividerVertical2 || (_DividerVertical2 = /*#__PURE__*/_jsx2__default["default"](DividerVertical, {}))), altAction]
|
|
162
|
+
}))), !disabledAll && /*#__PURE__*/_jsx2__default["default"](UploaderDragActive, {}, void 0, /*#__PURE__*/_jsx2__default["default"](DragActiveIcon, {}), dragActiveInstructionalText), !disabledAll && /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread({}, getInputProps()))]
|
|
163
|
+
})), typeof acceptedTypesText === 'string' && /*#__PURE__*/_jsx2__default["default"](AcceptedTypes, {}, void 0, acceptedTypesText.toUpperCase())]
|
|
162
164
|
}));
|
|
163
165
|
};
|
|
164
166
|
|
|
@@ -166,34 +168,8 @@ DSUploader.actions = {
|
|
|
166
168
|
defaultAction: 'LOCAL DRIVE',
|
|
167
169
|
altAction: 'DOCUMENTS'
|
|
168
170
|
};
|
|
169
|
-
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
170
|
-
|
|
171
|
-
const uploaderProps = {
|
|
172
|
-
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
173
|
-
dropzoneProps: reactDesc.PropTypes.object.description('props of react-dropzone https://react-dropzone.netlify.com/'),
|
|
174
|
-
label: reactDesc.PropTypes.string.description('Uploader label').defaultValue('Browse'),
|
|
175
|
-
icon: reactDesc.PropTypes.element.description('Uploader left icon').defaultValue(UploadFile__default['default']),
|
|
176
|
-
actions: reactDesc.PropTypes.shape({
|
|
177
|
-
defaultAction: reactDesc.PropTypes.string,
|
|
178
|
-
altAction: reactDesc.PropTypes.string
|
|
179
|
-
}).description('Uploader actions').defaultValue({
|
|
180
|
-
defaultAction: 'LOCAL DRIVE'
|
|
181
|
-
}),
|
|
182
|
-
defaultActionLabel: reactDesc.PropTypes.string.description('First action button label'),
|
|
183
|
-
showAltAction: reactDesc.PropTypes.bool.description('whether to show alternate action button or not').defaultValue(true),
|
|
184
|
-
altActionLabel: reactDesc.PropTypes.string.description('Second action button label').defaultValue('LOCAL DRIVE'),
|
|
185
|
-
dragActiveInstructionalText: reactDesc.PropTypes.string.description('informative text when user drags a file over the uploader zone').defaultValue('DROP FILES HERE'),
|
|
186
|
-
dragActiveIcon: reactDesc.PropTypes.string.description('Icon when user drags a file over the uploader zone'),
|
|
187
|
-
acceptedTypesText: reactDesc.PropTypes.string.description('Information text to show what types are supported').defaultValue('JPG, JPEG, PNG, PDF'),
|
|
188
|
-
disabledDefault: reactDesc.PropTypes.bool.description('Whether the default uploader is disabled or not').defaultValue(false),
|
|
189
|
-
disabledAlt: reactDesc.PropTypes.bool.description('Whether the alternative uploader is disabled or not').defaultValue(false),
|
|
190
|
-
onDefaultHandlerClick: reactDesc.PropTypes.func.description('First action button click handler'),
|
|
191
|
-
onAltHandlerClick: reactDesc.PropTypes.func.description('Second action button click handler'),
|
|
192
|
-
defaultActionTooltipText: reactDesc.PropTypes.string.description('shows tooltip in default action button'),
|
|
193
|
-
altActionTooltipText: reactDesc.PropTypes.string.description('Shows tooltip in alternate action button')
|
|
194
|
-
};
|
|
195
171
|
const UploaderWithSchema = reactDesc.describe(DSUploader);
|
|
196
|
-
UploaderWithSchema.propTypes =
|
|
172
|
+
UploaderWithSchema.propTypes = propTypes.propTypes;
|
|
197
173
|
|
|
198
174
|
exports.UploaderWithSchema = UploaderWithSchema;
|
|
199
|
-
exports[
|
|
175
|
+
exports["default"] = DSUploader;
|
package/cjs/index.d.js
ADDED
package/cjs/index.js
CHANGED
package/cjs/propTypes.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
var UploadFile = require('@elliemae/ds-icons/UploadFile');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var UploadFile__default = /*#__PURE__*/_interopDefaultLegacy(UploadFile);
|
|
11
|
+
|
|
12
|
+
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
13
|
+
|
|
14
|
+
const propTypes = {
|
|
15
|
+
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container.'),
|
|
16
|
+
validator: reactDesc.PropTypes.func.description("Custom validator. It must return null if it's valid or an object `{ code: string, message: string }` if it's not."),
|
|
17
|
+
maxFiles: reactDesc.PropTypes.number.description('Number of files accepted.'),
|
|
18
|
+
minSize: reactDesc.PropTypes.number.description('Minimun file size accepted in bytes.'),
|
|
19
|
+
maxSize: reactDesc.PropTypes.number.description('Maximum file size accepted in bytes.'),
|
|
20
|
+
onDropRejected: reactDesc.PropTypes.func.description('Cb called when files are rejected using maxFiles, minSize or maxSize properties.'),
|
|
21
|
+
disabled: reactDesc.PropTypes.bool.description('Disables the DSUploader.'),
|
|
22
|
+
multiple: reactDesc.PropTypes.bool.description('Set to false to restrict multiple files selection/upload.'),
|
|
23
|
+
accept: reactDesc.PropTypes.string.description('String containing the accepted MIME type for the DSUploader'),
|
|
24
|
+
label: reactDesc.PropTypes.string.description('Uploader label.').defaultValue('Browse'),
|
|
25
|
+
icon: reactDesc.PropTypes.element.description('Uploader left icon.').defaultValue(UploadFile__default["default"]),
|
|
26
|
+
actions: reactDesc.PropTypes.shape({
|
|
27
|
+
defaultAction: reactDesc.PropTypes.string,
|
|
28
|
+
altAction: reactDesc.PropTypes.string
|
|
29
|
+
}).description('Uploader actions.').defaultValue({
|
|
30
|
+
defaultAction: 'LOCAL DRIVE'
|
|
31
|
+
}),
|
|
32
|
+
defaultActionLabel: reactDesc.PropTypes.string.description('First action button label.'),
|
|
33
|
+
showAltAction: reactDesc.PropTypes.bool.description('whether to show alternate action button or not.').defaultValue(true),
|
|
34
|
+
altActionLabel: reactDesc.PropTypes.string.description('Second action button label.').defaultValue('LOCAL DRIVE'),
|
|
35
|
+
dragActiveInstructionalText: reactDesc.PropTypes.string.description('informative text when user drags a file over the uploader zone.').defaultValue('DROP FILES HERE'),
|
|
36
|
+
dragActiveIcon: reactDesc.PropTypes.string.description('Icon when user drags a file over the uploader zone.'),
|
|
37
|
+
acceptedTypesText: reactDesc.PropTypes.string.description('Information text to show what types are supported.').defaultValue('JPG, JPEG, PNG, PDF'),
|
|
38
|
+
disabledDefault: reactDesc.PropTypes.bool.description('Whether the default uploader is disabled or not.').defaultValue(false),
|
|
39
|
+
disabledAlt: reactDesc.PropTypes.bool.description('Whether the alternative uploader is disabled or not.').defaultValue(false),
|
|
40
|
+
onDefaultHandlerClick: reactDesc.PropTypes.func.description('First action button click handler.'),
|
|
41
|
+
onAltHandlerClick: reactDesc.PropTypes.func.description('Second action button click handler.'),
|
|
42
|
+
defaultActionTooltipText: reactDesc.PropTypes.string.description('shows tooltip in default action button.'),
|
|
43
|
+
altActionTooltipText: reactDesc.PropTypes.string.description('Shows tooltip in alternate action button.')
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.propTypes = propTypes;
|
package/esm/DSUploader.js
CHANGED
|
@@ -2,13 +2,14 @@ import _jsx2 from '@babel/runtime/helpers/esm/jsx';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
4
|
import 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { describe } from 'react-desc';
|
|
6
6
|
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
7
7
|
import { runAll } from '@elliemae/ds-utilities/utils';
|
|
8
8
|
import UploadFile from '@elliemae/ds-icons/UploadFile';
|
|
9
9
|
import DSButton, { BUTTON_VARIANT } from '@elliemae/ds-basic/Button';
|
|
10
10
|
import { useDropzone } from 'react-dropzone';
|
|
11
11
|
import DSTooltip from '@elliemae/ds-basic/Tooltip';
|
|
12
|
+
import { propTypes } from './propTypes.js';
|
|
12
13
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
13
14
|
|
|
14
15
|
var _DividerVertical, _DividerVertical2;
|
|
@@ -44,7 +45,7 @@ const DividerVertical = aggregatedClasses('div')('divider', null, ({
|
|
|
44
45
|
vertical
|
|
45
46
|
}) => ({
|
|
46
47
|
vertical
|
|
47
|
-
}));
|
|
48
|
+
}));
|
|
48
49
|
|
|
49
50
|
function ActionButton(_ref) {
|
|
50
51
|
let {
|
|
@@ -78,7 +79,8 @@ const DSUploader = _ref2 => {
|
|
|
78
79
|
onDefaultHandlerClick = noop,
|
|
79
80
|
onAltHandlerClick = noop,
|
|
80
81
|
actions = {
|
|
81
|
-
defaultAction: 'LOCAL DRIVE'
|
|
82
|
+
defaultAction: 'LOCAL DRIVE',
|
|
83
|
+
altAction: 'DOCUMENTS'
|
|
82
84
|
},
|
|
83
85
|
showAltAction = false,
|
|
84
86
|
defaultActionTooltipText,
|
|
@@ -153,33 +155,7 @@ DSUploader.actions = {
|
|
|
153
155
|
defaultAction: 'LOCAL DRIVE',
|
|
154
156
|
altAction: 'DOCUMENTS'
|
|
155
157
|
};
|
|
156
|
-
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
157
|
-
|
|
158
|
-
const uploaderProps = {
|
|
159
|
-
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
160
|
-
dropzoneProps: PropTypes.object.description('props of react-dropzone https://react-dropzone.netlify.com/'),
|
|
161
|
-
label: PropTypes.string.description('Uploader label').defaultValue('Browse'),
|
|
162
|
-
icon: PropTypes.element.description('Uploader left icon').defaultValue(UploadFile),
|
|
163
|
-
actions: PropTypes.shape({
|
|
164
|
-
defaultAction: PropTypes.string,
|
|
165
|
-
altAction: PropTypes.string
|
|
166
|
-
}).description('Uploader actions').defaultValue({
|
|
167
|
-
defaultAction: 'LOCAL DRIVE'
|
|
168
|
-
}),
|
|
169
|
-
defaultActionLabel: PropTypes.string.description('First action button label'),
|
|
170
|
-
showAltAction: PropTypes.bool.description('whether to show alternate action button or not').defaultValue(true),
|
|
171
|
-
altActionLabel: PropTypes.string.description('Second action button label').defaultValue('LOCAL DRIVE'),
|
|
172
|
-
dragActiveInstructionalText: PropTypes.string.description('informative text when user drags a file over the uploader zone').defaultValue('DROP FILES HERE'),
|
|
173
|
-
dragActiveIcon: PropTypes.string.description('Icon when user drags a file over the uploader zone'),
|
|
174
|
-
acceptedTypesText: PropTypes.string.description('Information text to show what types are supported').defaultValue('JPG, JPEG, PNG, PDF'),
|
|
175
|
-
disabledDefault: PropTypes.bool.description('Whether the default uploader is disabled or not').defaultValue(false),
|
|
176
|
-
disabledAlt: PropTypes.bool.description('Whether the alternative uploader is disabled or not').defaultValue(false),
|
|
177
|
-
onDefaultHandlerClick: PropTypes.func.description('First action button click handler'),
|
|
178
|
-
onAltHandlerClick: PropTypes.func.description('Second action button click handler'),
|
|
179
|
-
defaultActionTooltipText: PropTypes.string.description('shows tooltip in default action button'),
|
|
180
|
-
altActionTooltipText: PropTypes.string.description('Shows tooltip in alternate action button')
|
|
181
|
-
};
|
|
182
158
|
const UploaderWithSchema = describe(DSUploader);
|
|
183
|
-
UploaderWithSchema.propTypes =
|
|
159
|
+
UploaderWithSchema.propTypes = propTypes;
|
|
184
160
|
|
|
185
161
|
export { UploaderWithSchema, DSUploader as default };
|
package/esm/index.d.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/esm/propTypes.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
import UploadFile from '@elliemae/ds-icons/UploadFile';
|
|
3
|
+
|
|
4
|
+
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
5
|
+
|
|
6
|
+
const propTypes = {
|
|
7
|
+
containerProps: PropTypes.object.description('Set of Properties attached to the main container.'),
|
|
8
|
+
validator: PropTypes.func.description("Custom validator. It must return null if it's valid or an object `{ code: string, message: string }` if it's not."),
|
|
9
|
+
maxFiles: PropTypes.number.description('Number of files accepted.'),
|
|
10
|
+
minSize: PropTypes.number.description('Minimun file size accepted in bytes.'),
|
|
11
|
+
maxSize: PropTypes.number.description('Maximum file size accepted in bytes.'),
|
|
12
|
+
onDropRejected: PropTypes.func.description('Cb called when files are rejected using maxFiles, minSize or maxSize properties.'),
|
|
13
|
+
disabled: PropTypes.bool.description('Disables the DSUploader.'),
|
|
14
|
+
multiple: PropTypes.bool.description('Set to false to restrict multiple files selection/upload.'),
|
|
15
|
+
accept: PropTypes.string.description('String containing the accepted MIME type for the DSUploader'),
|
|
16
|
+
label: PropTypes.string.description('Uploader label.').defaultValue('Browse'),
|
|
17
|
+
icon: PropTypes.element.description('Uploader left icon.').defaultValue(UploadFile),
|
|
18
|
+
actions: PropTypes.shape({
|
|
19
|
+
defaultAction: PropTypes.string,
|
|
20
|
+
altAction: PropTypes.string
|
|
21
|
+
}).description('Uploader actions.').defaultValue({
|
|
22
|
+
defaultAction: 'LOCAL DRIVE'
|
|
23
|
+
}),
|
|
24
|
+
defaultActionLabel: PropTypes.string.description('First action button label.'),
|
|
25
|
+
showAltAction: PropTypes.bool.description('whether to show alternate action button or not.').defaultValue(true),
|
|
26
|
+
altActionLabel: PropTypes.string.description('Second action button label.').defaultValue('LOCAL DRIVE'),
|
|
27
|
+
dragActiveInstructionalText: PropTypes.string.description('informative text when user drags a file over the uploader zone.').defaultValue('DROP FILES HERE'),
|
|
28
|
+
dragActiveIcon: PropTypes.string.description('Icon when user drags a file over the uploader zone.'),
|
|
29
|
+
acceptedTypesText: PropTypes.string.description('Information text to show what types are supported.').defaultValue('JPG, JPEG, PNG, PDF'),
|
|
30
|
+
disabledDefault: PropTypes.bool.description('Whether the default uploader is disabled or not.').defaultValue(false),
|
|
31
|
+
disabledAlt: PropTypes.bool.description('Whether the alternative uploader is disabled or not.').defaultValue(false),
|
|
32
|
+
onDefaultHandlerClick: PropTypes.func.description('First action button click handler.'),
|
|
33
|
+
onAltHandlerClick: PropTypes.func.description('Second action button click handler.'),
|
|
34
|
+
defaultActionTooltipText: PropTypes.string.description('shows tooltip in default action button.'),
|
|
35
|
+
altActionTooltipText: PropTypes.string.description('Shows tooltip in alternate action button.')
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { propTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-uploader",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Uploader",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"import": "./esm/index.js",
|
|
12
12
|
"require": "./cjs/index.js"
|
|
13
13
|
},
|
|
14
|
+
"./propTypes": {
|
|
15
|
+
"import": "./esm/propTypes.js",
|
|
16
|
+
"require": "./cjs/propTypes.js"
|
|
17
|
+
},
|
|
14
18
|
"./DSUploader": {
|
|
15
19
|
"import": "./esm/DSUploader.js",
|
|
16
20
|
"require": "./cjs/DSUploader.js"
|
|
@@ -36,9 +40,9 @@
|
|
|
36
40
|
"build": "node ../../scripts/build/build.js"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
|
-
"@elliemae/ds-basic": "2.0.0-alpha.
|
|
40
|
-
"@elliemae/ds-classnames": "2.0.0-alpha.
|
|
41
|
-
"@elliemae/ds-utilities": "2.0.0-alpha.
|
|
43
|
+
"@elliemae/ds-basic": "2.0.0-alpha.10",
|
|
44
|
+
"@elliemae/ds-classnames": "2.0.0-alpha.10",
|
|
45
|
+
"@elliemae/ds-utilities": "2.0.0-alpha.10",
|
|
42
46
|
"react-dropzone": "~10.2.2"
|
|
43
47
|
},
|
|
44
48
|
"publishConfig": {
|
package/types/DSUploader.d.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { DSUploaderPropsT } from './index.d';
|
|
2
3
|
declare const DSUploader: {
|
|
3
|
-
({ containerProps, label, icon: UploadFileIcon, defaultActionLabel, dragActiveInstructionalText, dragActiveIcon: DragActiveIcon, altActionLabel, acceptedTypesText, disabledDefault, disabledAlt, onDefaultHandlerClick, onAltHandlerClick, actions, showAltAction, defaultActionTooltipText, altActionTooltipText, ...dropzoneProps }:
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
containerProps?: {} | undefined;
|
|
6
|
-
label?: string | undefined;
|
|
7
|
-
icon?: any;
|
|
8
|
-
defaultActionLabel?: string | undefined;
|
|
9
|
-
dragActiveInstructionalText?: string | undefined;
|
|
10
|
-
dragActiveIcon?: any;
|
|
11
|
-
altActionLabel?: string | undefined;
|
|
12
|
-
acceptedTypesText?: string | undefined;
|
|
13
|
-
disabledDefault?: boolean | undefined;
|
|
14
|
-
disabledAlt?: boolean | undefined;
|
|
15
|
-
onDefaultHandlerClick?: (() => null) | undefined;
|
|
16
|
-
onAltHandlerClick?: (() => null) | undefined;
|
|
17
|
-
actions?: {
|
|
18
|
-
defaultAction: string;
|
|
19
|
-
} | undefined;
|
|
20
|
-
showAltAction?: boolean | undefined;
|
|
21
|
-
defaultActionTooltipText: any;
|
|
22
|
-
altActionTooltipText: any;
|
|
23
|
-
}): JSX.Element;
|
|
4
|
+
({ containerProps, label, icon: UploadFileIcon, defaultActionLabel, dragActiveInstructionalText, dragActiveIcon: DragActiveIcon, altActionLabel, acceptedTypesText, disabledDefault, disabledAlt, onDefaultHandlerClick, onAltHandlerClick, actions, showAltAction, defaultActionTooltipText, altActionTooltipText, ...dropzoneProps }: DSUploaderPropsT): JSX.Element;
|
|
24
5
|
actions: {
|
|
25
6
|
defaultAction: string;
|
|
26
7
|
altAction: string;
|
|
27
8
|
};
|
|
28
9
|
propTypes: {
|
|
29
10
|
containerProps: any;
|
|
30
|
-
|
|
11
|
+
validator: any;
|
|
12
|
+
maxFiles: any;
|
|
13
|
+
minSize: any;
|
|
14
|
+
maxSize: any;
|
|
15
|
+
onDropRejected: any;
|
|
16
|
+
disabled: any;
|
|
17
|
+
multiple: any;
|
|
18
|
+
accept: any;
|
|
31
19
|
label: any;
|
|
32
20
|
icon: any;
|
|
33
21
|
actions: any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface DSUploaderPropsT {
|
|
3
|
+
containerProps?: Record<string, unknown>;
|
|
4
|
+
label?: string;
|
|
5
|
+
icon?: React.FC<{
|
|
6
|
+
size: string;
|
|
7
|
+
}>;
|
|
8
|
+
defaultActionLabel?: string;
|
|
9
|
+
dragActiveInstructionalText?: string;
|
|
10
|
+
dragActiveIcon?: React.FC;
|
|
11
|
+
altActionLabel?: string;
|
|
12
|
+
acceptedTypesText?: string;
|
|
13
|
+
disabledDefault?: boolean;
|
|
14
|
+
disabledAlt?: boolean;
|
|
15
|
+
onDefaultHandlerClick?: () => void | null;
|
|
16
|
+
onAltHandlerClick?: () => void | null;
|
|
17
|
+
actions?: Record<string, unknown>;
|
|
18
|
+
showAltAction?: boolean;
|
|
19
|
+
defaultActionTooltipText: string;
|
|
20
|
+
altActionTooltipText: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ActionButtonPropsT {
|
|
23
|
+
labelText: string;
|
|
24
|
+
variant: undefined | 'variant-disabled';
|
|
25
|
+
onClick: () => void | null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
2
|
+
export declare const propTypes: {
|
|
3
|
+
containerProps: any;
|
|
4
|
+
validator: any;
|
|
5
|
+
maxFiles: any;
|
|
6
|
+
minSize: any;
|
|
7
|
+
maxSize: any;
|
|
8
|
+
onDropRejected: any;
|
|
9
|
+
disabled: any;
|
|
10
|
+
multiple: any;
|
|
11
|
+
accept: any;
|
|
12
|
+
label: any;
|
|
13
|
+
icon: any;
|
|
14
|
+
actions: any;
|
|
15
|
+
defaultActionLabel: any;
|
|
16
|
+
showAltAction: any;
|
|
17
|
+
altActionLabel: any;
|
|
18
|
+
dragActiveInstructionalText: any;
|
|
19
|
+
dragActiveIcon: any;
|
|
20
|
+
acceptedTypesText: any;
|
|
21
|
+
disabledDefault: any;
|
|
22
|
+
disabledAlt: any;
|
|
23
|
+
onDefaultHandlerClick: any;
|
|
24
|
+
onAltHandlerClick: any;
|
|
25
|
+
defaultActionTooltipText: any;
|
|
26
|
+
altActionTooltipText: any;
|
|
27
|
+
};
|