@steroidsjs/core 3.0.77 → 3.0.79

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.
@@ -3673,6 +3673,22 @@
3673
3673
  "type": "string",
3674
3674
  "example": "'/api/v1/user/avatar/crop'"
3675
3675
  },
3676
+ {
3677
+ "name": "dropRef",
3678
+ "decorators": [],
3679
+ "description": "Ref для drop area",
3680
+ "required": false,
3681
+ "type": "RefObject",
3682
+ "example": null
3683
+ },
3684
+ {
3685
+ "name": "hasDropArea",
3686
+ "decorators": [],
3687
+ "description": "Использовать drop area",
3688
+ "required": false,
3689
+ "type": "boolean",
3690
+ "example": null
3691
+ },
3676
3692
  {
3677
3693
  "name": "imagesExactSize",
3678
3694
  "decorators": [],
@@ -22009,6 +22025,14 @@
22009
22025
  "type": "boolean",
22010
22026
  "example": null
22011
22027
  },
22028
+ {
22029
+ "name": "dropRef",
22030
+ "decorators": [],
22031
+ "description": "Ref для drop area",
22032
+ "required": false,
22033
+ "type": "RefObject",
22034
+ "example": null
22035
+ },
22012
22036
  {
22013
22037
  "name": "error",
22014
22038
  "decorators": [],
@@ -22033,6 +22057,14 @@
22033
22057
  "type": "string",
22034
22058
  "example": "'list'"
22035
22059
  },
22060
+ {
22061
+ "name": "hasDropArea",
22062
+ "decorators": [],
22063
+ "description": "Использовать drop area",
22064
+ "required": false,
22065
+ "type": "boolean",
22066
+ "example": null
22067
+ },
22036
22068
  {
22037
22069
  "name": "image",
22038
22070
  "decorators": [],
@@ -22276,6 +22308,15 @@
22276
22308
  "example": "true",
22277
22309
  "defaultValue": null
22278
22310
  },
22311
+ {
22312
+ "name": "dropRef",
22313
+ "decorators": [],
22314
+ "description": "Ref для drop area",
22315
+ "required": false,
22316
+ "type": "RefObject",
22317
+ "example": null,
22318
+ "defaultValue": null
22319
+ },
22279
22320
  {
22280
22321
  "name": "errors",
22281
22322
  "decorators": [],
@@ -22303,6 +22344,15 @@
22303
22344
  "example": "'list'",
22304
22345
  "defaultValue": null
22305
22346
  },
22347
+ {
22348
+ "name": "hasDropArea",
22349
+ "decorators": [],
22350
+ "description": "",
22351
+ "required": false,
22352
+ "type": "boolean",
22353
+ "example": null,
22354
+ "defaultValue": null
22355
+ },
22306
22356
  {
22307
22357
  "name": "hint",
22308
22358
  "decorators": [],
@@ -22625,6 +22675,14 @@
22625
22675
  "type": "boolean",
22626
22676
  "example": "true"
22627
22677
  },
22678
+ {
22679
+ "name": "dropRef",
22680
+ "decorators": [],
22681
+ "description": "Ref для drop area",
22682
+ "required": false,
22683
+ "type": "RefObject",
22684
+ "example": null
22685
+ },
22628
22686
  {
22629
22687
  "name": "errors",
22630
22688
  "decorators": [],
@@ -22649,6 +22707,14 @@
22649
22707
  "type": "string",
22650
22708
  "example": "'list'"
22651
22709
  },
22710
+ {
22711
+ "name": "hasDropArea",
22712
+ "decorators": [],
22713
+ "description": "",
22714
+ "required": false,
22715
+ "type": "boolean",
22716
+ "example": null
22717
+ },
22652
22718
  {
22653
22719
  "name": "hint",
22654
22720
  "decorators": [],
@@ -24421,6 +24487,15 @@
24421
24487
  "example": "true",
24422
24488
  "defaultValue": null
24423
24489
  },
24490
+ {
24491
+ "name": "dropRef",
24492
+ "decorators": [],
24493
+ "description": "Ref для drop area",
24494
+ "required": false,
24495
+ "type": "RefObject",
24496
+ "example": null,
24497
+ "defaultValue": null
24498
+ },
24424
24499
  {
24425
24500
  "name": "errors",
24426
24501
  "decorators": [],
@@ -24439,6 +24514,15 @@
24439
24514
  "example": null,
24440
24515
  "defaultValue": null
24441
24516
  },
