UNPKG

dash-core-components

Version:

Core component suite for Dash

164 lines (162 loc) 5.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.propTypes = exports.defaultProps = exports.default = void 0; var _propTypes = _interopRequireDefault(require("prop-types")); var _react = _interopRequireWildcard(require("react")); var _upload = _interopRequireDefault(require("../utils/LazyLoader/upload")); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } var RealUpload = /*#__PURE__*/(0, _react.lazy)(_upload.default); /** * Upload components allow your app to accept user-uploaded files via drag'n'drop */ class Upload extends _react.Component { render() { return /*#__PURE__*/_react.default.createElement(_react.Suspense, { fallback: null }, /*#__PURE__*/_react.default.createElement(RealUpload, this.props)); } } exports.default = Upload; Upload.propTypes = { /** * The ID of this component, used to identify dash components * in callbacks. The ID needs to be unique across all of the * components in an app. */ id: _propTypes.default.string, /** * The contents of the uploaded file as a binary string */ contents: _propTypes.default.oneOfType([ /** * If `multiple` is `false`, then the contents will be a string */ _propTypes.default.string, /** * If `multiple` is `true`, then the contents will be a list of strings */ _propTypes.default.arrayOf(_propTypes.default.string)]), /** * The name of the file(s) that was(were) uploaded. * Note that this does not include the path of the file * (for security reasons). */ filename: _propTypes.default.oneOfType([ /** * If `multiple` is `false`, then the contents will be a string */ _propTypes.default.string, /** * If `multiple` is `true`, then the contents will be a list of strings */ _propTypes.default.arrayOf(_propTypes.default.string)]), /** * The last modified date of the file that was uploaded in unix time * (seconds since 1970). */ last_modified: _propTypes.default.oneOfType([ /** * If `multiple` is `false`, then the contents will be a number */ _propTypes.default.number, /** * If `multiple` is `true`, then the contents will be a list of numbers */ _propTypes.default.arrayOf(_propTypes.default.number)]), /** * Contents of the upload component */ children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]), /** * Allow specific types of files. * See https://github.com/okonet/attr-accept for more information. * Keep in mind that mime type determination is not reliable across * platforms. CSV files, for example, are reported as text/plain * under macOS but as application/vnd.ms-excel under Windows. * In some cases there might not be a mime type set at all. * See: https://github.com/react-dropzone/react-dropzone/issues/276 */ accept: _propTypes.default.string, /** * Enable/disable the upload component entirely */ disabled: _propTypes.default.bool, /** * Disallow clicking on the component to open the file dialog */ disable_click: _propTypes.default.bool, /** * Maximum file size in bytes. If `-1`, then infinite */ max_size: _propTypes.default.number, /** * Minimum file size in bytes */ min_size: _propTypes.default.number, /** * Allow dropping multiple files */ multiple: _propTypes.default.bool, /** * HTML class name of the component */ className: _propTypes.default.string, /** * HTML class name of the component while active */ className_active: _propTypes.default.string, /** * HTML class name of the component if rejected */ className_reject: _propTypes.default.string, /** * HTML class name of the component if disabled */ className_disabled: _propTypes.default.string, /** * CSS styles to apply */ style: _propTypes.default.object, /** * CSS styles to apply while active */ style_active: _propTypes.default.object, /** * CSS styles if rejected */ style_reject: _propTypes.default.object, /** * CSS styles if disabled */ style_disabled: _propTypes.default.object, /** * Dash-supplied function for updating props */ setProps: _propTypes.default.func }; Upload.defaultProps = { disabled: false, disable_click: false, max_size: -1, min_size: 0, multiple: false, style: {}, style_active: { borderStyle: 'solid', borderColor: '#6c6', backgroundColor: '#eee' }, style_disabled: { opacity: 0.5 }, style_reject: { borderStyle: 'solid', borderColor: '#c66', backgroundColor: '#eee' } }; var propTypes = exports.propTypes = Upload.propTypes; var defaultProps = exports.defaultProps = Upload.defaultProps;