ywana-core8 0.0.825 → 0.0.826

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.
@@ -7,6 +7,7 @@ import 'moment/locale/es';
7
7
  import ResumableJS from 'resumablejs';
8
8
  import { ReactNotifications, Store } from 'react-notifications-component';
9
9
  import 'react-notifications-component/dist/theme.css';
10
+ import axios from 'axios';
10
11
  import equal from 'deep-equal';
11
12
 
12
13
  /**
@@ -3793,7 +3794,7 @@ var UPLOAD_STATES = {
3793
3794
  * Upload File
3794
3795
  */
3795
3796
 
3796
- var UploadFile = function UploadFile(_ref) {
3797
+ var UploadFile$1 = function UploadFile(_ref) {
3797
3798
  var file = _ref.file;
3798
3799
  var icon = file.icon,
3799
3800
  name = file.name,
@@ -3829,7 +3830,7 @@ var UploadProgress = function UploadProgress(_ref) {
3829
3830
  state: file.uploadState,
3830
3831
  error: file.uploadError
3831
3832
  };
3832
- return /*#__PURE__*/React.createElement(UploadFile, {
3833
+ return /*#__PURE__*/React.createElement(UploadFile$1, {
3833
3834
  key: f.name,
3834
3835
  file: f
3835
3836
  });
@@ -5301,6 +5302,145 @@ var TaskInfo = function TaskInfo(props) {
5301
5302
  return editor(task);
5302
5303
  };
5303
5304
 
5305
+ /*
5306
+ * Upload Form
5307
+ */
5308
+
5309
+ var UploadForm = function UploadForm(props) {
5310
+ var _props$label = props.label,
5311
+ label = _props$label === void 0 ? "Browse" : _props$label,
5312
+ _props$text = props.text,
5313
+ text = _props$text === void 0 ? "Drag and drop here" : _props$text,
5314
+ url = props.url,
5315
+ _props$headers = props.headers,
5316
+ headers = _props$headers === void 0 ? {} : _props$headers,
5317
+ onSuccess = props.onSuccess,
5318
+ onError = props.onError;
5319
+
5320
+ var _useState = useState(null),
5321
+ file = _useState[0],
5322
+ setFile = _useState[1];
5323
+
5324
+ var _useState2 = useState(0),
5325
+ progress = _useState2[0],
5326
+ setProgress = _useState2[1];
5327
+
5328
+ useEffect(function () {
5329
+ if (file) {
5330
+ uploadFile(file);
5331
+ }
5332
+ }, [file]);
5333
+
5334
+ function onDragOver(e) {
5335
+ e.stopPropagation();
5336
+ e.preventDefault();
5337
+ }
5338
+
5339
+ function onDragEnter(e) {
5340
+ e.preventDefault();
5341
+ e.stopPropagation();
5342
+
5343
+ if (e.type === "dragenter" || e.type === "dragover") {
5344
+ console.log("dragenter");
5345
+ } else if (e.type === "dragleave") {
5346
+ console.log("dragleave");
5347
+ }
5348
+ }
5349
+
5350
+ function onFileDrop(e) {
5351
+ e.preventDefault();
5352
+ e.stopPropagation();
5353
+
5354
+ if (e.dataTransfer.files && e.dataTransfer.files[0]) {
5355
+ var files = e.dataTransfer.files;
5356
+ handleFiles(files);
5357
+ }
5358
+ }
5359
+
5360
+ function handleFiles(files) {
5361
+ var file = files[0];
5362
+ console.log("handleFiles", files, file);
5363
+ setFile(file);
5364
+ }
5365
+
5366
+ function handleFile(e) {
5367
+ var file = e.target.files[0];
5368
+ setFile(file);
5369
+ }
5370
+
5371
+ function uploadFile(file) {
5372
+ var formData = new FormData();
5373
+ formData.append('file', file);
5374
+ var config = {
5375
+ onUploadProgress: function onUploadProgress(progressEvent) {
5376
+ setProgress(Math.round(progressEvent.loaded / progressEvent.total * 100));
5377
+ },
5378
+ headers: _extends({
5379
+ 'content-type': 'multipart/form-data'
5380
+ }, headers)
5381
+ };
5382
+ axios.post(url, formData, config).then(function (response) {
5383
+ if (onSuccess) onSuccess(response);
5384
+ })["catch"](function (error) {
5385
+ if (onError) onError(error);
5386
+ });
5387
+ }
5388
+
5389
+ return /*#__PURE__*/React.createElement("div", {
5390
+ className: "upload-form",
5391
+ onDragEnter: onDragEnter,
5392
+ onDragOver: onDragOver,
5393
+ onDrop: onFileDrop
5394
+ }, /*#__PURE__*/React.createElement("div", {
5395
+ className: "upload-area"
5396
+ }, /*#__PURE__*/React.createElement("div", {
5397
+ className: "upload-area-text"
5398
+ }, text), /*#__PURE__*/React.createElement("label", {
5399
+ htmlFor: "upload"
5400
+ }, /*#__PURE__*/React.createElement("span", {
5401
+ className: "upload-label"
5402
+ }, label)), /*#__PURE__*/React.createElement("input", {
5403
+ id: "upload",
5404
+ type: "file",
5405
+ onChange: handleFile
5406
+ })), file ? /*#__PURE__*/React.createElement(UploadFile, {
5407
+ name: file.name,
5408
+ progress: progress
5409
+ }) : null);
5410
+ };
5411
+ /**
5412
+ * Upload File
5413
+ */
5414
+
5415
+ var UploadFile = function UploadFile(props) {
5416
+ var name = props.name,
5417
+ _props$progress = props.progress,
5418
+ progress = _props$progress === void 0 ? 0 : _props$progress;
5419
+ return /*#__PURE__*/React.createElement("div", {
5420
+ className: "upload-file"
5421
+ }, /*#__PURE__*/React.createElement("div", {
5422
+ className: "upload-file-info"
5423
+ }, /*#__PURE__*/React.createElement("label", null, name), /*#__PURE__*/React.createElement("span", null, progress, " %")), /*#__PURE__*/React.createElement(UploadProgressBar, {
5424
+ progress: progress
5425
+ }));
5426
+ };
5427
+ /**
5428
+ * Upload Progress Bar
5429
+ */
5430
+
5431
+
5432
+ var UploadProgressBar = function UploadProgressBar(props) {
5433
+ var progress = props.progress;
5434
+ return /*#__PURE__*/React.createElement("div", {
5435
+ className: "upload-progress-bar"
5436
+ }, /*#__PURE__*/React.createElement("div", {
5437
+ className: "upload-progress-bar-inner",
5438
+ style: {
5439
+ width: progress + "%"
5440
+ }
5441
+ }));
5442
+ };
5443
+
5304
5444
  /**
5305
5445
  * Password Editor
5306
5446
  */
@@ -11558,5 +11698,5 @@ var isFunction = function isFunction(value) {
11558
11698
  return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
11559
11699
  };
11560
11700
 
11561
- export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
11701
+ export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES$1 as TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile$1 as UploadFile, UploadForm, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
11562
11702
  //# sourceMappingURL=index.modern.js.map