24517
+ {
24518
+ "name": "hasDropArea",
24519
+ "decorators": [],
24520
+ "description": "Использовать drop area",
24521
+ "required": false,
24522
+ "type": "boolean",
24523
+ "example": null,
24524
+ "defaultValue": null
24525
+ },
24442
24526
  {
24443
24527
  "name": "hint",
24444
24528
  "decorators": [],
@@ -24717,6 +24801,14 @@
24717
24801
  "type": "boolean",
24718
24802
  "example": "true"
24719
24803
  },
24804
+ {
24805
+ "name": "dropRef",
24806
+ "decorators": [],
24807
+ "description": "Ref для drop area",
24808
+ "required": false,
24809
+ "type": "RefObject",
24810
+ "example": null
24811
+ },
24720
24812
  {
24721
24813
  "name": "errors",
24722
24814
  "decorators": [],
@@ -24733,6 +24825,14 @@
24733
24825
  "type": "string",
24734
24826
  "example": null
24735
24827
  },
24828
+ {
24829
+ "name": "hasDropArea",
24830
+ "decorators": [],
24831
+ "description": "Использовать drop area",
24832
+ "required": false,
24833
+ "type": "boolean",
24834
+ "example": null
24835
+ },
24736
24836
  {
24737
24837
  "name": "hint",
24738
24838
  "decorators": [],
@@ -39051,6 +39151,15 @@
39051
39151
  "type": "React.ReactNode | {}",
39052
39152
  "example": "MyCustomView",
39053
39153
  "defaultValue": null
39154
+ },
39155
+ {
39156
+ "name": "viewProps",
39157
+ "decorators": [],
39158
+ "description": "Свойства для view компонента",
39159
+ "required": false,
39160
+ "type": "any",
39161
+ "example": null,
39162
+ "defaultValue": null
39054
39163
  }
39055
39164
  ],
39056
39165
  "methods": [
@@ -39148,6 +39257,14 @@
39148
39257
  "required": false,
39149
39258
  "type": "React.ReactNode | {}",
39150
39259
  "example": "MyCustomView"
39260
+ },
39261
+ {
39262
+ "name": "viewProps",
39263
+ "decorators": [],
39264
+ "description": "Свойства для view компонента",
39265
+ "required": false,
39266
+ "type": "any",
39267
+ "example": null
39151
39268
  }
39152
39269
  ],
