@steroidsjs/core 3.0.0-beta.74 → 3.0.0-beta.75

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/actions/list.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import { IApiMethod } from '../components/ApiComponent';
2
1
  export interface IList {
3
2
  /**
4
3
  * Url, который вернет коллекцию элементов.
5
4
  * @example api/v1/articles
6
5
  */
7
- action?: string | IApiMethod;
6
+ action?: string;
8
7
  /**
9
8
  * Тип HTTP запроса (GET | POST | PUT | DELETE)
10
9
  */
@@ -102,8 +101,7 @@ export declare const LIST_DESTROY = "@list/destroy";
102
101
  export declare const LIST_TOGGLE_ITEM = "@list/toggle_item";
103
102
  export declare const LIST_TOGGLE_ALL = "@list/toggle_all";
104
103
  export declare const LIST_SET_LAYOUT = "@list/set_layout";
105
- export declare const httpFetchHandler: (list: IList, query: any, { api, http }: {
106
- api: any;
104
+ export declare const httpFetchHandler: (list: IList, query: any, { http }: {
107
105
  http: any;
108
106
  }) => any;
109
107
  export declare const localFetchHandler: (list: IList, query: Record<string, unknown>) => {
package/actions/list.js CHANGED
@@ -60,14 +60,7 @@ var createList = function (listId, props) { return ({
60
60
  layoutAttribute: (0, get_1["default"])(props, '_layout.attribute') || null
61
61
  }); };
62
62
  var httpFetchHandler = function (list, query, _a) {
63
- var api = _a.api, http = _a.http;
64
- if (typeof list.action === 'function') {
65
- var params = __assign({}, query);
66
- if (list.scope) {
67
- params.scope = list.scope.join(',');
68
- }
69
- return list.action(api, params).then(function (response) { return response.data; });
70
- }
63
+ var http = _a.http;
71
64
  var url = list.action;
72
65
  if (list.scope) {
73
66
  url
@@ -14,7 +14,7 @@
14
14
  "decorators": [],
15
15
  "description": "Url, который вернет коллекцию элементов.",
16
16
  "required": false,
17
- "type": "string | IApiMethod",
17
+ "type": "string",
18
18
  "example": "api/v1/articles"
19
19
  },
20
20
  {
@@ -214,26 +214,6 @@
214
214
  }
215
215
  ]
216
216
  },
217
- "IApiRest": {
218
- "name": "IApiRest",
219
- "moduleName": "components/ApiComponent",
220
- "title": "",
221
- "description": "",
222
- "tags": {},
223
- "defaultProps": null,
224
- "extends": [],
225
- "properties": []
226
- },
227
- "IApiSendConfig": {
228
- "name": "IApiSendConfig",
229
- "moduleName": "components/ApiComponent",
230
- "title": "",
231
- "description": "",
232
- "tags": {},
233
- "defaultProps": null,
234
- "extends": [],
235
- "properties": []
236
- },
237
217
  "Model": {
238
218
  "name": "Model",
239
219
  "moduleName": "components/MetaComponent",
@@ -761,7 +741,7 @@
761
741
  "decorators": [],
762
742
  "description": "URL для подгрузки новой коллекции данных",
763
743
  "required": false,
764
- "type": "string | IApiMethod",
744
+ "type": "string",
765
745
  "example": "'/api/v1/search'"
766
746
  },
767
747
  {
@@ -1139,7 +1119,7 @@
1139
1119
  "decorators": [],
1140
1120
  "description": "",
1141
1121
  "required": false,
1142
- "type": "string | IApiMethod",
1122
+ "type": "string",
1143
1123
  "example": null
1144
1124
  }
1145
1125
  ]
@@ -1378,7 +1358,7 @@
1378
1358
  "decorators": [],
1379
1359
  "description": "Url, который вернет коллекцию элементов",
1380
1360
  "required": false,
1381
- "type": "string | IApiMethod",
1361
+ "type": "string",
1382
1362
  "example": "api/v1/articles"
1383
1363
  },
1384
1364
  {
@@ -1769,14 +1749,6 @@
1769
1749
  "defaultProps": null,
1770
1750
  "extends": [],
1771
1751
  "properties": [
1772
- {
1773
- "name": "api",
1774
- "decorators": [],
1775
- "description": "",
1776
- "required": false,
1777
- "type": "any",
1778
- "example": null
1779
- },
1780
1752
  {
1781
1753
  "name": "clientStorage",
1782
1754
  "decorators": [],
@@ -5263,6 +5235,57 @@
5263
5235
  }
5264
5236
  ]
5265
5237
  },
5238
+ "IApiRest": {
5239
+ "name": "IApiRest",
5240
+ "moduleName": "ui/crud/Crud/Crud",
5241
+ "title": "",
5242
+ "description": "",
5243
+ "tags": {},
5244
+ "defaultProps": null,
5245
+ "extends": [],
5246
+ "properties": [
5247
+ {
5248
+ "name": "create",
5249
+ "decorators": [],
5250
+ "description": "",
5251
+ "required": false,
5252
+ "type": "any",
5253
+ "example": null
5254
+ },
5255
+ {
5256
+ "name": "delete",
5257
+ "decorators": [],
5258
+ "description": "",
5259
+ "required": false,
5260
+ "type": "any",
5261
+ "example": null
5262
+ },
5263
+ {
5264
+ "name": "index",
5265
+ "decorators": [],
5266
+ "description": "",
5267
+ "required": false,
5268
+ "type": "any",
5269
+ "example": null
5270
+ },
5271
+ {
5272
+ "name": "update",
5273
+ "decorators": [],
5274
+ "description": "",
5275
+ "required": false,
5276
+ "type": "any",
5277
+ "example": null
5278
+ },
5279
+ {
5280
+ "name": "view",
5281
+ "decorators": [],
5282
+ "description": "",
5283
+ "required": false,
5284
+ "type": "any",
5285
+ "example": null
5286
+ }
5287
+ ]
5288
+ },
5266
5289
  "ICrudChildrenProps": {
5267
5290
  "name": "ICrudChildrenProps",
5268
5291
  "moduleName": "ui/crud/Crud/Crud",
@@ -12912,7 +12935,7 @@
12912
12935
  "decorators": [],
12913
12936
  "description": "Url на который будет отправлена форма",
12914
12937
  "required": false,
12915
- "type": "string | IApiMethod",
12938
+ "type": "string",
12916
12939
  "example": "api/v1/handle-form"
12917
12940
  },
12918
12941
  {
@@ -15808,7 +15831,7 @@
15808
15831
  "decorators": [],
15809
15832
  "description": "Свойства для элемента input",
15810
15833
  "required": true,
15811
- "type": "{disabled: boolean, max: string | number, min: string | number, name: string, onChange: {}, placeholder: string, step: string | number, type: string, value: number}",
15834
+ "type": "{disabled: boolean, max: number, min: number, name: string, onChange: {}, placeholder: string, step: string | number, type: string, value: number}",
15812
15835
  "example": null
15813
15836
  },
15814
15837
  {
@@ -17701,7 +17724,7 @@
17701
17724
  "name": "IReCaptchaFieldProps",
17702
17725
  "moduleName": "ui/form/ReCaptchaField/ReCaptchaField",
17703
17726
  "title": "ReCaptchaField",
17704
- "description": "Компонент для использования ReCAPTCHA v3 от Google: https://developers.google.com/recaptcha/docs/v3.\nЧтобы добавить ReCAPTCHA в форму необходимо:\n1) Передать siteKey в ResourceComponent.\n2) Поместить на сайт скрипт от Google с помощью метода экземпляра ResourceComponent\n(скрипт анализирует поведение пользователя).\n3) Разместить ReCaptchaField внутри компонента Form. На событие формы onSubmit отправится запрос в Google для\nполучения токена. Далее этот токен с остальными данными формы отправится на бэкенд.\nСам компонент отображает ссылки на политику конфиденциальности и условия использования сервисов Google.",
17727
+ "description": "Компонент для использования ReCAPTCHA v3 от Google.\nЧтобы добавить ReCAPTCHA в форму необходимо:\n1) Передать siteKey в ResourceComponent.\n2) Поместить на сайт скрипт от Google с помощью метода экземпляра ResourceComponent\n(скрипт анализирует поведение пользователя).\n3) Разместить ReCaptchaField внутри компонента Form. На событие формы onSubmit отправится запрос в Google для\nполучения токена. Далее этот токен с остальными данными формы отправится на бэкенд.\nСам компонент отображает ссылки на политику конфиденциальности и условия использования сервисов Google.",
17705
17728
  "tags": {},
17706
17729
  "defaultProps": null,
17707
17730
  "extends": [
@@ -23467,7 +23490,7 @@
23467
23490
  "decorators": [],
23468
23491
  "description": "Url, который вернет коллекцию элементов",
23469
23492
  "required": false,
23470
- "type": "string | IApiMethod",
23493
+ "type": "string",
23471
23494
  "example": "api/v1/articles"
23472
23495
  },
23473
23496
  {
@@ -23980,7 +24003,7 @@
23980
24003
  "decorators": [],
23981
24004
  "description": "Url, который вернет коллекцию элементов",
23982
24005
  "required": false,
23983
- "type": "string | IApiMethod",
24006
+ "type": "string",
23984
24007
  "example": "api/v1/articles"
23985
24008
  },
23986
24009
  {
@@ -24907,7 +24930,7 @@
24907
24930
  "decorators": [],
24908
24931
  "description": "Url на который будет отправлена форма",
24909
24932
  "required": false,
24910
- "type": "string | IApiMethod",
24933
+ "type": "string",
24911
24934
  "example": "api/v1/handle-form"
24912
24935
  },
24913
24936
  {
@@ -27245,6 +27268,14 @@
27245
27268
  "defaultProps": null,
27246
27269
  "extends": [],
27247
27270
  "properties": [
27271
+ {
27272
+ "name": "alwaysOpened",
27273
+ "decorators": [],
27274
+ "description": " Используется для управления раскрытием всех элементов в дереве",
27275
+ "required": false,
27276
+ "type": "boolean",
27277
+ "example": null
27278
+ },
27248
27279
  {
27249
27280
  "name": "autoOpenLevels",
27250
27281
  "decorators": [],
@@ -27338,6 +27369,14 @@
27338
27369
  "ITreeProps"
27339
27370
  ],
27340
27371
  "properties": [
27372
+ {
27373
+ "name": "alwaysOpened",
27374
+ "decorators": [],
27375
+ "description": " Используется для управления раскрытием всех элементов в дереве",
27376
+ "required": false,
27377
+ "type": "boolean",
27378
+ "example": null
27379
+ },
27341
27380
  {
27342
27381
  "name": "autoOpenLevels",
27343
27382
  "decorators": [],
@@ -27584,14 +27623,6 @@
27584
27623
  }
27585
27624
  },
27586
27625
  "declarations": {
27587
- "IApiMethod": {
27588
- "name": "IApiMethod",
27589
- "decorators": [],
27590
- "description": "",
27591
- "required": true,
27592
- "type": "{}",
27593
- "example": null
27594
- },
27595
27626
  "ListControlPosition": {
27596
27627
  "name": "ListControlPosition",
27597
27628
  "decorators": [],
@@ -27924,15 +27955,6 @@
27924
27955
  }
27925
27956
  ]
27926
27957
  },
27927
- "components/ApiComponent": {
27928
- "name": "default",
27929
- "moduleName": "components/ApiComponent",
27930
- "title": "Http Component",
27931
- "description": "Обертка над Axios для запросов на бекенд. Поддерживает токен авторизации, CSRF и обработку ошибок.",
27932
- "tags": {},
27933
- "properties": [],
27934
- "methods": []
27935
- },
27936
27958
  "components/ClientStorageComponent": {
27937
27959
  "name": "default",
27938
27960
  "moduleName": "components/ClientStorageComponent",
package/en.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "\nКомпонент RadioField представляет собой элемент выбора типа \"radio\". Он позволяет пользователю выбрать один вариант из нескольких предложенных.\n": "\nRadioField component represents a \"radio\" type selection element. It allows the user to choose one option from several presented.\n",
41
41
  "Список с радиокнопками. Используется в формах для выбора одного значения.": "List with radio buttons. Used in forms to select one value.",
42
42
  "\nПоле для проставления рейтинга\n": "\nRating input field\n",
43
- "Компонент для использования ReCAPTCHA v3 от Google: https://developers.google.com/recaptcha/docs/v3.\nЧтобы добавить ReCAPTCHA в форму необходимо:\n1) Передать siteKey в ResourceComponent.\n2) Поместить на сайт скрипт от Google с помощью метода экземпляра ResourceComponent\n(скрипт анализирует поведение пользователя).\n3) Разместить ReCaptchaField внутри компонента Form. На событие формы onSubmit отправится запрос в Google для\nполучения токена. Далее этот токен с остальными данными формы отправится на бэкенд.\nСам компонент отображает ссылки на политику конфиденциальности и условия использования сервисов Google.": "Component for using Google ReCAPTCHA v3: https://developers.google.com/recaptcha/docs/v3.\nTo add ReCAPTCHA to a form:\n1) Pass the siteKey to the ResourceComponent.\n2) Embed the Google script on the site using the ResourceComponent instance method\n(the script analyzes user behavior).\n3) Place ReCaptchaField inside the Form component. On the form's onSubmit event, a request will be sent to Google to\nretrieve a token. Then, this token along with other form data will be sent to the backend.\nThe component also displays links to Google's privacy policy and terms of use.",
43
+ "Компонент для использования ReCAPTCHA v3 от Google.\nЧтобы добавить ReCAPTCHA в форму необходимо:\n1) Передать siteKey в ResourceComponent.\n2) Поместить на сайт скрипт от Google с помощью метода экземпляра ResourceComponent\n(скрипт анализирует поведение пользователя).\n3) Разместить ReCaptchaField внутри компонента Form. На событие формы onSubmit отправится запрос в Google для\nполучения токена. Далее этот токен с остальными данными формы отправится на бэкенд.\nСам компонент отображает ссылки на политику конфиденциальности и условия использования сервисов Google.": "Component for using Google ReCAPTCHA v3\nTo add ReCAPTCHA to a form:\n1) Pass the siteKey to the ResourceComponent.\n2) Embed the Google script on the site using the ResourceComponent instance method\n(the script analyzes user behavior).\n3) Place ReCaptchaField inside the Form component. On the form's onSubmit event, a request will be sent to Google to\nretrieve a token. Then, this token along with other form data will be sent to the backend.\nThe component also displays links to Google's privacy policy and terms of use.",
44
44
  "Компонент с ползунком для выбора числового значения в пределах указанного промежутка": "Slider component for selecting a numerical value within a specified range",
45
45
  "Список с кнопками. Используется для выбора одного значения.": "List with buttons. Used to select one value.",
46
46
  "Поле для ввода нескольких строк текста": "Textarea input field for entering multiple lines of text",
@@ -781,5 +781,6 @@
781
781
  " Список со всеми элементами": " List with all elements",
782
782
  " Элементы меню": " Menu Items",
783
783
  "При указании данного свойства, после нажатия на кнопку и до выполнения действия будет отображено нативное\nокно с текстом подтверждения - `window.confirm('Ваш текст')`.": "When this property is specified, after clicking the button and before performing the action, a native \nwindow with the confirmation text will be displayed - `window.confirm('Your text')`.",
784
- "Контент, который отобразиться, если элемент навигации будет активен": "The content that will be displayed if the navigation element is active"
784
+ "Контент, который отобразиться, если элемент навигации будет активен": "The content that will be displayed if the navigation element is active",
785
+ " Используется для управления раскрытием всех элементов в дереве": " Used to control the expansion of all items in the tree"
785
786
  }
@@ -1,4 +1,3 @@
1
- import { IApiMethod } from '../components/ApiComponent';
2
1
  import Enum from '../base/Enum';
3
2
  export interface IAutoCompleteConfig {
4
3
  /**
@@ -35,7 +34,7 @@ export interface IDataProvider {
35
34
  * URL для подгрузки новой коллекции данных
36
35
  * @example '/api/v1/search'
37
36
  */
38
- action?: string | IApiMethod;
37
+ action?: string;
39
38
  /**
40
39
  * Параметры запроса
41
40
  * @example {pageSize: 3}
@@ -132,10 +132,9 @@ function useDataProvider(config) {
132
132
  return __generator(this, function (_b) {
133
133
  switch (_b.label) {
134
134
  case 0:
135
- searchHandler = dataProvider.onSearch || (typeof dataProvider.action === 'function'
136
- ? function (method, params) { return method(components.api, params).then(function (response) { return response.data; }); }
137
- : function (method, params) { return components.http.send(dataProvider.actionMethod, method, params)
138
- .then(function (response) { return response.data; }); });
135
+ searchHandler = dataProvider.onSearch || (function (method, params) { return components.http
136
+ .send(dataProvider.actionMethod, method, params)
137
+ .then(function (response) { return response.data; }); });
139
138
  result = searchHandler(dataProvider.action, __assign(__assign(__assign({ query: config.query }, (isAuto ? { ids: config.initialSelectedIds } : null)), (((_a = config.initialSelectedIds) === null || _a === void 0 ? void 0 : _a.length) > 0 ? { withIds: config.initialSelectedIds } : null)), config.dataProvider.params));
140
139
  if (!(result && (0, isFunction_1["default"])(result.then))) return [3 /*break*/, 2];
141
140
  setIsLoading(true);
@@ -179,7 +178,7 @@ function useDataProvider(config) {
179
178
  delayTimerRef.current = setTimeout(fetchRemote, autoComplete.delay);
180
179
  }
181
180
  }
182
- }, [autoComplete, components.api, components.http, config.autoFetch,
181
+ }, [autoComplete, components.http, config.autoFetch,
183
182
  config.dataProvider, config.initialSelectedIds, config.query, dataProvider,
184
183
  dataProvider.action, dataProvider.onSearch, prevParams, prevQuery, prevValues, setSourceItems, sourceItems]);
