@elliemae/ds-uploader 2.3.0-next.0 → 3.0.0-alpha.0
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/dist/cjs/DSUploader.js +135 -0
- package/dist/cjs/DSUploader.js.map +7 -0
- package/dist/cjs/index.d.js +27 -0
- package/dist/cjs/index.d.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +65 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/esm/DSUploader.js +106 -0
- package/dist/esm/DSUploader.js.map +7 -0
- package/dist/esm/index.d.js +2 -0
- package/dist/esm/index.d.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +36 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/{types → dist/types}/DSUploader.d.ts +0 -0
- package/{types → dist/types}/index.d.d.ts +0 -0
- package/{types → dist/types}/index.d.ts +0 -0
- package/{types → dist/types}/propTypes.d.ts +0 -0
- package/{types → dist/types}/tests/DSUploader.test.d.ts +0 -0
- package/package.json +33 -25
- package/cjs/DSUploader.js +0 -189
- package/cjs/index.d.js +0 -2
- package/cjs/index.js +0 -10
- package/cjs/propTypes.js +0 -42
- package/esm/DSUploader.js +0 -176
- package/esm/index.d.js +0 -1
- package/esm/index.js +0 -1
- package/esm/propTypes.js +0 -38
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var DSUploader_exports = {};
|
|
29
|
+
__export(DSUploader_exports, {
|
|
30
|
+
UploaderWithSchema: () => UploaderWithSchema,
|
|
31
|
+
default: () => DSUploader_default
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_react_desc = require("react-desc");
|
|
36
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
37
|
+
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
38
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
39
|
+
var import_ds_button = __toESM(require("@elliemae/ds-button"));
|
|
40
|
+
var import_react_dropzone = require("react-dropzone");
|
|
41
|
+
var import_ds_tooltip = __toESM(require("@elliemae/ds-tooltip"));
|
|
42
|
+
var import_propTypes = require("./propTypes");
|
|
43
|
+
const blockName = "uploader";
|
|
44
|
+
const blockNameInfo = `${blockName}-info`;
|
|
45
|
+
const blockNameDragActive = `${blockName}-drag-active`;
|
|
46
|
+
const blockNameWrapper = `${blockName}-wrapper`;
|
|
47
|
+
const UploaderWrapper = (0, import_ds_classnames.aggregatedClasses)("div")(blockNameWrapper, null, ({ disabled }) => ({ disabled }));
|
|
48
|
+
const Uploader = (0, import_ds_classnames.aggregatedClasses)("div")(blockName, null, ({ isDragActive }) => ({ "drag-active": isDragActive }));
|
|
49
|
+
const UploaderDragActive = (0, import_ds_classnames.aggregatedClasses)("div")(blockNameDragActive);
|
|
50
|
+
const UploaderIconArea = (0, import_ds_classnames.aggregatedClasses)("div")(`${blockName}-icon-wrapper`);
|
|
51
|
+
const UploaderInfo = (0, import_ds_classnames.aggregatedClasses)("div")(blockNameInfo);
|
|
52
|
+
const InfoText = (0, import_ds_classnames.aggregatedClasses)("span")(blockNameInfo, "text");
|
|
53
|
+
const UploaderActions = (0, import_ds_classnames.aggregatedClasses)("div")(blockNameInfo, "actions");
|
|
54
|
+
const AcceptedTypes = (0, import_ds_classnames.aggregatedClasses)("div")(blockNameWrapper, "accepted-types");
|
|
55
|
+
const DividerVertical = (0, import_ds_classnames.aggregatedClasses)("div")("divider", null, ({ vertical }) => ({ vertical }));
|
|
56
|
+
function ActionButton({ labelText, ...otherProps }) {
|
|
57
|
+
return /* @__PURE__ */ import_react.default.createElement(import_ds_button.default, {
|
|
58
|
+
...otherProps,
|
|
59
|
+
buttonType: "text",
|
|
60
|
+
labelText
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const noop = () => null;
|
|
64
|
+
const DSUploader = ({
|
|
65
|
+
containerProps = {},
|
|
66
|
+
label = "Browse",
|
|
67
|
+
icon: UploadFileIcon = import_ds_icons.UploadFile,
|
|
68
|
+
defaultActionLabel = "LOCAL DRIVE",
|
|
69
|
+
dragActiveInstructionalText = "DROP FILES HERE",
|
|
70
|
+
dragActiveIcon: DragActiveIcon = import_ds_icons.UploadFile,
|
|
71
|
+
altActionLabel = "DOCUMENTS",
|
|
72
|
+
acceptedTypesText = "JPG, JPEG, PNG, PDF",
|
|
73
|
+
disabledDefault = false,
|
|
74
|
+
disabledAlt = false,
|
|
75
|
+
onDefaultHandlerClick = noop,
|
|
76
|
+
onAltHandlerClick = noop,
|
|
77
|
+
actions = { defaultAction: "LOCAL DRIVE", altAction: "DOCUMENTS" },
|
|
78
|
+
showAltAction = false,
|
|
79
|
+
defaultActionTooltipText,
|
|
80
|
+
altActionTooltipText,
|
|
81
|
+
...dropzoneProps
|
|
82
|
+
}) => {
|
|
83
|
+
const { getRootProps, getInputProps, isDragActive } = (0, import_react_dropzone.useDropzone)(dropzoneProps);
|
|
84
|
+
const { onClick: onOpenFile, ...rootProps } = getRootProps();
|
|
85
|
+
const disabledAll = disabledDefault && disabledAlt;
|
|
86
|
+
const delfaultActionButton = /* @__PURE__ */ import_react.default.createElement(ActionButton, {
|
|
87
|
+
variant: disabledDefault && import_ds_button.BUTTON_VARIANT.DISABLED,
|
|
88
|
+
labelText: actions.defaultAction ? actions.defaultAction : defaultActionLabel,
|
|
89
|
+
onClick: (...args) => {
|
|
90
|
+
if (!disabledDefault)
|
|
91
|
+
(0, import_ds_utilities.runAll)(onDefaultHandlerClick, onOpenFile)(...args);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const altActionButton = /* @__PURE__ */ import_react.default.createElement(ActionButton, {
|
|
95
|
+
variant: disabledAlt && import_ds_button.BUTTON_VARIANT.DISABLED,
|
|
96
|
+
labelText: actions.altAction ? actions.altAction : altActionLabel,
|
|
97
|
+
onClick: (...args) => {
|
|
98
|
+
if (!disabledAlt)
|
|
99
|
+
onAltHandlerClick(...args);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /* @__PURE__ */ import_react.default.createElement(import_ds_tooltip.default, {
|
|
103
|
+
containerProps: { id: "default-action-tooltip" },
|
|
104
|
+
interactionType: "hover",
|
|
105
|
+
title: defaultActionTooltipText,
|
|
106
|
+
triggerComponent: delfaultActionButton
|
|
107
|
+
});
|
|
108
|
+
const altAction = !altActionTooltipText ? altActionButton : /* @__PURE__ */ import_react.default.createElement(import_ds_tooltip.default, {
|
|
109
|
+
containerProps: { id: "alt-action-tooltip" },
|
|
110
|
+
interactionType: "hover",
|
|
111
|
+
title: altActionTooltipText,
|
|
112
|
+
triggerComponent: altActionButton
|
|
113
|
+
});
|
|
114
|
+
return /* @__PURE__ */ import_react.default.createElement(UploaderWrapper, {
|
|
115
|
+
...containerProps,
|
|
116
|
+
classProps: { disabled: disabledAll }
|
|
117
|
+
}, /* @__PURE__ */ import_react.default.createElement(Uploader, {
|
|
118
|
+
...rootProps,
|
|
119
|
+
classProps: { isDragActive }
|
|
120
|
+
}, /* @__PURE__ */ import_react.default.createElement(UploaderIconArea, null, /* @__PURE__ */ import_react.default.createElement(UploadFileIcon, {
|
|
121
|
+
size: "l"
|
|
122
|
+
})), /* @__PURE__ */ import_react.default.createElement(DividerVertical, null), /* @__PURE__ */ import_react.default.createElement(UploaderInfo, null, /* @__PURE__ */ import_react.default.createElement(InfoText, null, label), /* @__PURE__ */ import_react.default.createElement(UploaderActions, null, actions.defaultAction && defaultAction, (actions.altAction || showAltAction) && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, actions.defaultAction && /* @__PURE__ */ import_react.default.createElement(DividerVertical, null), altAction))), !disabledAll && /* @__PURE__ */ import_react.default.createElement(UploaderDragActive, null, /* @__PURE__ */ import_react.default.createElement(DragActiveIcon, null), dragActiveInstructionalText), !disabledAll && /* @__PURE__ */ import_react.default.createElement("input", {
|
|
123
|
+
...getInputProps()
|
|
124
|
+
})), typeof acceptedTypesText === "string" && /* @__PURE__ */ import_react.default.createElement(AcceptedTypes, null, acceptedTypesText.toUpperCase()));
|
|
125
|
+
};
|
|
126
|
+
DSUploader.actions = {
|
|
127
|
+
defaultAction: "LOCAL DRIVE",
|
|
128
|
+
altAction: "DOCUMENTS"
|
|
129
|
+
};
|
|
130
|
+
DSUploader.propTypes = import_propTypes.propTypes;
|
|
131
|
+
const UploaderWithSchema = (0, import_react_desc.describe)(DSUploader);
|
|
132
|
+
UploaderWithSchema.propTypes = import_propTypes.propTypes;
|
|
133
|
+
var DSUploader_default = DSUploader;
|
|
134
|
+
module.exports = __toCommonJS(DSUploader_exports);
|
|
135
|
+
//# sourceMappingURL=DSUploader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSUploader.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { describe } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { runAll } from '@elliemae/ds-utilities';\nimport { UploadFile } from '@elliemae/ds-icons';\nimport DSButton, { BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { useDropzone } from 'react-dropzone';\nimport DSTooltip from '@elliemae/ds-tooltip';\nimport { propTypes } from './propTypes';\nimport type { DSUploaderPropsT, ActionButtonPropsT } from './index.d';\n\nconst blockName = 'uploader';\nconst blockNameInfo = `${blockName}-info`;\nconst blockNameDragActive = `${blockName}-drag-active`;\nconst blockNameWrapper = `${blockName}-wrapper`;\n\nconst UploaderWrapper = aggregatedClasses('div')(blockNameWrapper, null, ({ disabled }) => ({ disabled }));\nconst Uploader = aggregatedClasses('div')(blockName, null, ({ isDragActive }) => ({ 'drag-active': isDragActive }));\nconst UploaderDragActive = aggregatedClasses('div')(blockNameDragActive);\nconst UploaderIconArea = aggregatedClasses('div')(`${blockName}-icon-wrapper`);\nconst UploaderInfo = aggregatedClasses('div')(blockNameInfo);\nconst InfoText = aggregatedClasses('span')(blockNameInfo, 'text');\nconst UploaderActions = aggregatedClasses('div')(blockNameInfo, 'actions');\nconst AcceptedTypes = aggregatedClasses('div')(blockNameWrapper, 'accepted-types');\n\nconst DividerVertical = aggregatedClasses('div')('divider', null, ({ vertical }) => ({ vertical }));\n\nfunction ActionButton({ labelText, ...otherProps }: ActionButtonPropsT): React.ReactElement {\n return <DSButton {...otherProps} buttonType=\"text\" labelText={labelText} />;\n}\n\nconst noop = () => null;\n\nconst DSUploader = ({\n containerProps = {},\n label = 'Browse', // todo: i18n\n icon: UploadFileIcon = UploadFile,\n defaultActionLabel = 'LOCAL DRIVE', // todo: i18n\n dragActiveInstructionalText = 'DROP FILES HERE',\n dragActiveIcon: DragActiveIcon = UploadFile,\n altActionLabel = 'DOCUMENTS', // todo: i18n\n acceptedTypesText = 'JPG, JPEG, PNG, PDF',\n disabledDefault = false,\n disabledAlt = false,\n onDefaultHandlerClick = noop,\n onAltHandlerClick = noop,\n actions = { defaultAction: 'LOCAL DRIVE', altAction: 'DOCUMENTS' },\n showAltAction = false,\n defaultActionTooltipText,\n altActionTooltipText,\n ...dropzoneProps\n}: DSUploaderPropsT): JSX.Element => {\n const { getRootProps, getInputProps, isDragActive } = useDropzone(dropzoneProps);\n const { onClick: onOpenFile, ...rootProps } = getRootProps();\n const disabledAll = disabledDefault && disabledAlt;\n\n const delfaultActionButton = (\n <ActionButton\n variant={disabledDefault && BUTTON_VARIANT.DISABLED}\n labelText={actions.defaultAction ? (actions.defaultAction as string) : defaultActionLabel}\n onClick={(...args) => {\n if (!disabledDefault) runAll(onDefaultHandlerClick, onOpenFile)(...args);\n }}\n />\n );\n\n const altActionButton = (\n <ActionButton\n variant={disabledAlt && BUTTON_VARIANT.DISABLED}\n labelText={actions.altAction ? (actions.altAction as string) : altActionLabel}\n onClick={(...args) => {\n if (!disabledAlt) onAltHandlerClick(...args);\n }}\n />\n );\n\n const defaultAction = !defaultActionTooltipText ? (\n delfaultActionButton\n ) : (\n <DSTooltip\n containerProps={{ id: 'default-action-tooltip' }}\n interactionType=\"hover\"\n title={defaultActionTooltipText}\n triggerComponent={delfaultActionButton}\n />\n );\n\n const altAction = !altActionTooltipText ? (\n altActionButton\n ) : (\n <DSTooltip\n containerProps={{ id: 'alt-action-tooltip' }}\n interactionType=\"hover\"\n title={altActionTooltipText}\n triggerComponent={altActionButton}\n />\n );\n\n return (\n <UploaderWrapper {...containerProps} classProps={{ disabled: disabledAll }}>\n <Uploader {...rootProps} classProps={{ isDragActive }}>\n <UploaderIconArea>\n <UploadFileIcon size=\"l\" />\n </UploaderIconArea>\n <DividerVertical />\n <UploaderInfo>\n <InfoText>{label}</InfoText>\n <UploaderActions>\n {actions.defaultAction && defaultAction}\n {(actions.altAction || showAltAction) && (\n <>\n {actions.defaultAction && <DividerVertical />}\n {altAction}\n </>\n )}\n </UploaderActions>\n </UploaderInfo>\n {!disabledAll && (\n <UploaderDragActive>\n <DragActiveIcon />\n {dragActiveInstructionalText}\n </UploaderDragActive>\n )}\n {!disabledAll && <input {...getInputProps()} />}\n </Uploader>\n {typeof acceptedTypesText === 'string' && <AcceptedTypes>{acceptedTypesText.toUpperCase()}</AcceptedTypes>}\n </UploaderWrapper>\n );\n};\n\nDSUploader.actions = {\n defaultAction: 'LOCAL DRIVE',\n altAction: 'DOCUMENTS',\n};\n\nDSUploader.propTypes = propTypes;\n\nconst UploaderWithSchema = describe(DSUploader);\nUploaderWithSchema.propTypes = propTypes;\n\nexport { UploaderWithSchema };\nexport default DSUploader;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
9
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(module2))
|
|
11
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
12
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (module2, isNodeMode) => {
|
|
17
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
20
|
+
return (module2, temp) => {
|
|
21
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
22
|
+
};
|
|
23
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
24
|
+
var index_d_exports = {};
|
|
25
|
+
var React = __toESM(require("react"));
|
|
26
|
+
module.exports = __toCommonJS(index_d_exports);
|
|
27
|
+
//# sourceMappingURL=index.d.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.d.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export interface DSUploaderPropsT {\n containerProps?: Record<string, unknown>;\n label?: string;\n icon?: React.FC<{ size: string }>;\n defaultActionLabel?: string;\n dragActiveInstructionalText?: string;\n dragActiveIcon?: React.FC;\n altActionLabel?: string;\n acceptedTypesText?: string;\n disabledDefault?: boolean;\n disabledAlt?: boolean;\n onDefaultHandlerClick?: () => void | null;\n onAltHandlerClick?: () => void | null;\n actions?: Record<string, unknown>;\n showAltAction?: boolean;\n defaultActionTooltipText: string;\n altActionTooltipText: string;\n}\n\nexport interface ActionButtonPropsT {\n labelText: string;\n variant: undefined | 'variant-disabled';\n onClick: () => void | null;\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
UploaderWithSchema: () => import_DSUploader.UploaderWithSchema,
|
|
31
|
+
default: () => import_DSUploader.default
|
|
32
|
+
});
|
|
33
|
+
var React = __toESM(require("react"));
|
|
34
|
+
var import_DSUploader = __toESM(require("./DSUploader"));
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { default, UploaderWithSchema } from './DSUploader';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA4C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var propTypes_exports = {};
|
|
29
|
+
__export(propTypes_exports, {
|
|
30
|
+
propTypes: () => propTypes
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_desc = require("react-desc");
|
|
34
|
+
var import_ds_icons = require("@elliemae/ds-icons");
|
|
35
|
+
const propTypes = {
|
|
36
|
+
containerProps: import_react_desc.PropTypes.object.description("Set of Properties attached to the main container."),
|
|
37
|
+
validator: import_react_desc.PropTypes.func.description("Custom validator. It must return null if it's valid or an object `{ code: string, message: string }` if it's not."),
|
|
38
|
+
maxFiles: import_react_desc.PropTypes.number.description("Number of files accepted."),
|
|
39
|
+
minSize: import_react_desc.PropTypes.number.description("Minimun file size accepted in bytes."),
|
|
40
|
+
maxSize: import_react_desc.PropTypes.number.description("Maximum file size accepted in bytes."),
|
|
41
|
+
onDropRejected: import_react_desc.PropTypes.func.description("Cb called when files are rejected using maxFiles, minSize or maxSize properties."),
|
|
42
|
+
disabled: import_react_desc.PropTypes.bool.description("Disables the DSUploader."),
|
|
43
|
+
multiple: import_react_desc.PropTypes.bool.description("Set to false to restrict multiple files selection/upload."),
|
|
44
|
+
accept: import_react_desc.PropTypes.string.description("String containing the accepted MIME type for the DSUploader"),
|
|
45
|
+
label: import_react_desc.PropTypes.string.description("Uploader label.").defaultValue("Browse"),
|
|
46
|
+
icon: import_react_desc.PropTypes.element.description("Uploader left icon.").defaultValue(import_ds_icons.UploadFile),
|
|
47
|
+
actions: import_react_desc.PropTypes.shape({
|
|
48
|
+
defaultAction: import_react_desc.PropTypes.string,
|
|
49
|
+
altAction: import_react_desc.PropTypes.string
|
|
50
|
+
}).description("Uploader actions.").defaultValue({ defaultAction: "LOCAL DRIVE" }),
|
|
51
|
+
defaultActionLabel: import_react_desc.PropTypes.string.description("First action button label."),
|
|
52
|
+
showAltAction: import_react_desc.PropTypes.bool.description("whether to show alternate action button or not.").defaultValue(true),
|
|
53
|
+
altActionLabel: import_react_desc.PropTypes.string.description("Second action button label.").defaultValue("LOCAL DRIVE"),
|
|
54
|
+
dragActiveInstructionalText: import_react_desc.PropTypes.string.description("informative text when user drags a file over the uploader zone.").defaultValue("DROP FILES HERE"),
|
|
55
|
+
dragActiveIcon: import_react_desc.PropTypes.string.description("Icon when user drags a file over the uploader zone."),
|
|
56
|
+
acceptedTypesText: import_react_desc.PropTypes.string.description("Information text to show what types are supported.").defaultValue("JPG, JPEG, PNG, PDF"),
|
|
57
|
+
disabledDefault: import_react_desc.PropTypes.bool.description("Whether the default uploader is disabled or not.").defaultValue(false),
|
|
58
|
+
disabledAlt: import_react_desc.PropTypes.bool.description("Whether the alternative uploader is disabled or not.").defaultValue(false),
|
|
59
|
+
onDefaultHandlerClick: import_react_desc.PropTypes.func.description("First action button click handler."),
|
|
60
|
+
onAltHandlerClick: import_react_desc.PropTypes.func.description("Second action button click handler."),
|
|
61
|
+
defaultActionTooltipText: import_react_desc.PropTypes.string.description("shows tooltip in default action button."),
|
|
62
|
+
altActionTooltipText: import_react_desc.PropTypes.string.description("Shows tooltip in alternate action button.")
|
|
63
|
+
};
|
|
64
|
+
module.exports = __toCommonJS(propTypes_exports);
|
|
65
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/propTypes.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { PropTypes } from 'react-desc';\nimport { UploadFile } from '@elliemae/ds-icons';\n/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */\n\nexport const propTypes = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container.'),\n validator: PropTypes.func.description(\n \"Custom validator. It must return null if it's valid or an object `{ code: string, message: string }` if it's not.\",\n ),\n maxFiles: PropTypes.number.description('Number of files accepted.'),\n minSize: PropTypes.number.description('Minimun file size accepted in bytes.'),\n maxSize: PropTypes.number.description('Maximum file size accepted in bytes.'),\n onDropRejected: PropTypes.func.description(\n 'Cb called when files are rejected using maxFiles, minSize or maxSize properties.',\n ),\n disabled: PropTypes.bool.description('Disables the DSUploader.'),\n multiple: PropTypes.bool.description('Set to false to restrict multiple files selection/upload.'),\n accept: PropTypes.string.description('String containing the accepted MIME type for the DSUploader'),\n\n label: PropTypes.string.description('Uploader label.').defaultValue('Browse'),\n icon: PropTypes.element.description('Uploader left icon.').defaultValue(UploadFile),\n actions: PropTypes.shape({\n defaultAction: PropTypes.string,\n altAction: PropTypes.string,\n })\n .description('Uploader actions.')\n .defaultValue({ defaultAction: 'LOCAL DRIVE' }),\n defaultActionLabel: PropTypes.string.description('First action button label.'),\n showAltAction: PropTypes.bool.description('whether to show alternate action button or not.').defaultValue(true),\n altActionLabel: PropTypes.string.description('Second action button label.').defaultValue('LOCAL DRIVE'),\n dragActiveInstructionalText: PropTypes.string\n .description('informative text when user drags a file over the uploader zone.')\n .defaultValue('DROP FILES HERE'),\n dragActiveIcon: PropTypes.string.description('Icon when user drags a file over the uploader zone.'),\n acceptedTypesText: PropTypes.string\n .description('Information text to show what types are supported.')\n .defaultValue('JPG, JPEG, PNG, PDF'),\n disabledDefault: PropTypes.bool.description('Whether the default uploader is disabled or not.').defaultValue(false),\n disabledAlt: PropTypes.bool.description('Whether the alternative uploader is disabled or not.').defaultValue(false),\n onDefaultHandlerClick: PropTypes.func.description('First action button click handler.'),\n onAltHandlerClick: PropTypes.func.description('Second action button click handler.'),\n defaultActionTooltipText: PropTypes.string.description('shows tooltip in default action button.'),\n altActionTooltipText: PropTypes.string.description('Shows tooltip in alternate action button.'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAC1B,sBAA2B;AAGpB,MAAM,YAAY;AAAA,EACvB,gBAAgB,4BAAU,OAAO,YAAY;AAAA,EAC7C,WAAW,4BAAU,KAAK,YACxB;AAAA,EAEF,UAAU,4BAAU,OAAO,YAAY;AAAA,EACvC,SAAS,4BAAU,OAAO,YAAY;AAAA,EACtC,SAAS,4BAAU,OAAO,YAAY;AAAA,EACtC,gBAAgB,4BAAU,KAAK,YAC7B;AAAA,EAEF,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,UAAU,4BAAU,KAAK,YAAY;AAAA,EACrC,QAAQ,4BAAU,OAAO,YAAY;AAAA,EAErC,OAAO,4BAAU,OAAO,YAAY,mBAAmB,aAAa;AAAA,EACpE,MAAM,4BAAU,QAAQ,YAAY,uBAAuB,aAAa;AAAA,EACxE,SAAS,4BAAU,MAAM;AAAA,IACvB,eAAe,4BAAU;AAAA,IACzB,WAAW,4BAAU;AAAA,KAEpB,YAAY,qBACZ,aAAa,EAAE,eAAe;AAAA,EACjC,oBAAoB,4BAAU,OAAO,YAAY;AAAA,EACjD,eAAe,4BAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EAC1G,gBAAgB,4BAAU,OAAO,YAAY,+BAA+B,aAAa;AAAA,EACzF,6BAA6B,4BAAU,OACpC,YAAY,mEACZ,aAAa;AAAA,EAChB,gBAAgB,4BAAU,OAAO,YAAY;AAAA,EAC7C,mBAAmB,4BAAU,OAC1B,YAAY,sDACZ,aAAa;AAAA,EAChB,iBAAiB,4BAAU,KAAK,YAAY,oDAAoD,aAAa;AAAA,EAC7G,aAAa,4BAAU,KAAK,YAAY,wDAAwD,aAAa;AAAA,EAC7G,uBAAuB,4BAAU,KAAK,YAAY;AAAA,EAClD,mBAAmB,4BAAU,KAAK,YAAY;AAAA,EAC9C,0BAA0B,4BAAU,OAAO,YAAY;AAAA,EACvD,sBAAsB,4BAAU,OAAO,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { describe } from "react-desc";
|
|
4
|
+
import { aggregatedClasses } from "@elliemae/ds-classnames";
|
|
5
|
+
import { runAll } from "@elliemae/ds-utilities";
|
|
6
|
+
import { UploadFile } from "@elliemae/ds-icons";
|
|
7
|
+
import DSButton, { BUTTON_VARIANT } from "@elliemae/ds-button";
|
|
8
|
+
import { useDropzone } from "react-dropzone";
|
|
9
|
+
import DSTooltip from "@elliemae/ds-tooltip";
|
|
10
|
+
import { propTypes } from "./propTypes";
|
|
11
|
+
const blockName = "uploader";
|
|
12
|
+
const blockNameInfo = `${blockName}-info`;
|
|
13
|
+
const blockNameDragActive = `${blockName}-drag-active`;
|
|
14
|
+
const blockNameWrapper = `${blockName}-wrapper`;
|
|
15
|
+
const UploaderWrapper = aggregatedClasses("div")(blockNameWrapper, null, ({ disabled }) => ({ disabled }));
|
|
16
|
+
const Uploader = aggregatedClasses("div")(blockName, null, ({ isDragActive }) => ({ "drag-active": isDragActive }));
|
|
17
|
+
const UploaderDragActive = aggregatedClasses("div")(blockNameDragActive);
|
|
18
|
+
const UploaderIconArea = aggregatedClasses("div")(`${blockName}-icon-wrapper`);
|
|
19
|
+
const UploaderInfo = aggregatedClasses("div")(blockNameInfo);
|
|
20
|
+
const InfoText = aggregatedClasses("span")(blockNameInfo, "text");
|
|
21
|
+
const UploaderActions = aggregatedClasses("div")(blockNameInfo, "actions");
|
|
22
|
+
const AcceptedTypes = aggregatedClasses("div")(blockNameWrapper, "accepted-types");
|
|
23
|
+
const DividerVertical = aggregatedClasses("div")("divider", null, ({ vertical }) => ({ vertical }));
|
|
24
|
+
function ActionButton({ labelText, ...otherProps }) {
|
|
25
|
+
return /* @__PURE__ */ React2.createElement(DSButton, {
|
|
26
|
+
...otherProps,
|
|
27
|
+
buttonType: "text",
|
|
28
|
+
labelText
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const noop = () => null;
|
|
32
|
+
const DSUploader = ({
|
|
33
|
+
containerProps = {},
|
|
34
|
+
label = "Browse",
|
|
35
|
+
icon: UploadFileIcon = UploadFile,
|
|
36
|
+
defaultActionLabel = "LOCAL DRIVE",
|
|
37
|
+
dragActiveInstructionalText = "DROP FILES HERE",
|
|
38
|
+
dragActiveIcon: DragActiveIcon = UploadFile,
|
|
39
|
+
altActionLabel = "DOCUMENTS",
|
|
40
|
+
acceptedTypesText = "JPG, JPEG, PNG, PDF",
|
|
41
|
+
disabledDefault = false,
|
|
42
|
+
disabledAlt = false,
|
|
43
|
+
onDefaultHandlerClick = noop,
|
|
44
|
+
onAltHandlerClick = noop,
|
|
45
|
+
actions = { defaultAction: "LOCAL DRIVE", altAction: "DOCUMENTS" },
|
|
46
|
+
showAltAction = false,
|
|
47
|
+
defaultActionTooltipText,
|
|
48
|
+
altActionTooltipText,
|
|
49
|
+
...dropzoneProps
|
|
50
|
+
}) => {
|
|
51
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone(dropzoneProps);
|
|
52
|
+
const { onClick: onOpenFile, ...rootProps } = getRootProps();
|
|
53
|
+
const disabledAll = disabledDefault && disabledAlt;
|
|
54
|
+
const delfaultActionButton = /* @__PURE__ */ React2.createElement(ActionButton, {
|
|
55
|
+
variant: disabledDefault && BUTTON_VARIANT.DISABLED,
|
|
56
|
+
labelText: actions.defaultAction ? actions.defaultAction : defaultActionLabel,
|
|
57
|
+
onClick: (...args) => {
|
|
58
|
+
if (!disabledDefault)
|
|
59
|
+
runAll(onDefaultHandlerClick, onOpenFile)(...args);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const altActionButton = /* @__PURE__ */ React2.createElement(ActionButton, {
|
|
63
|
+
variant: disabledAlt && BUTTON_VARIANT.DISABLED,
|
|
64
|
+
labelText: actions.altAction ? actions.altAction : altActionLabel,
|
|
65
|
+
onClick: (...args) => {
|
|
66
|
+
if (!disabledAlt)
|
|
67
|
+
onAltHandlerClick(...args);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /* @__PURE__ */ React2.createElement(DSTooltip, {
|
|
71
|
+
containerProps: { id: "default-action-tooltip" },
|
|
72
|
+
interactionType: "hover",
|
|
73
|
+
title: defaultActionTooltipText,
|
|
74
|
+
triggerComponent: delfaultActionButton
|
|
75
|
+
});
|
|
76
|
+
const altAction = !altActionTooltipText ? altActionButton : /* @__PURE__ */ React2.createElement(DSTooltip, {
|
|
77
|
+
containerProps: { id: "alt-action-tooltip" },
|
|
78
|
+
interactionType: "hover",
|
|
79
|
+
title: altActionTooltipText,
|
|
80
|
+
triggerComponent: altActionButton
|
|
81
|
+
});
|
|
82
|
+
return /* @__PURE__ */ React2.createElement(UploaderWrapper, {
|
|
83
|
+
...containerProps,
|
|
84
|
+
classProps: { disabled: disabledAll }
|
|
85
|
+
}, /* @__PURE__ */ React2.createElement(Uploader, {
|
|
86
|
+
...rootProps,
|
|
87
|
+
classProps: { isDragActive }
|
|
88
|
+
}, /* @__PURE__ */ React2.createElement(UploaderIconArea, null, /* @__PURE__ */ React2.createElement(UploadFileIcon, {
|
|
89
|
+
size: "l"
|
|
90
|
+
})), /* @__PURE__ */ React2.createElement(DividerVertical, null), /* @__PURE__ */ React2.createElement(UploaderInfo, null, /* @__PURE__ */ React2.createElement(InfoText, null, label), /* @__PURE__ */ React2.createElement(UploaderActions, null, actions.defaultAction && defaultAction, (actions.altAction || showAltAction) && /* @__PURE__ */ React2.createElement(React2.Fragment, null, actions.defaultAction && /* @__PURE__ */ React2.createElement(DividerVertical, null), altAction))), !disabledAll && /* @__PURE__ */ React2.createElement(UploaderDragActive, null, /* @__PURE__ */ React2.createElement(DragActiveIcon, null), dragActiveInstructionalText), !disabledAll && /* @__PURE__ */ React2.createElement("input", {
|
|
91
|
+
...getInputProps()
|
|
92
|
+
})), typeof acceptedTypesText === "string" && /* @__PURE__ */ React2.createElement(AcceptedTypes, null, acceptedTypesText.toUpperCase()));
|
|
93
|
+
};
|
|
94
|
+
DSUploader.actions = {
|
|
95
|
+
defaultAction: "LOCAL DRIVE",
|
|
96
|
+
altAction: "DOCUMENTS"
|
|
97
|
+
};
|
|
98
|
+
DSUploader.propTypes = propTypes;
|
|
99
|
+
const UploaderWithSchema = describe(DSUploader);
|
|
100
|
+
UploaderWithSchema.propTypes = propTypes;
|
|
101
|
+
var DSUploader_default = DSUploader;
|
|
102
|
+
export {
|
|
103
|
+
UploaderWithSchema,
|
|
104
|
+
DSUploader_default as default
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=DSUploader.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSUploader.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable complexity */\nimport React from 'react';\nimport { describe } from 'react-desc';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport { runAll } from '@elliemae/ds-utilities';\nimport { UploadFile } from '@elliemae/ds-icons';\nimport DSButton, { BUTTON_VARIANT } from '@elliemae/ds-button';\nimport { useDropzone } from 'react-dropzone';\nimport DSTooltip from '@elliemae/ds-tooltip';\nimport { propTypes } from './propTypes';\nimport type { DSUploaderPropsT, ActionButtonPropsT } from './index.d';\n\nconst blockName = 'uploader';\nconst blockNameInfo = `${blockName}-info`;\nconst blockNameDragActive = `${blockName}-drag-active`;\nconst blockNameWrapper = `${blockName}-wrapper`;\n\nconst UploaderWrapper = aggregatedClasses('div')(blockNameWrapper, null, ({ disabled }) => ({ disabled }));\nconst Uploader = aggregatedClasses('div')(blockName, null, ({ isDragActive }) => ({ 'drag-active': isDragActive }));\nconst UploaderDragActive = aggregatedClasses('div')(blockNameDragActive);\nconst UploaderIconArea = aggregatedClasses('div')(`${blockName}-icon-wrapper`);\nconst UploaderInfo = aggregatedClasses('div')(blockNameInfo);\nconst InfoText = aggregatedClasses('span')(blockNameInfo, 'text');\nconst UploaderActions = aggregatedClasses('div')(blockNameInfo, 'actions');\nconst AcceptedTypes = aggregatedClasses('div')(blockNameWrapper, 'accepted-types');\n\nconst DividerVertical = aggregatedClasses('div')('divider', null, ({ vertical }) => ({ vertical }));\n\nfunction ActionButton({ labelText, ...otherProps }: ActionButtonPropsT): React.ReactElement {\n return <DSButton {...otherProps} buttonType=\"text\" labelText={labelText} />;\n}\n\nconst noop = () => null;\n\nconst DSUploader = ({\n containerProps = {},\n label = 'Browse', // todo: i18n\n icon: UploadFileIcon = UploadFile,\n defaultActionLabel = 'LOCAL DRIVE', // todo: i18n\n dragActiveInstructionalText = 'DROP FILES HERE',\n dragActiveIcon: DragActiveIcon = UploadFile,\n altActionLabel = 'DOCUMENTS', // todo: i18n\n acceptedTypesText = 'JPG, JPEG, PNG, PDF',\n disabledDefault = false,\n disabledAlt = false,\n onDefaultHandlerClick = noop,\n onAltHandlerClick = noop,\n actions = { defaultAction: 'LOCAL DRIVE', altAction: 'DOCUMENTS' },\n showAltAction = false,\n defaultActionTooltipText,\n altActionTooltipText,\n ...dropzoneProps\n}: DSUploaderPropsT): JSX.Element => {\n const { getRootProps, getInputProps, isDragActive } = useDropzone(dropzoneProps);\n const { onClick: onOpenFile, ...rootProps } = getRootProps();\n const disabledAll = disabledDefault && disabledAlt;\n\n const delfaultActionButton = (\n <ActionButton\n variant={disabledDefault && BUTTON_VARIANT.DISABLED}\n labelText={actions.defaultAction ? (actions.defaultAction as string) : defaultActionLabel}\n onClick={(...args) => {\n if (!disabledDefault) runAll(onDefaultHandlerClick, onOpenFile)(...args);\n }}\n />\n );\n\n const altActionButton = (\n <ActionButton\n variant={disabledAlt && BUTTON_VARIANT.DISABLED}\n labelText={actions.altAction ? (actions.altAction as string) : altActionLabel}\n onClick={(...args) => {\n if (!disabledAlt) onAltHandlerClick(...args);\n }}\n />\n );\n\n const defaultAction = !defaultActionTooltipText ? (\n delfaultActionButton\n ) : (\n <DSTooltip\n containerProps={{ id: 'default-action-tooltip' }}\n interactionType=\"hover\"\n title={defaultActionTooltipText}\n triggerComponent={delfaultActionButton}\n />\n );\n\n const altAction = !altActionTooltipText ? (\n altActionButton\n ) : (\n <DSTooltip\n containerProps={{ id: 'alt-action-tooltip' }}\n interactionType=\"hover\"\n title={altActionTooltipText}\n triggerComponent={altActionButton}\n />\n );\n\n return (\n <UploaderWrapper {...containerProps} classProps={{ disabled: disabledAll }}>\n <Uploader {...rootProps} classProps={{ isDragActive }}>\n <UploaderIconArea>\n <UploadFileIcon size=\"l\" />\n </UploaderIconArea>\n <DividerVertical />\n <UploaderInfo>\n <InfoText>{label}</InfoText>\n <UploaderActions>\n {actions.defaultAction && defaultAction}\n {(actions.altAction || showAltAction) && (\n <>\n {actions.defaultAction && <DividerVertical />}\n {altAction}\n </>\n )}\n </UploaderActions>\n </UploaderInfo>\n {!disabledAll && (\n <UploaderDragActive>\n <DragActiveIcon />\n {dragActiveInstructionalText}\n </UploaderDragActive>\n )}\n {!disabledAll && <input {...getInputProps()} />}\n </Uploader>\n {typeof acceptedTypesText === 'string' && <AcceptedTypes>{acceptedTypesText.toUpperCase()}</AcceptedTypes>}\n </UploaderWrapper>\n );\n};\n\nDSUploader.actions = {\n defaultAction: 'LOCAL DRIVE',\n altAction: 'DOCUMENTS',\n};\n\nDSUploader.propTypes = propTypes;\n\nconst UploaderWithSchema = describe(DSUploader);\nUploaderWithSchema.propTypes = propTypes;\n\nexport { UploaderWithSchema };\nexport default DSUploader;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default, UploaderWithSchema } from './DSUploader';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "react-desc";
|
|
3
|
+
import { UploadFile } from "@elliemae/ds-icons";
|
|
4
|
+
const propTypes = {
|
|
5
|
+
containerProps: PropTypes.object.description("Set of Properties attached to the main container."),
|
|
6
|
+
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."),
|
|
7
|
+
maxFiles: PropTypes.number.description("Number of files accepted."),
|
|
8
|
+
minSize: PropTypes.number.description("Minimun file size accepted in bytes."),
|
|
9
|
+
maxSize: PropTypes.number.description("Maximum file size accepted in bytes."),
|
|
10
|
+
onDropRejected: PropTypes.func.description("Cb called when files are rejected using maxFiles, minSize or maxSize properties."),
|
|
11
|
+
disabled: PropTypes.bool.description("Disables the DSUploader."),
|
|
12
|
+
multiple: PropTypes.bool.description("Set to false to restrict multiple files selection/upload."),
|
|
13
|
+
accept: PropTypes.string.description("String containing the accepted MIME type for the DSUploader"),
|
|
14
|
+
label: PropTypes.string.description("Uploader label.").defaultValue("Browse"),
|
|
15
|
+
icon: PropTypes.element.description("Uploader left icon.").defaultValue(UploadFile),
|
|
16
|
+
actions: PropTypes.shape({
|
|
17
|
+
defaultAction: PropTypes.string,
|
|
18
|
+
altAction: PropTypes.string
|
|
19
|
+
}).description("Uploader actions.").defaultValue({ defaultAction: "LOCAL DRIVE" }),
|
|
20
|
+
defaultActionLabel: PropTypes.string.description("First action button label."),
|
|
21
|
+
showAltAction: PropTypes.bool.description("whether to show alternate action button or not.").defaultValue(true),
|
|
22
|
+
altActionLabel: PropTypes.string.description("Second action button label.").defaultValue("LOCAL DRIVE"),
|
|
23
|
+
dragActiveInstructionalText: PropTypes.string.description("informative text when user drags a file over the uploader zone.").defaultValue("DROP FILES HERE"),
|
|
24
|
+
dragActiveIcon: PropTypes.string.description("Icon when user drags a file over the uploader zone."),
|
|
25
|
+
acceptedTypesText: PropTypes.string.description("Information text to show what types are supported.").defaultValue("JPG, JPEG, PNG, PDF"),
|
|
26
|
+
disabledDefault: PropTypes.bool.description("Whether the default uploader is disabled or not.").defaultValue(false),
|
|
27
|
+
disabledAlt: PropTypes.bool.description("Whether the alternative uploader is disabled or not.").defaultValue(false),
|
|
28
|
+
onDefaultHandlerClick: PropTypes.func.description("First action button click handler."),
|
|
29
|
+
onAltHandlerClick: PropTypes.func.description("Second action button click handler."),
|
|
30
|
+
defaultActionTooltipText: PropTypes.string.description("shows tooltip in default action button."),
|
|
31
|
+
altActionTooltipText: PropTypes.string.description("Shows tooltip in alternate action button.")
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
propTypes
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=propTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/propTypes.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from 'react-desc';\nimport { UploadFile } from '@elliemae/ds-icons';\n/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */\n\nexport const propTypes = {\n containerProps: PropTypes.object.description('Set of Properties attached to the main container.'),\n validator: PropTypes.func.description(\n \"Custom validator. It must return null if it's valid or an object `{ code: string, message: string }` if it's not.\",\n ),\n maxFiles: PropTypes.number.description('Number of files accepted.'),\n minSize: PropTypes.number.description('Minimun file size accepted in bytes.'),\n maxSize: PropTypes.number.description('Maximum file size accepted in bytes.'),\n onDropRejected: PropTypes.func.description(\n 'Cb called when files are rejected using maxFiles, minSize or maxSize properties.',\n ),\n disabled: PropTypes.bool.description('Disables the DSUploader.'),\n multiple: PropTypes.bool.description('Set to false to restrict multiple files selection/upload.'),\n accept: PropTypes.string.description('String containing the accepted MIME type for the DSUploader'),\n\n label: PropTypes.string.description('Uploader label.').defaultValue('Browse'),\n icon: PropTypes.element.description('Uploader left icon.').defaultValue(UploadFile),\n actions: PropTypes.shape({\n defaultAction: PropTypes.string,\n altAction: PropTypes.string,\n })\n .description('Uploader actions.')\n .defaultValue({ defaultAction: 'LOCAL DRIVE' }),\n defaultActionLabel: PropTypes.string.description('First action button label.'),\n showAltAction: PropTypes.bool.description('whether to show alternate action button or not.').defaultValue(true),\n altActionLabel: PropTypes.string.description('Second action button label.').defaultValue('LOCAL DRIVE'),\n dragActiveInstructionalText: PropTypes.string\n .description('informative text when user drags a file over the uploader zone.')\n .defaultValue('DROP FILES HERE'),\n dragActiveIcon: PropTypes.string.description('Icon when user drags a file over the uploader zone.'),\n acceptedTypesText: PropTypes.string\n .description('Information text to show what types are supported.')\n .defaultValue('JPG, JPEG, PNG, PDF'),\n disabledDefault: PropTypes.bool.description('Whether the default uploader is disabled or not.').defaultValue(false),\n disabledAlt: PropTypes.bool.description('Whether the alternative uploader is disabled or not.').defaultValue(false),\n onDefaultHandlerClick: PropTypes.func.description('First action button click handler.'),\n onAltHandlerClick: PropTypes.func.description('Second action button click handler.'),\n defaultActionTooltipText: PropTypes.string.description('shows tooltip in default action button.'),\n altActionTooltipText: PropTypes.string.description('Shows tooltip in alternate action button.'),\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAGO,MAAM,YAAY;AAAA,EACvB,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAC7C,WAAW,UAAU,KAAK,YACxB;AAAA,EAEF,UAAU,UAAU,OAAO,YAAY;AAAA,EACvC,SAAS,UAAU,OAAO,YAAY;AAAA,EACtC,SAAS,UAAU,OAAO,YAAY;AAAA,EACtC,gBAAgB,UAAU,KAAK,YAC7B;AAAA,EAEF,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,UAAU,UAAU,KAAK,YAAY;AAAA,EACrC,QAAQ,UAAU,OAAO,YAAY;AAAA,EAErC,OAAO,UAAU,OAAO,YAAY,mBAAmB,aAAa;AAAA,EACpE,MAAM,UAAU,QAAQ,YAAY,uBAAuB,aAAa;AAAA,EACxE,SAAS,UAAU,MAAM;AAAA,IACvB,eAAe,UAAU;AAAA,IACzB,WAAW,UAAU;AAAA,KAEpB,YAAY,qBACZ,aAAa,EAAE,eAAe;AAAA,EACjC,oBAAoB,UAAU,OAAO,YAAY;AAAA,EACjD,eAAe,UAAU,KAAK,YAAY,mDAAmD,aAAa;AAAA,EAC1G,gBAAgB,UAAU,OAAO,YAAY,+BAA+B,aAAa;AAAA,EACzF,6BAA6B,UAAU,OACpC,YAAY,mEACZ,aAAa;AAAA,EAChB,gBAAgB,UAAU,OAAO,YAAY;AAAA,EAC7C,mBAAmB,UAAU,OAC1B,YAAY,sDACZ,aAAa;AAAA,EAChB,iBAAiB,UAAU,KAAK,YAAY,oDAAoD,aAAa;AAAA,EAC7G,aAAa,UAAU,KAAK,YAAY,wDAAwD,aAAa;AAAA,EAC7G,uBAAuB,UAAU,KAAK,YAAY;AAAA,EAClD,mBAAmB,UAAU,KAAK,YAAY;AAAA,EAC9C,0BAA0B,UAAU,OAAO,YAAY;AAAA,EACvD,sBAAsB,UAAU,OAAO,YAAY;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-uploader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Uploader",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./propTypes": {
|
|
15
|
-
"import": "./esm/propTypes.js",
|
|
16
|
-
"require": "./cjs/propTypes.js"
|
|
18
|
+
"import": "./dist/esm/propTypes.js",
|
|
19
|
+
"require": "./dist/cjs/propTypes.js"
|
|
17
20
|
},
|
|
18
21
|
"./DSUploader": {
|
|
19
|
-
"import": "./esm/DSUploader.js",
|
|
20
|
-
"require": "./cjs/DSUploader.js"
|
|
22
|
+
"import": "./dist/esm/DSUploader.js",
|
|
23
|
+
"require": "./dist/cjs/DSUploader.js"
|
|
21
24
|
}
|
|
22
25
|
},
|
|
23
26
|
"sideEffects": [
|
|
@@ -29,27 +32,27 @@
|
|
|
29
32
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
30
33
|
},
|
|
31
34
|
"engines": {
|
|
32
|
-
"
|
|
33
|
-
"node": ">=
|
|
35
|
+
"pnpm": ">=6",
|
|
36
|
+
"node": ">=16"
|
|
34
37
|
},
|
|
35
38
|
"author": "ICE MT",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"jestSonar": {
|
|
40
|
+
"sonar56x": true,
|
|
41
|
+
"reportPath": "reports",
|
|
42
|
+
"reportFile": "tests.xml",
|
|
43
|
+
"indent": 4
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {
|
|
43
|
-
"@elliemae/ds-button": "
|
|
44
|
-
"@elliemae/ds-classnames": "
|
|
45
|
-
"@elliemae/ds-icons": "
|
|
46
|
-
"@elliemae/ds-tooltip": "
|
|
47
|
-
"@elliemae/ds-utilities": "
|
|
46
|
+
"@elliemae/ds-button": "3.0.0-alpha.0",
|
|
47
|
+
"@elliemae/ds-classnames": "3.0.0-alpha.0",
|
|
48
|
+
"@elliemae/ds-icons": "3.0.0-alpha.0",
|
|
49
|
+
"@elliemae/ds-tooltip": "3.0.0-alpha.0",
|
|
50
|
+
"@elliemae/ds-utilities": "3.0.0-alpha.0",
|
|
48
51
|
"react-desc": "~4.1.3",
|
|
49
52
|
"react-dropzone": "~10.2.2"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
|
-
"@testing-library/jest-dom": "~5.15.
|
|
55
|
+
"@testing-library/jest-dom": "~5.15.1",
|
|
53
56
|
"@testing-library/react": "~12.1.2"
|
|
54
57
|
},
|
|
55
58
|
"peerDependencies": {
|
|
@@ -59,7 +62,12 @@
|
|
|
59
62
|
},
|
|
60
63
|
"publishConfig": {
|
|
61
64
|
"access": "public",
|
|
62
|
-
"
|
|
63
|
-
|
|
65
|
+
"typeSafety": false
|
|
66
|
+
},
|
|
67
|
+
"scripts": {
|
|
68
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
69
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
70
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
71
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
64
72
|
}
|
|
65
73
|
}
|
package/cjs/DSUploader.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
6
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
14
|
-
require('react');
|
|
15
|
-
var reactDesc = require('react-desc');
|
|
16
|
-
var dsClassnames = require('@elliemae/ds-classnames');
|
|
17
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
18
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
19
|
-
var DSButton = require('@elliemae/ds-button');
|
|
20
|
-
var reactDropzone = require('react-dropzone');
|
|
21
|
-
var DSTooltip = require('@elliemae/ds-tooltip');
|
|
22
|
-
var propTypes = require('./propTypes.js');
|
|
23
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
24
|
-
|
|
25
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
-
|
|
27
|
-
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
|
28
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
29
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
30
|
-
var DSButton__default = /*#__PURE__*/_interopDefaultLegacy(DSButton);
|
|
31
|
-
var DSTooltip__default = /*#__PURE__*/_interopDefaultLegacy(DSTooltip);
|
|
32
|
-
|
|
33
|
-
var _DividerVertical, _DividerVertical2;
|
|
34
|
-
|
|
35
|
-
const _excluded = ["labelText"],
|
|
36
|
-
_excluded2 = ["containerProps", "label", "icon", "defaultActionLabel", "dragActiveInstructionalText", "dragActiveIcon", "altActionLabel", "acceptedTypesText", "disabledDefault", "disabledAlt", "onDefaultHandlerClick", "onAltHandlerClick", "actions", "showAltAction", "defaultActionTooltipText", "altActionTooltipText"],
|
|
37
|
-
_excluded3 = ["onClick"];
|
|
38
|
-
|
|
39
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
40
|
-
|
|
41
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
42
|
-
const blockName = 'uploader';
|
|
43
|
-
const blockNameInfo = "".concat(blockName, "-info");
|
|
44
|
-
const blockNameDragActive = "".concat(blockName, "-drag-active");
|
|
45
|
-
const blockNameWrapper = "".concat(blockName, "-wrapper");
|
|
46
|
-
const UploaderWrapper = dsClassnames.aggregatedClasses('div')(blockNameWrapper, null, _ref => {
|
|
47
|
-
let {
|
|
48
|
-
disabled
|
|
49
|
-
} = _ref;
|
|
50
|
-
return {
|
|
51
|
-
disabled
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
const Uploader = dsClassnames.aggregatedClasses('div')(blockName, null, _ref2 => {
|
|
55
|
-
let {
|
|
56
|
-
isDragActive
|
|
57
|
-
} = _ref2;
|
|
58
|
-
return {
|
|
59
|
-
'drag-active': isDragActive
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
const UploaderDragActive = dsClassnames.aggregatedClasses('div')(blockNameDragActive);
|
|
63
|
-
const UploaderIconArea = dsClassnames.aggregatedClasses('div')("".concat(blockName, "-icon-wrapper"));
|
|
64
|
-
const UploaderInfo = dsClassnames.aggregatedClasses('div')(blockNameInfo);
|
|
65
|
-
const InfoText = dsClassnames.aggregatedClasses('span')(blockNameInfo, 'text');
|
|
66
|
-
const UploaderActions = dsClassnames.aggregatedClasses('div')(blockNameInfo, 'actions');
|
|
67
|
-
const AcceptedTypes = dsClassnames.aggregatedClasses('div')(blockNameWrapper, 'accepted-types');
|
|
68
|
-
const DividerVertical = dsClassnames.aggregatedClasses('div')('divider', null, _ref3 => {
|
|
69
|
-
let {
|
|
70
|
-
vertical
|
|
71
|
-
} = _ref3;
|
|
72
|
-
return {
|
|
73
|
-
vertical
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
function ActionButton(_ref4) {
|
|
78
|
-
let {
|
|
79
|
-
labelText
|
|
80
|
-
} = _ref4,
|
|
81
|
-
otherProps = _objectWithoutProperties__default["default"](_ref4, _excluded);
|
|
82
|
-
|
|
83
|
-
return /*#__PURE__*/jsxRuntime.jsx(DSButton__default["default"], _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
84
|
-
buttonType: "text",
|
|
85
|
-
labelText: labelText
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const noop = () => null;
|
|
90
|
-
|
|
91
|
-
const DSUploader = _ref5 => {
|
|
92
|
-
let {
|
|
93
|
-
containerProps = {},
|
|
94
|
-
label = 'Browse',
|
|
95
|
-
// todo: i18n
|
|
96
|
-
icon: UploadFileIcon = dsIcons.UploadFile,
|
|
97
|
-
defaultActionLabel = 'LOCAL DRIVE',
|
|
98
|
-
// todo: i18n
|
|
99
|
-
dragActiveInstructionalText = 'DROP FILES HERE',
|
|
100
|
-
dragActiveIcon: DragActiveIcon = dsIcons.UploadFile,
|
|
101
|
-
altActionLabel = 'DOCUMENTS',
|
|
102
|
-
// todo: i18n
|
|
103
|
-
acceptedTypesText = 'JPG, JPEG, PNG, PDF',
|
|
104
|
-
disabledDefault = false,
|
|
105
|
-
disabledAlt = false,
|
|
106
|
-
onDefaultHandlerClick = noop,
|
|
107
|
-
onAltHandlerClick = noop,
|
|
108
|
-
actions = {
|
|
109
|
-
defaultAction: 'LOCAL DRIVE',
|
|
110
|
-
altAction: 'DOCUMENTS'
|
|
111
|
-
},
|
|
112
|
-
showAltAction = false,
|
|
113
|
-
defaultActionTooltipText,
|
|
114
|
-
altActionTooltipText
|
|
115
|
-
} = _ref5,
|
|
116
|
-
dropzoneProps = _objectWithoutProperties__default["default"](_ref5, _excluded2);
|
|
117
|
-
|
|
118
|
-
const {
|
|
119
|
-
getRootProps,
|
|
120
|
-
getInputProps,
|
|
121
|
-
isDragActive
|
|
122
|
-
} = reactDropzone.useDropzone(dropzoneProps);
|
|
123
|
-
|
|
124
|
-
const _getRootProps = getRootProps(),
|
|
125
|
-
{
|
|
126
|
-
onClick: onOpenFile
|
|
127
|
-
} = _getRootProps,
|
|
128
|
-
rootProps = _objectWithoutProperties__default["default"](_getRootProps, _excluded3);
|
|
129
|
-
|
|
130
|
-
const disabledAll = disabledDefault && disabledAlt;
|
|
131
|
-
|
|
132
|
-
const delfaultActionButton = /*#__PURE__*/_jsx2__default["default"](ActionButton, {
|
|
133
|
-
variant: disabledDefault && DSButton.BUTTON_VARIANT.DISABLED,
|
|
134
|
-
labelText: actions.defaultAction ? actions.defaultAction : defaultActionLabel,
|
|
135
|
-
onClick: function () {
|
|
136
|
-
if (!disabledDefault) dsUtilities.runAll(onDefaultHandlerClick, onOpenFile)(...arguments);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
const altActionButton = /*#__PURE__*/_jsx2__default["default"](ActionButton, {
|
|
141
|
-
variant: disabledAlt && DSButton.BUTTON_VARIANT.DISABLED,
|
|
142
|
-
labelText: actions.altAction ? actions.altAction : altActionLabel,
|
|
143
|
-
onClick: function () {
|
|
144
|
-
if (!disabledAlt) onAltHandlerClick(...arguments);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /*#__PURE__*/_jsx2__default["default"](DSTooltip__default["default"], {
|
|
149
|
-
containerProps: {
|
|
150
|
-
id: 'default-action-tooltip'
|
|
151
|
-
},
|
|
152
|
-
interactionType: "hover",
|
|
153
|
-
title: defaultActionTooltipText,
|
|
154
|
-
triggerComponent: delfaultActionButton
|
|
155
|
-
});
|
|
156
|
-
const altAction = !altActionTooltipText ? altActionButton : /*#__PURE__*/_jsx2__default["default"](DSTooltip__default["default"], {
|
|
157
|
-
containerProps: {
|
|
158
|
-
id: 'alt-action-tooltip'
|
|
159
|
-
},
|
|
160
|
-
interactionType: "hover",
|
|
161
|
-
title: altActionTooltipText,
|
|
162
|
-
triggerComponent: altActionButton
|
|
163
|
-
});
|
|
164
|
-
return /*#__PURE__*/jsxRuntime.jsxs(UploaderWrapper, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
165
|
-
classProps: {
|
|
166
|
-
disabled: disabledAll
|
|
167
|
-
},
|
|
168
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs(Uploader, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
169
|
-
classProps: {
|
|
170
|
-
isDragActive
|
|
171
|
-
},
|
|
172
|
-
children: [/*#__PURE__*/_jsx2__default["default"](UploaderIconArea, {}, void 0, /*#__PURE__*/_jsx2__default["default"](UploadFileIcon, {
|
|
173
|
-
size: "l"
|
|
174
|
-
})), _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, {
|
|
175
|
-
children: [actions.defaultAction && (_DividerVertical2 || (_DividerVertical2 = /*#__PURE__*/_jsx2__default["default"](DividerVertical, {}))), altAction]
|
|
176
|
-
}))), !disabledAll && /*#__PURE__*/_jsx2__default["default"](UploaderDragActive, {}, void 0, /*#__PURE__*/_jsx2__default["default"](DragActiveIcon, {}), dragActiveInstructionalText), !disabledAll && /*#__PURE__*/jsxRuntime.jsx("input", _objectSpread({}, getInputProps()))]
|
|
177
|
-
})), typeof acceptedTypesText === 'string' && /*#__PURE__*/_jsx2__default["default"](AcceptedTypes, {}, void 0, acceptedTypesText.toUpperCase())]
|
|
178
|
-
}));
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
DSUploader.actions = {
|
|
182
|
-
defaultAction: 'LOCAL DRIVE',
|
|
183
|
-
altAction: 'DOCUMENTS'
|
|
184
|
-
};
|
|
185
|
-
const UploaderWithSchema = reactDesc.describe(DSUploader);
|
|
186
|
-
UploaderWithSchema.propTypes = propTypes.propTypes;
|
|
187
|
-
|
|
188
|
-
exports.UploaderWithSchema = UploaderWithSchema;
|
|
189
|
-
exports["default"] = DSUploader;
|
package/cjs/index.d.js
DELETED
package/cjs/index.js
DELETED
package/cjs/propTypes.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
var dsIcons = require('@elliemae/ds-icons');
|
|
7
|
-
|
|
8
|
-
/** Inherits the props of react-dropzone https://react-dropzone.netlify.com/ */
|
|
9
|
-
|
|
10
|
-
const propTypes = {
|
|
11
|
-
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container.'),
|
|
12
|
-
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."),
|
|
13
|
-
maxFiles: reactDesc.PropTypes.number.description('Number of files accepted.'),
|
|
14
|
-
minSize: reactDesc.PropTypes.number.description('Minimun file size accepted in bytes.'),
|
|
15
|
-
maxSize: reactDesc.PropTypes.number.description('Maximum file size accepted in bytes.'),
|
|
16
|
-
onDropRejected: reactDesc.PropTypes.func.description('Cb called when files are rejected using maxFiles, minSize or maxSize properties.'),
|
|
17
|
-
disabled: reactDesc.PropTypes.bool.description('Disables the DSUploader.'),
|
|
18
|
-
multiple: reactDesc.PropTypes.bool.description('Set to false to restrict multiple files selection/upload.'),
|
|
19
|
-
accept: reactDesc.PropTypes.string.description('String containing the accepted MIME type for the DSUploader'),
|
|
20
|
-
label: reactDesc.PropTypes.string.description('Uploader label.').defaultValue('Browse'),
|
|
21
|
-
icon: reactDesc.PropTypes.element.description('Uploader left icon.').defaultValue(dsIcons.UploadFile),
|
|
22
|
-
actions: reactDesc.PropTypes.shape({
|
|
23
|
-
defaultAction: reactDesc.PropTypes.string,
|
|
24
|
-
altAction: reactDesc.PropTypes.string
|
|
25
|
-
}).description('Uploader actions.').defaultValue({
|
|
26
|
-
defaultAction: 'LOCAL DRIVE'
|
|
27
|
-
}),
|
|
28
|
-
defaultActionLabel: reactDesc.PropTypes.string.description('First action button label.'),
|
|
29
|
-
showAltAction: reactDesc.PropTypes.bool.description('whether to show alternate action button or not.').defaultValue(true),
|
|
30
|
-
altActionLabel: reactDesc.PropTypes.string.description('Second action button label.').defaultValue('LOCAL DRIVE'),
|
|
31
|
-
dragActiveInstructionalText: reactDesc.PropTypes.string.description('informative text when user drags a file over the uploader zone.').defaultValue('DROP FILES HERE'),
|
|
32
|
-
dragActiveIcon: reactDesc.PropTypes.string.description('Icon when user drags a file over the uploader zone.'),
|
|
33
|
-
acceptedTypesText: reactDesc.PropTypes.string.description('Information text to show what types are supported.').defaultValue('JPG, JPEG, PNG, PDF'),
|
|
34
|
-
disabledDefault: reactDesc.PropTypes.bool.description('Whether the default uploader is disabled or not.').defaultValue(false),
|
|
35
|
-
disabledAlt: reactDesc.PropTypes.bool.description('Whether the alternative uploader is disabled or not.').defaultValue(false),
|
|
36
|
-
onDefaultHandlerClick: reactDesc.PropTypes.func.description('First action button click handler.'),
|
|
37
|
-
onAltHandlerClick: reactDesc.PropTypes.func.description('Second action button click handler.'),
|
|
38
|
-
defaultActionTooltipText: reactDesc.PropTypes.string.description('shows tooltip in default action button.'),
|
|
39
|
-
altActionTooltipText: reactDesc.PropTypes.string.description('Shows tooltip in alternate action button.')
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.propTypes = propTypes;
|
package/esm/DSUploader.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _jsx2 from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
10
|
-
import 'react';
|
|
11
|
-
import { describe } from 'react-desc';
|
|
12
|
-
import { aggregatedClasses } from '@elliemae/ds-classnames';
|
|
13
|
-
import { runAll } from '@elliemae/ds-utilities';
|
|
14
|
-
import { UploadFile } from '@elliemae/ds-icons';
|
|
15
|
-
import DSButton, { BUTTON_VARIANT } from '@elliemae/ds-button';
|
|
16
|
-
import { useDropzone } from 'react-dropzone';
|
|
17
|
-
import DSTooltip from '@elliemae/ds-tooltip';
|
|
18
|
-
import { propTypes } from './propTypes.js';
|
|
19
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
20
|
-
|
|
21
|
-
var _DividerVertical, _DividerVertical2;
|
|
22
|
-
|
|
23
|
-
const _excluded = ["labelText"],
|
|
24
|
-
_excluded2 = ["containerProps", "label", "icon", "defaultActionLabel", "dragActiveInstructionalText", "dragActiveIcon", "altActionLabel", "acceptedTypesText", "disabledDefault", "disabledAlt", "onDefaultHandlerClick", "onAltHandlerClick", "actions", "showAltAction", "defaultActionTooltipText", "altActionTooltipText"],
|
|
25
|
-
_excluded3 = ["onClick"];
|
|
26
|
-
|
|
27
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
28
|
-
|
|
29
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
|
-
const blockName = 'uploader';
|
|
31
|
-
const blockNameInfo = "".concat(blockName, "-info");
|
|
32
|
-
const blockNameDragActive = "".concat(blockName, "-drag-active");
|
|
33
|
-
const blockNameWrapper = "".concat(blockName, "-wrapper");
|
|
34
|
-
const UploaderWrapper = aggregatedClasses('div')(blockNameWrapper, null, _ref => {
|
|
35
|
-
let {
|
|
36
|
-
disabled
|
|
37
|
-
} = _ref;
|
|
38
|
-
return {
|
|
39
|
-
disabled
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
const Uploader = aggregatedClasses('div')(blockName, null, _ref2 => {
|
|
43
|
-
let {
|
|
44
|
-
isDragActive
|
|
45
|
-
} = _ref2;
|
|
46
|
-
return {
|
|
47
|
-
'drag-active': isDragActive
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
const UploaderDragActive = aggregatedClasses('div')(blockNameDragActive);
|
|
51
|
-
const UploaderIconArea = aggregatedClasses('div')("".concat(blockName, "-icon-wrapper"));
|
|
52
|
-
const UploaderInfo = aggregatedClasses('div')(blockNameInfo);
|
|
53
|
-
const InfoText = aggregatedClasses('span')(blockNameInfo, 'text');
|
|
54
|
-
const UploaderActions = aggregatedClasses('div')(blockNameInfo, 'actions');
|
|
55
|
-
const AcceptedTypes = aggregatedClasses('div')(blockNameWrapper, 'accepted-types');
|
|
56
|
-
const DividerVertical = aggregatedClasses('div')('divider', null, _ref3 => {
|
|
57
|
-
let {
|
|
58
|
-
vertical
|
|
59
|
-
} = _ref3;
|
|
60
|
-
return {
|
|
61
|
-
vertical
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
function ActionButton(_ref4) {
|
|
66
|
-
let {
|
|
67
|
-
labelText
|
|
68
|
-
} = _ref4,
|
|
69
|
-
otherProps = _objectWithoutProperties(_ref4, _excluded);
|
|
70
|
-
|
|
71
|
-
return /*#__PURE__*/jsx(DSButton, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
72
|
-
buttonType: "text",
|
|
73
|
-
labelText: labelText
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const noop = () => null;
|
|
78
|
-
|
|
79
|
-
const DSUploader = _ref5 => {
|
|
80
|
-
let {
|
|
81
|
-
containerProps = {},
|
|
82
|
-
label = 'Browse',
|
|
83
|
-
// todo: i18n
|
|
84
|
-
icon: UploadFileIcon = UploadFile,
|
|
85
|
-
defaultActionLabel = 'LOCAL DRIVE',
|
|
86
|
-
// todo: i18n
|
|
87
|
-
dragActiveInstructionalText = 'DROP FILES HERE',
|
|
88
|
-
dragActiveIcon: DragActiveIcon = UploadFile,
|
|
89
|
-
altActionLabel = 'DOCUMENTS',
|
|
90
|
-
// todo: i18n
|
|
91
|
-
acceptedTypesText = 'JPG, JPEG, PNG, PDF',
|
|
92
|
-
disabledDefault = false,
|
|
93
|
-
disabledAlt = false,
|
|
94
|
-
onDefaultHandlerClick = noop,
|
|
95
|
-
onAltHandlerClick = noop,
|
|
96
|
-
actions = {
|
|
97
|
-
defaultAction: 'LOCAL DRIVE',
|
|
98
|
-
altAction: 'DOCUMENTS'
|
|
99
|
-
},
|
|
100
|
-
showAltAction = false,
|
|
101
|
-
defaultActionTooltipText,
|
|
102
|
-
altActionTooltipText
|
|
103
|
-
} = _ref5,
|
|
104
|
-
dropzoneProps = _objectWithoutProperties(_ref5, _excluded2);
|
|
105
|
-
|
|
106
|
-
const {
|
|
107
|
-
getRootProps,
|
|
108
|
-
getInputProps,
|
|
109
|
-
isDragActive
|
|
110
|
-
} = useDropzone(dropzoneProps);
|
|
111
|
-
|
|
112
|
-
const _getRootProps = getRootProps(),
|
|
113
|
-
{
|
|
114
|
-
onClick: onOpenFile
|
|
115
|
-
} = _getRootProps,
|
|
116
|
-
rootProps = _objectWithoutProperties(_getRootProps, _excluded3);
|
|
117
|
-
|
|
118
|
-
const disabledAll = disabledDefault && disabledAlt;
|
|
119
|
-
|
|
120
|
-
const delfaultActionButton = /*#__PURE__*/_jsx2(ActionButton, {
|
|
121
|
-
variant: disabledDefault && BUTTON_VARIANT.DISABLED,
|
|
122
|
-
labelText: actions.defaultAction ? actions.defaultAction : defaultActionLabel,
|
|
123
|
-
onClick: function () {
|
|
124
|
-
if (!disabledDefault) runAll(onDefaultHandlerClick, onOpenFile)(...arguments);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const altActionButton = /*#__PURE__*/_jsx2(ActionButton, {
|
|
129
|
-
variant: disabledAlt && BUTTON_VARIANT.DISABLED,
|
|
130
|
-
labelText: actions.altAction ? actions.altAction : altActionLabel,
|
|
131
|
-
onClick: function () {
|
|
132
|
-
if (!disabledAlt) onAltHandlerClick(...arguments);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const defaultAction = !defaultActionTooltipText ? delfaultActionButton : /*#__PURE__*/_jsx2(DSTooltip, {
|
|
137
|
-
containerProps: {
|
|
138
|
-
id: 'default-action-tooltip'
|
|
139
|
-
},
|
|
140
|
-
interactionType: "hover",
|
|
141
|
-
title: defaultActionTooltipText,
|
|
142
|
-
triggerComponent: delfaultActionButton
|
|
143
|
-
});
|
|
144
|
-
const altAction = !altActionTooltipText ? altActionButton : /*#__PURE__*/_jsx2(DSTooltip, {
|
|
145
|
-
containerProps: {
|
|
146
|
-
id: 'alt-action-tooltip'
|
|
147
|
-
},
|
|
148
|
-
interactionType: "hover",
|
|
149
|
-
title: altActionTooltipText,
|
|
150
|
-
triggerComponent: altActionButton
|
|
151
|
-
});
|
|
152
|
-
return /*#__PURE__*/jsxs(UploaderWrapper, _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
153
|
-
classProps: {
|
|
154
|
-
disabled: disabledAll
|
|
155
|
-
},
|
|
156
|
-
children: [/*#__PURE__*/jsxs(Uploader, _objectSpread(_objectSpread({}, rootProps), {}, {
|
|
157
|
-
classProps: {
|
|
158
|
-
isDragActive
|
|
159
|
-
},
|
|
160
|
-
children: [/*#__PURE__*/_jsx2(UploaderIconArea, {}, void 0, /*#__PURE__*/_jsx2(UploadFileIcon, {
|
|
161
|
-
size: "l"
|
|
162
|
-
})), _DividerVertical || (_DividerVertical = /*#__PURE__*/_jsx2(DividerVertical, {})), /*#__PURE__*/_jsx2(UploaderInfo, {}, void 0, /*#__PURE__*/_jsx2(InfoText, {}, void 0, label), /*#__PURE__*/_jsx2(UploaderActions, {}, void 0, actions.defaultAction && defaultAction, (actions.altAction || showAltAction) && /*#__PURE__*/jsxs(Fragment, {
|
|
163
|
-
children: [actions.defaultAction && (_DividerVertical2 || (_DividerVertical2 = /*#__PURE__*/_jsx2(DividerVertical, {}))), altAction]
|
|
164
|
-
}))), !disabledAll && /*#__PURE__*/_jsx2(UploaderDragActive, {}, void 0, /*#__PURE__*/_jsx2(DragActiveIcon, {}), dragActiveInstructionalText), !disabledAll && /*#__PURE__*/jsx("input", _objectSpread({}, getInputProps()))]
|
|
165
|
-
})), typeof acceptedTypesText === 'string' && /*#__PURE__*/_jsx2(AcceptedTypes, {}, void 0, acceptedTypesText.toUpperCase())]
|
|
166
|
-
}));
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
DSUploader.actions = {
|
|
170
|
-
defaultAction: 'LOCAL DRIVE',
|
|
171
|
-
altAction: 'DOCUMENTS'
|
|
172
|
-
};
|
|
173
|
-
const UploaderWithSchema = describe(DSUploader);
|
|
174
|
-
UploaderWithSchema.propTypes = propTypes;
|
|
175
|
-
|
|
176
|
-
export { UploaderWithSchema, DSUploader as default };
|
package/esm/index.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { UploaderWithSchema, default } from './DSUploader.js';
|
package/esm/propTypes.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PropTypes } from 'react-desc';
|
|
2
|
-
import { UploadFile } from '@elliemae/ds-icons';
|
|
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 };
|