39153
39270
  "methods": [
package/en.json CHANGED
@@ -987,6 +987,8 @@
987
987
  "Логическое значение, указывающее, можно ли загрузить еще элементы для списка при скролле.": "",
988
988
  " Ref autocomplete поиска": "",
989
989
  "Нужно ли закрывать выпадающий список после выбора элемента": "",
990
+ "Ref для drop area": "",
991
+ "Использовать drop area": "",
990
992
  "Подключение бесконечного скролла": "",
991
993
  "Флаг определяет необходимо ли передавать query параметры в URL": "",
992
994
  "Дополнительный свойства для view части компонента": "",
@@ -1,15 +1,16 @@
1
+ import { RefObject } from 'react';
1
2
  export interface IFileInput {
2
3
  /**
3
- * Параметры для input элемента
4
- */
4
+ * Параметры для input элемента
5
+ */
5
6
  input?: FormInputType;
6
7
  /**
7
- * Множественный выбор файлов
8
- */
8
+ * Множественный выбор файлов
9
+ */
9
10
  multiple?: boolean;
10
11
  /**
11
- * Позволяет указать uploader
12
- */
12
+ * Позволяет указать uploader
13
+ */
13
14
  uploader?: any;
14
15
  /**
15
16
  * Экшен для отправки на бэкенд
@@ -17,29 +18,37 @@ export interface IFileInput {
17
18
  */
18
19
  backendUrl?: string;
19
20
  /**
20
- * Список mime-типов
21
- */
21
+ * Список mime-типов
22
+ */
22
23
  mimeTypes?: string[];
23
24
  /**
24
- * Использовать только изображения
25
- */
25
+ * Использовать только изображения
26
+ */
26
27
  imagesOnly?: boolean;
27
28
  imagesProcessor?: string;
28
29
  /**
29
- * Точные размеры изображений
30
- */
30
+ * Точные размеры изображений
31
+ */
31
32
  imagesExactSize?: string;
32
33
  /**
33
- * Начальные файлы
34
- */
34
+ * Начальные файлы
35
+ */
35
36
  initialFiles?: any;
36
37
  /**
37
- * Параметры для uploader
38
- */
38
+ * Параметры для uploader
39
+ */
39
40
  uploaderConfig?: {
40
41
  useFormData?: boolean;
41
42
  fileFieldName?: string;
42
43
  } | any;
44
+ /**
45
+ * Ref для drop area
46
+ */
47
+ dropRef?: RefObject<HTMLDivElement>;
48
+ /**
49
+ * Использовать drop area
50
+ */
51
+ hasDropArea?: boolean;
43
52
  }
44
53
  export interface IFileOutput {
45
54
  uploader?: any;
package/hooks/useFile.js CHANGED
@@ -58,7 +58,13 @@ function useFile(props) {
58
58
  http.getAccessToken(); // TODO Run promise..
59
59
  var uploader = (0, useInitial_1["default"])(function () {
60
60
  var _a;
61
- return new fileup_core_1["default"](__assign(__assign({ dropArea: {}, backendUrl: generateBackendUrl(props), uploaderConfig: __assign(__assign({}, props.uploaderConfig), { headers: __assign(__assign({}, (_a = props.uploaderConfig) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: 'Bearer ' + http._accessToken }) }) }, props.uploader), { form: __assign(__assign({}, (props.uploader && props.uploader.form)), { multiple: props.multiple, accept: generateAcceptString(props) }) }));
61
+ return new fileup_core_1["default"](__assign(__assign({ backendUrl: generateBackendUrl(props), uploaderConfig: __assign(__assign({}, props.uploaderConfig), { headers: __assign(__assign({}, (_a = props.uploaderConfig) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: 'Bearer ' + http._accessToken }) }) }, props.uploader), { dropArea: (props === null || props === void 0 ? void 0 : props.hasDropArea)
62
+ ? {
63
+ className: props.uploader.dropArea.className,
64
+ container: props.dropRef.current,
65
+ enable: true
66
+ }
67
+ : {}, form: __assign(__assign({}, (props.uploader && props.uploader.form)), { multiple: props.multiple, accept: generateAcceptString(props) }) }));
62
68
  });
63
69
  /**
64
70
  * Force component update when file status or progress changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.77",
3
+ "version": "3.0.79",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -58,6 +58,7 @@ export interface IFileFieldProps extends IFieldWrapperInputProps, IFileFieldComm
58
58
  * @example true
59
59
  */
60
60
  itemProps?: Record<string, any>;
61
+ hasDropArea?: boolean;
61
62
  [key: string]: any;
62
63
  }
63
64
  export interface IFileFieldItemViewProps extends IFileFieldCommonProps {
@@ -54,7 +54,8 @@ var FilesLayout;
54
54
  var FILE_STATUS_END = 'end';
55
55
  function FileFieldComponent(props) {
56
56
  var components = (0, hooks_1.useComponents)();
57
- var _a = (0, useFile_1["default"])(props), files = _a.files, onBrowse = _a.onBrowse, onRemove = _a.onRemove;
57
+ var dropRef = (0, react_1.useRef)(null);
58
+ var _a = (0, useFile_1["default"])(__assign(__assign({}, props), { dropRef: props.hasDropArea ? dropRef : null })), files = _a.files, onBrowse = _a.onBrowse, onRemove = _a.onRemove, uploader = _a.uploader;
58
59
  var _b = react_1["default"].useState(false), isFilesLoaded = _b[0], setIsFilesLoaded = _b[1];
59
60
  var FileFieldView = props.view || components.ui.getView('form.FileFieldView');
60
61
  var FileFieldItemView = props.itemView || components.ui.getView('form.FileFieldItemView');
@@ -84,6 +85,9 @@ function FileFieldComponent(props) {
84
85
  className: props.className,
85
86
  itemProps: props.itemProps,
86
87
  loadingText: props.loadingText,
88
+ dropRef: dropRef,
89
+ uploader: uploader,
90
+ hasDropArea: props.hasDropArea,
87
91
  items: files.map(function (file) {
88
92
  var data = file.getResultHttpMessage() || {};
89
93
  var item = {
@@ -127,7 +131,7 @@ function FileFieldComponent(props) {
127
131
  }
128
132
  return item;
129
133
  })
130
- }); }, [FileFieldItemView, files, onBrowse, onRemove, props.buttonProps, props.buttonView, props.className, props.disabled, props.filesLayout, props.imagesOnly, props.imagesProcessor, props.input, props.itemProps, props.loadingText, props.multiple, props.showRemove, props.size]);
134
+ }); }, [FileFieldItemView, files, onBrowse, onRemove, props.buttonProps, props.buttonView, props.className, props.disabled, props.filesLayout, props.hasDropArea, props.imagesOnly, props.imagesProcessor, props.input, props.itemProps, props.loadingText, props.multiple, props.showRemove, props.size, uploader]);
131
135
  return (react_1["default"].createElement(FileFieldView, __assign({}, viewProps)));