185
184
  return {
@@ -1,6 +1,5 @@
1
1
  import { AxiosError } from 'axios';
2
2
  import { IComponents } from '../providers/ComponentsProvider';
3
- import { IApiMethod } from '../components/ApiComponent';
4
3
  declare global {
5
4
  interface Window {
6
5
  APP_PRELOADED_DATA: any;
@@ -8,7 +7,7 @@ declare global {
8
7
  }
9
8
  export interface IFetchConfig {
10
9
  id?: string | number;
11
- url?: string | IApiMethod;
10
+ url?: string;
12
11
  method?: 'get' | 'post' | string;
13
12
  params?: Record<string, unknown>;
14
13
  onFetch?: (config: IFetchConfig, components: IComponents, addCancelToken: (token: any) => any) => any;
package/hooks/useFetch.js CHANGED
@@ -75,9 +75,6 @@ var defaultFetchHandler = function (config, components, addCancelToken) {
75
75
  var cancelToken = new axios_1["default"].CancelToken(function (cancel) {
76
76
  addCancelToken(cancel);
77
77
  });
78
- if (typeof config.url === 'function') {
79
- return config.url(components.api, config.params, config.options).then(function (result) { return result.data; });
80
- }
81
78
  return components.http
82
79
  .send(config.method, config.url, config.params, __assign(__assign({}, config.options), { cancelToken: cancelToken }))
83
80
  .then(function (result) { return result.data; });
@@ -1,4 +1,3 @@
1
- import { IApiMethod } from '../components/ApiComponent';
2
1
  import { IAddressBarConfig } from '../hooks/useAddressBar';
3
2
  import { IList } from '../actions/list';
4
3
  import { ILayoutNamesProps } from '../ui/list/LayoutNames/LayoutNames';
@@ -41,7 +40,7 @@ export interface IListConfig {
41
40
  * Url, который вернет коллекцию элементов
42
41
  * @example api/v1/articles
43
42
  */
44
- action?: string | IApiMethod;
43
+ action?: string;
45
44
  /**
46
45
  * Тип HTTP запроса (GET | POST | PUT | DELETE)
47
46
  * @example GET
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "3.0.0-beta.74",
3
+ "version": "3.0.0-beta.75",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -8,7 +8,6 @@ declare global {
8
8
  }
9
9
  }
10
10
  export interface IComponents {
11
- api?: any;
12
11
  clientStorage?: any;
13
12
  html?: any;
14
13
  http?: any;
@@ -1,10 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import { ReactNode } from 'react';
3
- import { IApiRest } from '../../../components/ApiComponent';
4
3
  import { IComponents } from '../../../providers/ComponentsProvider';
5
4
  import { IFormProps } from '../../form/Form/Form';
6
5
  import { IGridProps } from '../../list/Grid/Grid';
7
6
  import { IControlItem } from '../../nav/Controls/Controls';
7
+ export interface IApiRest {
8
+ index?: any;
9
+ create?: any;
10
+ update?: any;
11
+ delete?: any;
12
+ view?: any;
13
+ [key: string]: any | undefined;
14
+ }
8
15
  export interface ICrudItem extends Omit<IControlItem, 'visible' | 'confirm' | 'onClick'> {
9
16
  /**
10
17
  * Заголовок
@@ -1,8 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { IGridProps } from '../../list/Grid/Grid';
3
3
  import { IFormProps } from '../../form/Form/Form';
4
- import { ICrudItem } from './Crud';
5
- import { IApiRest } from '../../../components/ApiComponent';
4
+ import { IApiRest, ICrudItem } from './Crud';
6
5
  export interface ICrudContentProps {
7
6
  crudId?: string;
8
7
  queryKey?: string;
@@ -93,18 +93,14 @@ var normalizeItems = function (sourceItems, fromProps) {
93
93
  position: 'right',
94
94
  confirm: function (e, props) { return __('Удалить запись {id}?', { id: props.recordId }); },
95
95
  onClick: function (e, props) { return __awaiter(void 0, void 0, void 0, function () {
96
- var _a;
97
- return __generator(this, function (_b) {
98
- switch (_b.label) {
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
99
98
  case 0:
100
- if (!props.restApi) return [3 /*break*/, 2];
101
- return [4 /*yield*/, props.restApi["delete"](props.components.api, (_a = {}, _a[props.primaryKey] = props.recordId, _a))];
102
- case 1:
103
- _b.sent();
104
- props.goToAction(exports.CRUD_ACTION_INDEX);
105
- return [2 /*return*/];
106
- case 2:
107
- if (!props.restUrl) return [3 /*break*/, 4];
99
+ if (props.restApi) {
100
+ props.goToAction(exports.CRUD_ACTION_INDEX);
101
+ return [2 /*return*/];
102
+ }
103
+ if (!props.restUrl) return [3 /*break*/, 2];
108
104
  return [4 /*yield*/, props.components.http["delete"]("".concat(props.restUrl, "/").concat(props.recordId))
109
105
  .then(function () { return props.goToAction(exports.CRUD_ACTION_INDEX); })["catch"](function (error) {
110
106
  if (props.errorHandler) {
@@ -114,10 +110,10 @@ var normalizeItems = function (sourceItems, fromProps) {
114
110
  throw error;
115
111
  }
116
112
  })];
117
- case 3:
118
- _b.sent();
113
+ case 1:
114
+ _a.sent();
119
115
  return [2 /*return*/];
120
- case 4: throw new Error('Either restApi or restUrl must be set');
116
+ case 2: throw new Error('Either restApi or restUrl must be set');
121
117
  }
122
118
  });
123
119
  }); }
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { IAddressBarConfig } from '../../../hooks/useAddressBar';
3
- import { IApiMethod } from '../../../components/ApiComponent';
4
3
  import { IFieldProps } from '../Field/Field';
