@lyra/form-builder
Version:
Lyra form builder
50 lines (35 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _uploadImage = require('./uploadImage');
var _uploadImage2 = _interopRequireDefault(_uploadImage);
var _uploadFile = require('./uploadFile');
var _uploadFile2 = _interopRequireDefault(_uploadFile);
var _patches = require('../../utils/patches');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*:: import type {Uploader, UploaderDef} from './typedefs'*/
/*:: import type {Type, UploadOptions} from '../../typedefs'*/
const UPLOAD_IMAGE /*: UploaderDef*/ = {
type: 'image',
accepts: 'image/*',
upload: (file /*: File*/, type /*: Type*/, options /*: UploadOptions*/) => (0, _uploadImage2.default)(file, options)
};
const UPLOAD_FILE /*: UploaderDef*/ = {
type: 'file',
accepts: '',
upload: (file /*: File*/, type /*: Type*/, options /*: UploadOptions*/) => (0, _uploadFile2.default)(file, options)
};
const UPLOAD_TEXT /*: UploaderDef*/ = {
type: 'string',
accepts: 'text/*',
upload: (file /*: File*/, type /*: Type*/, options /*: UploadOptions*/) => (0, _uploadFile2.default)(file, options).map(content => ({
patches: [(0, _patches.set)(content)]
}))
// Todo: promote this to a "first-class" form-builder abstraction
// and make it possible to register custom uploaders
};const uploaders /*: Array<Uploader>*/ = [UPLOAD_IMAGE, UPLOAD_TEXT, UPLOAD_FILE].map((uploader, i) => _extends({}, uploader, {
priority: i
}));
exports.default = uploaders;