132
136
  }
133
137
  function FileField(props) {
@@ -146,6 +150,7 @@ FileField.defaultProps = {
146
150
  color: 'basic',
147
151
  outline: true
148
152
  },
149
- multiple: false
153
+ multiple: false,
154
+ hasDropArea: false
150
155
  };
151
156
  exports["default"] = (0, fieldWrapper_1["default"])(enums_1.FieldEnum.FILE_FIELD, FileField);
@@ -54,6 +54,7 @@ function ImageField(props) {
54
54
  var _a;
55
55
  var components = (0, hooks_1.useComponents)();
56
56
  var dispatch = (0, useDispatch_1["default"])();
57
+ var dropRef = (0, react_1.useRef)(null);
57
58
  // Add cropping option
58
59
  var _b = (0, react_1.useState)(null), croppedImage = _b[0], setCroppedImage = _b[1];
59
60
  var modalId = (0, react_1.useMemo)(function () { var _a; return ((_a = props.modalProps) === null || _a === void 0 ? void 0 : _a.modalId) || (0, uniqueId_1["default"])('cropModal'); }, [props.modalProps.modalId]);
@@ -72,7 +73,7 @@ function ImageField(props) {
72
73
  xhr: {
73
74
  responseParser: props.crop ? responseParser : null
74
75
  }
75
- } }, props.uploader) })), files = _c.files, onBrowse = _c.onBrowse, onRemove = _c.onRemove, onAdd = _c.onAdd;
76
+ } }, props.uploader), dropRef: props.hasDropArea ? dropRef : null })), files = _c.files, onBrowse = _c.onBrowse, onRemove = _c.onRemove, onAdd = _c.onAdd, uploader = _c.uploader;
76
77
  var oldCroppedImage = (0, react_use_1.usePrevious)(croppedImage);
77
78
  // Fetch cropped image
78
79
  (0, react_1.useEffect)(function () {
@@ -141,8 +142,11 @@ function ImageField(props) {
141
142
  item: item,
142
143
  onClick: onBrowse,
143
144
  buttonProps: props.buttonProps,
144
- label: props.label
145
- }); }, [item, onBrowse, props.buttonProps, props.label]);
145
+ label: props.label,
146
+ dropRef: dropRef,
147
+ uploader: uploader,
148
+ hasDropArea: props.hasDropArea
149
+ }); }, [item, onBrowse, props.buttonProps, props.hasDropArea, props.label, uploader]);
146
150
  return (React.createElement(ImageFieldView, __assign({}, viewProps)));
147
151
  }
148
152
  ImageField.defaultProps = {
@@ -99,6 +99,10 @@ export interface INavProps {
99
99
  * @example MyCustomView
100
100
  */
101
101
  view?: CustomView;
102
+ /**
103
+ * Свойства для view компонента
104
+ */
105
+ viewProps?: CustomViewProps;
102
106
  /**
103
107
  * Обработчик, который вызывается при смене активного элемента навигации
104
108
  * @param args
package/ui/nav/Nav/Nav.js CHANGED
@@ -110,16 +110,7 @@ function Nav(props) {
110
110
  .filter(function (item) { return item.visible !== false; });
111
111
  }, [activeRouteIds, activeTab, props.items, routerParams, routes]);
112
112
  var items = (0, react_1.useMemo)(function () { return formatItems(); }, [formatItems]);
113
- var viewProps = (0, react_1.useMemo)(function () { return ({
114
- items: items,
115
- onClick: onClick,
116
- disabled: props.disabled,
117
- size: props.size,
118
- icon: props.icon,
119
- className: props.className,
120
- navClassName: props.navClassName,
121
- children: renderContent()
122
- }); }, [items, onClick, props.className, props.disabled, props.icon, props.navClassName, props.size, renderContent]);
113
+ var viewProps = (0, react_1.useMemo)(function () { return (__assign(__assign({}, props.viewProps), { items: items, onClick: onClick, disabled: props.disabled, size: props.size, icon: props.icon, className: props.className, navClassName: props.navClassName, children: renderContent() })); }, [items, onClick, props.className, props.disabled, props.icon, props.navClassName, props.size, props.viewProps, renderContent]);
123
114
  return components.ui.renderView(props.view || defaultViewMap[props.layout], viewProps);
124
115
  }
125
116
  Nav.defaultProps = {