5
4
  /**
6
5
  * Form
@@ -27,7 +26,7 @@ export interface IFormProps extends IUiComponent {
27
26
  * Url на который будет отправлена форма
28
27
  * @example api/v1/handle-form
29
28
  */
30
- action?: string | IApiMethod;
29
+ action?: string;
31
30
  /**
32
31
  * Тип HTTP запроса (GET | POST | PUT | DELETE)
33
32
  * @example POST
@@ -157,11 +157,11 @@ function Form(props) {
157
157
  var onSubmit = (0, react_1.useCallback)(function (e) {
158
158
  if (e === void 0) { e = null; }
159
159
  return __awaiter(_this, void 0, void 0, function () {
160
- var cleanedValues, submitResult, captchaAttribute, googleCaptcha, captchaToken, options, response, _a, requestError_1, data;
161
- var _b;
160
+ var cleanedValues, submitResult, captchaAttribute, googleCaptcha, captchaToken, options, response, requestError_1, data;
161
+ var _a;
162
162
  var _this = this;
163
- return __generator(this, function (_c) {
164
- switch (_c.label) {
163
+ return __generator(this, function (_b) {
164
+ switch (_b.label) {
165
165
  case 0:
166
166
  dispatch((0, form_2.formSetSubmitting)(props.formId, true));
167
167
  // TODO
@@ -206,7 +206,7 @@ function Form(props) {
206
206
  if (!props.onSubmit) return [3 /*break*/, 2];
