@steroidsjs/core 2.2.59 → 2.2.62

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/hoc/file.d.ts CHANGED
@@ -15,7 +15,7 @@ export interface IFileHocInput {
15
15
  uploaderConfig?: {
16
16
  useFormData?: boolean;
17
17
  fileFieldName?: string;
18
- };
18
+ } | any;
19
19
  }
20
20
  export interface IFileHocOutput {
21
21
  uploader?: any;
@@ -1,3 +1,4 @@
1
+ import { AxiosError } from 'axios';
1
2
  import { IComponents } from '../providers/ComponentsProvider';
2
3
  import { IApiMethod } from '../components/ApiComponent';
3
4
  declare global {
@@ -22,6 +23,7 @@ export interface IFetchResult {
22
23
  } | any;
23
24
  isLoading: boolean;
24
25
  fetch?: (newParams?: Record<string, unknown>) => void;
26
+ axiosError: AxiosError | null;
25
27
  }
26
28
  export declare const normalizeConfig: (config: any) => any;
27
29
  export declare const getConfigId: (config: any) => any;
package/hooks/useFetch.js CHANGED
@@ -111,7 +111,8 @@ function useFetch(rawConfig) {
111
111
  var preloadedDataByConfigId = (preloadedData && configId) ? preloadedData[configId] : null;
112
112
  // State for data and loading flag
113
113
  var _b = react_1.useState(preloadedDataByConfigId || null), data = _b[0], setData = _b[1];
114
- var _c = react_1.useState(!!config && !data), isLoading = _c[0], setIsLoading = _c[1];
114
+ var _c = react_1.useState(null), axiosError = _c[0], setAxiosError = _c[1];
115
+ var _d = react_1.useState(!!config && !data), isLoading = _d[0], setIsLoading = _d[1];
115
116
  // Cancel tokens
116
117
  var cancelTokens = react_1.useRef([]);
117
118
  var addCancelToken = function (token) { return cancelTokens.current.push(token); };
@@ -120,7 +121,7 @@ function useFetch(rawConfig) {
120
121
  var fetch = react_1.useCallback(function (newConfig) {
121
122
  if (newConfig === void 0) { newConfig = null; }
122
123
  return __awaiter(_this, void 0, void 0, function () {
123
- var _a;
124
+ var _a, error_1;
124
125
  return __generator(this, function (_b) {
125
126
  switch (_b.label) {
126
127
  case 0:
@@ -128,15 +129,26 @@ function useFetch(rawConfig) {
128
129
  setConfig(__assign(__assign(__assign({}, config), newConfig), { params: __assign(__assign({}, config === null || config === void 0 ? void 0 : config.params), newConfig === null || newConfig === void 0 ? void 0 : newConfig.params) }));
129
130
  }
130
131
  setData(null);
131
- if (!config) return [3 /*break*/, 2];
132
+ if (!config) return [3 /*break*/, 5];
132
133
  setIsLoading(true);
134
+ _b.label = 1;
135
+ case 1:
136
+ _b.trys.push([1, 3, , 4]);
133
137
  _a = setData;
134
138
  return [4 /*yield*/, exports.fetchData(config, components, addCancelToken)];
135
- case 1:
139
+ case 2:
136
140
  _a.apply(void 0, [_b.sent()]);
141
+ return [3 /*break*/, 4];
142
+ case 3:
143
+ error_1 = _b.sent();
144
+ if (error_1.isAxiosError) {
145
+ setAxiosError(error_1);
146
+ }
147
+ return [3 /*break*/, 4];
148
+ case 4:
137
149
  setIsLoading(false);
138
- _b.label = 2;
139
- case 2: return [2 /*return*/];
150
+ _b.label = 5;
151
+ case 5: return [2 /*return*/];
140
152
  }
141
153
  });
142
154
  });
@@ -150,6 +162,6 @@ function useFetch(rawConfig) {
150
162
  react_use_1.useUpdateEffect(function () {
151
163
  fetch();
152
164
  }, [fetch]);
153
- return { data: data, isLoading: isLoading, fetch: fetch };
165
+ return { data: data, isLoading: isLoading, fetch: fetch, axiosError: axiosError };
154
166
  }
155
167
  exports["default"] = useFetch;
package/hooks/useFile.js CHANGED
@@ -39,7 +39,12 @@ function generateBackendUrl(props) {
39
39
  });
40
40
  }
41
41
  function useFile(props) {
42
- var uploader = useInitial_1["default"](function () { return new fileup_core_1["default"](__assign(__assign({ dropArea: {}, backendUrl: generateBackendUrl(props), uploaderConfig: __assign({}, props.uploaderConfig) }, props.uploader), { form: __assign(__assign({}, (props.uploader && props.uploader.form)), { multiple: props.multiple }) })); });
42
+ var http = index_1.useComponents().http;
43
+ http.getAccessToken(); // TODO Run promise..
44
+ var uploader = useInitial_1["default"](function () {
45
+ var _a;
46
+ 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 }) }));
47
+ });
43
48
  /**
44
49
  * Force component update when file status or progress changes
45
50
  * @private
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "2.2.59",
3
+ "version": "2.2.62",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -25,12 +25,16 @@ export interface IModalProps {
25
25
  */
26
26
  controls?: IControlItem[];
27
27
  /**
28
- * Время, через которое произойдет закрытие Modal.
29
- * В этот отрезок времени должны происходить все анимации закрытия компонента.
28
+ * Время, в течение которого будет происходить анимация закрытия Modal.
30
29
  * Переопределяет отрезок времени, заданный в ModalPortal
31
30
  * @example 300
32
31
  */
33
32
  closeTimeoutMs?: number;
33
+ /**
34
+ * Время, через которое автоматически произойдет закрытие Modal.
35
+ * @example 1000
36
+ */
37
+ closeAfterMs?: number;
34
38
  /**
35
39
  * Группа Modal
36
40
  * @example 'modal'
@@ -36,6 +36,11 @@ function Modal(props) {
36
36
  var components = hooks_1.useComponents();
37
37
  var ModalView = props.view || components.ui.getView('modal.ModalView');
38
38
  var ContentComponent = props.component;
39
+ React.useEffect(function () {
40
+ if (props.closeAfterMs) {
41
+ setTimeout(function () { return props.onClose(); }, props.closeAfterMs);
42
+ }
43
+ }, []);
39
44
  return (React.createElement(ModalView, __assign({}, props), (ContentComponent && (React.createElement(ContentComponent, __assign({}, props, props.componentProps)))) || (props.children)));
40
45
  }
41
46
  Modal.defaultProps = {