207
207
  return [4 /*yield*/, props.onSubmit.call(null, cleanedValues)];
208
208
  case 1:
209
- submitResult = _c.sent();
209
+ submitResult = _b.sent();
210
210
  dispatch((0, form_2.formSetSubmitting)(props.formId, false));
211
211
  return [2 /*return*/, submitResult];
212
212
  case 2:
@@ -220,16 +220,16 @@ function Form(props) {
220
220
  if (!(captchaAttribute && components.resource.googleCaptchaSiteKey)) return [3 /*break*/, 5];
221
221
  return [4 /*yield*/, components.resource.loadGoogleCaptcha()];
222
222
  case 3:
223
- googleCaptcha = _c.sent();
223
+ googleCaptcha = _b.sent();
224
224
  return [4 /*yield*/, getCaptchaToken({
225
225
  googleCaptcha: googleCaptcha,
226
226
  siteKey: components.resource.googleCaptchaSiteKey,
227
227
  actionName: props.captchaActionName
228
228
  })];
229
229
  case 4:
230
- captchaToken = _c.sent();
231
- cleanedValues = __assign(__assign({}, cleanedValues), (_b = {}, _b[captchaAttribute] = captchaToken, _b));
232
- _c.label = 5;
230
+ captchaToken = _b.sent();
231
+ cleanedValues = __assign(__assign({}, cleanedValues), (_a = {}, _a[captchaAttribute] = captchaToken, _a));
232
+ _b.label = 5;
233
233
  case 5:
234
234
  options = {
235
235
  onTwoFactor: props.onTwoFactor
@@ -255,23 +255,15 @@ function Form(props) {
255
255
  }); }
256
256
  : undefined
257
257
  };
258
- _c.label = 6;
258
+ _b.label = 6;
259
259
  case 6:
260
- _c.trys.push([6, 11, , 12]);
261
- if (!(typeof props.action === 'function')) return [3 /*break*/, 8];
262
- return [4 /*yield*/, props.action.call(null, components.api, cleanedValues, options)];
260
+ _b.trys.push([6, 8, , 9]);
261
+ return [4 /*yield*/, components.http.send(props.actionMethod, props.action || window.location.pathname, cleanedValues, options)];
263
262
  case 7:
264
- _a = _c.sent();
265
- return [3 /*break*/, 10];
266
- case 8: return [4 /*yield*/, components.http.send(props.actionMethod, props.action || window.location.pathname, cleanedValues, options)];
267
- case 9:
268
- _a = _c.sent();
269
- _c.label = 10;
270
- case 10:
271
- response = _a;
272
- return [3 /*break*/, 12];
273
- case 11:
274
- requestError_1 = _c.sent();
263
+ response = _b.sent();
264
+ return [3 /*break*/, 9];
265
+ case 8:
266
+ requestError_1 = _b.sent();
275
267
  console.error(requestError_1); // eslint-disable-line no-console
276
268
  dispatch((0, form_2.formSetSubmitting)(props.formId, false));
277
269
  if (typeof props.onError === 'function') {
@@ -281,7 +273,7 @@ function Form(props) {
281
273
  reduxDispatch((0, notifications_1.showNotification)(props.submitErrorMessage || __('Ошибка сервера'), 'danger'));
282
274
  }
283
275
  return [2 /*return*/, null];
284
- case 12:
276
+ case 9:
285
277
  // Skip on 2fa
286
278
  if (response.twoFactor) {
287
279
  dispatch((0, form_2.formSetSubmitting)(props.formId, false));
@@ -314,7 +306,7 @@ function Form(props) {
314
306
  });
315
307
  });
316
308
  }, [dispatch, props, values, components.ui, components.resource,
317
- components.http, components.api, reduxDispatch, setErrors]);
309
+ components.http, reduxDispatch, setErrors]);
318
310
  // Manual submit form by reducer action
319
311
  var prevSubmitCounter = (0, react_use_1.usePrevious)(submitCounter);
320
312
  (0, react_use_1.useUpdateEffect)(function () {
@@ -2,7 +2,7 @@
2
2
  import { IFieldWrapperInputProps, IFieldWrapperOutputProps } from '../Field/fieldWrapper';
3
3
  /**
4
4
  * ReCaptchaField
5
- * Компонент для использования ReCAPTCHA v3 от Google: https://developers.google.com/recaptcha/docs/v3.
5
+ * Компонент для использования ReCAPTCHA v3 от Google.
6
6
  * Чтобы добавить ReCAPTCHA в форму необходимо:
7
7
  * 1) Передать siteKey в ResourceComponent.
8
8
  * 2) Поместить на сайт скрипт от Google с помощью метода экземпляра ResourceComponent
@@ -39,6 +39,7 @@ export interface IListItemViewProps {
39
39
  id?: PrimaryKey;
40
40
  title?: string | any;
41
41
  label?: string | any;
42
+ [key: string]: any;
42
43
  };
43
44
  index: number;
44
45
  className?: CssClassName;
@@ -1,23 +0,0 @@
1
- export interface IApiSendConfig {
2
- method?: HttpMethod;
3
- url?: string;
4
- params?: Record<string, unknown>;
5
- }
6
- export type IApiMethod = (api: any, params?: Record<string, unknown>, options?: Record<string, unknown>) => Promise<any>;
7
- export interface IApiRest {
8
- index?: IApiMethod;
9
- create?: IApiMethod;
10
- update?: IApiMethod;
11
- delete?: IApiMethod;
12
- view?: IApiMethod;
13
- [key: string]: IApiMethod | undefined;
14
- }
15
- /**
16
- * Http Component
17
- * Обертка над Axios для запросов на бекенд. Поддерживает токен авторизации, CSRF и обработку ошибок.
18
- */
19
- export default class ApiComponent {
20
- _components: any;
21
- constructor(components: any);
22
- send(config: IApiSendConfig): Promise<any>;
23
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- exports.__esModule = true;
50
- /**
51
- * Http Component
52
- * Обертка над Axios для запросов на бекенд. Поддерживает токен авторизации, CSRF и обработку ошибок.
53
- */
54
- var ApiComponent = /** @class */ (function () {
55
- function ApiComponent(components) {
56
- this._components = components;
57
- }
58
- ApiComponent.prototype.send = function (config) {
59
- return __awaiter(this, void 0, void 0, function () {
60
- var method, params, url;
61
- return __generator(this, function (_a) {
62
- method = config.method || 'get';
63
- params = __assign({}, config.params);
64
- url = config.url.replace(/{([0-9a-z_]+)}/ig, function (str, key) {
65
- var value = params[key];
66
- delete params[key];
67
- return value;
68
- });
69
- return [2 /*return*/, this._components.http.send(method, url, params)];
70
- });
71
- });
72
- };
73
- return ApiComponent;
74
- }());
75
- exports["default"] = ApiComponent;