@steroidsjs/core 3.0.93 → 3.0.96

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.
Files changed (199) hide show
  1. package/actions/auth.js +1 -0
  2. package/actions/list.js +12 -10
  3. package/actions/notifications.d.ts +1 -1
  4. package/actions/notifications.js +5 -3
  5. package/components/ClientStorageComponent.js +1 -1
  6. package/components/HttpComponent.js +3 -3
  7. package/components/JwtHttpComponent.js +2 -2
  8. package/components/LocaleComponent.js +4 -3
  9. package/components/MetricsComponent.js +1 -1
  10. package/components/ResourceComponent.d.ts +2 -0
  11. package/components/ResourceComponent.js +9 -3
  12. package/components/SocialComponent.js +3 -1
  13. package/components/StoreComponent.d.ts +33 -21
  14. package/components/StoreComponent.js +5 -10
  15. package/components/UiComponent.js +1 -1
  16. package/components/social/GitlabProvider.js +3 -1
  17. package/docs-autogen-result.json +83 -41
  18. package/en.json +7 -1
  19. package/hooks/index.d.ts +5 -5
  20. package/hooks/index.js +10 -10
  21. package/hooks/useAddressBar.js +13 -9
  22. package/hooks/useApplication.d.ts +9 -9
  23. package/hooks/useApplication.js +17 -15
  24. package/hooks/useDataProvider.js +13 -7
  25. package/hooks/useDataSelect.js +4 -4
  26. package/hooks/useFetch.d.ts +6 -7
  27. package/hooks/useFetch.js +2 -2
  28. package/hooks/useFile.js +12 -7
  29. package/hooks/useLayout.js +25 -23
  30. package/hooks/useList.d.ts +4 -4
  31. package/hooks/useList.js +28 -22
  32. package/hooks/useListField.js +1 -1
  33. package/hooks/useSaveCursorPosition.js +1 -1
  34. package/hooks/useTree.d.ts +1 -1
  35. package/hooks/useTree.js +7 -6
  36. package/hooks/useUniqueId.js +1 -1
  37. package/index.d.ts +49 -0
  38. package/package.json +4 -4
  39. package/providers/ComponentsProvider.d.ts +5 -5
  40. package/providers/SsrProvider.js +7 -6
  41. package/providers/index.d.ts +1 -1
  42. package/providers/index.js +2 -2
  43. package/reducers/auth.js +1 -0
  44. package/reducers/fields.js +2 -1
  45. package/reducers/form.js +4 -3
  46. package/reducers/index.d.ts +1 -1
  47. package/reducers/index.js +2 -2
  48. package/reducers/list.js +3 -2
  49. package/reducers/modal.js +2 -1
  50. package/reducers/notifications.js +2 -1
  51. package/reducers/router.js +13 -7
  52. package/ui/content/Accordion/index.d.ts +1 -1
  53. package/ui/content/Accordion/index.js +2 -2
  54. package/ui/content/Alert/Alert.d.ts +1 -1
  55. package/ui/content/Badge/Badge.d.ts +1 -1
  56. package/ui/content/Calendar/Calendar.js +2 -2
  57. package/ui/content/CalendarSystem/CalendarSystem.d.ts +2 -2
  58. package/ui/content/CalendarSystem/CalendarSystem.js +2 -2
  59. package/ui/content/CalendarSystem/hooks/useCalendarControls.js +5 -3
  60. package/ui/content/CalendarSystem/hooks/useCalendarSystem.js +11 -11
  61. package/ui/content/CalendarSystem/hooks/useCalendarSystemEventGroupModals.d.ts +1 -1
  62. package/ui/content/CalendarSystem/hooks/useCalendarSystemEventGroupModals.js +2 -2
  63. package/ui/content/CalendarSystem/hooks/useCalendarSystemModals.js +6 -4
  64. package/ui/content/CalendarSystem/hooks/useDisplayDate.js +1 -1
  65. package/ui/content/CalendarSystem/hooks/useEventsFromDate.js +1 -1
  66. package/ui/content/CalendarSystem/utils/utils.js +6 -4
  67. package/ui/content/Card/Card.d.ts +1 -1
  68. package/ui/content/Chat/Chat.d.ts +1 -1
  69. package/ui/content/Chat/Chat.js +1 -1
  70. package/ui/content/Chat/hooks/useChat.js +5 -5
  71. package/ui/content/Chat/utils/addNewMessageIntoGroupedMessages.js +1 -1
  72. package/ui/content/Chat/utils/calculateMessageTimeAgo.js +6 -2
  73. package/ui/content/Chat/utils/getMessagesGroupedByDate.d.ts +1 -1
  74. package/ui/content/Chat/utils/getMessagesGroupedByDate.js +1 -1
  75. package/ui/content/Chat/utils/index.d.ts +1 -1
  76. package/ui/content/Chat/utils/index.js +3 -3
  77. package/ui/content/CopyToClipboard/CopyToClipboard.js +1 -1
  78. package/ui/content/Dashboard/Dashboard.js +1 -1
  79. package/ui/content/Detail/Detail.js +5 -3
  80. package/ui/content/DropDown/DropDown.js +1 -1
  81. package/ui/content/Kanban/Kanban.d.ts +3 -3
  82. package/ui/content/Kanban/Kanban.js +4 -4
  83. package/ui/content/Kanban/enums/KanbanPrioritiesEnum.d.ts +1 -1
  84. package/ui/content/Kanban/enums/KanbanPrioritiesEnum.js +6 -2
  85. package/ui/content/Kanban/enums/index.d.ts +1 -1
  86. package/ui/content/Kanban/enums/index.js +2 -2
  87. package/ui/content/Kanban/hooks/useKanban.js +2 -2
  88. package/ui/content/Kanban/reducers/kanban.js +1 -0
  89. package/ui/content/Slider/Slider.d.ts +1 -1
  90. package/ui/content/Slider/Slider.js +0 -1
  91. package/ui/content/index.d.ts +7 -7
  92. package/ui/content/index.js +15 -15
  93. package/ui/crud/Crud/Crud.js +4 -4
  94. package/ui/crud/Crud/CrudContent.d.ts +2 -2
  95. package/ui/crud/Crud/CrudContent.js +11 -5
  96. package/ui/crud/Crud/CrudModal.js +1 -1
  97. package/ui/crud/Crud/utils.js +5 -3
  98. package/ui/crud/index.d.ts +1 -1
  99. package/ui/form/AutoCompleteField/AutoCompleteField.js +2 -2
  100. package/ui/form/BlankField/BlankField.js +1 -1
  101. package/ui/form/Button/Button.d.ts +2 -2
  102. package/ui/form/Button/Button.js +4 -2
  103. package/ui/form/Button/index.js +1 -0
  104. package/ui/form/CheckboxField/CheckboxField.js +5 -3
  105. package/ui/form/CheckboxListField/CheckboxListField.d.ts +1 -1
  106. package/ui/form/CheckboxListField/CheckboxListField.js +1 -1
  107. package/ui/form/CheckboxTreeField/CheckboxTreeField.d.ts +3 -3
  108. package/ui/form/CheckboxTreeField/CheckboxTreeField.js +3 -3
  109. package/ui/form/DateField/DateField.d.ts +2 -2
  110. package/ui/form/DateField/DateField.js +7 -7
  111. package/ui/form/DateField/useDateInputState.js +1 -1
  112. package/ui/form/DateField/useDateRange.js +3 -3
  113. package/ui/form/DateField/useDateTime.js +1 -1
  114. package/ui/form/DateRangeField/DateRangeField.d.ts +2 -2
  115. package/ui/form/DateRangeField/DateRangeField.js +15 -13
  116. package/ui/form/DateTimeField/DateTimeField.d.ts +1 -1
  117. package/ui/form/DateTimeField/DateTimeField.js +9 -9
  118. package/ui/form/DateTimeField/utils.js +12 -3
  119. package/ui/form/DateTimeRangeField/DateTimeRangeField.d.ts +1 -1
  120. package/ui/form/DateTimeRangeField/DateTimeRangeField.js +15 -13
  121. package/ui/form/DropDownField/DropDownField.d.ts +3 -3
  122. package/ui/form/DropDownField/DropDownField.js +5 -5
  123. package/ui/form/EmailField/EmailField.d.ts +1 -1
  124. package/ui/form/EmailField/EmailField.js +2 -2
  125. package/ui/form/Field/Field.js +3 -3
  126. package/ui/form/Field/fieldWrapper.js +6 -6
  127. package/ui/form/FieldLayout/FieldLayout.js +1 -1
  128. package/ui/form/FieldList/FieldList.js +15 -11
  129. package/ui/form/FieldSet/FieldSet.js +5 -3
  130. package/ui/form/FileField/FileField.d.ts +1 -1
  131. package/ui/form/FileField/FileField.js +2 -2
  132. package/ui/form/Form/Form.d.ts +2 -2
  133. package/ui/form/Form/Form.js +28 -25
  134. package/ui/form/HtmlField/HtmlField.js +2 -2
  135. package/ui/form/ImageField/ImageField.d.ts +2 -2
  136. package/ui/form/ImageField/ImageField.js +4 -4
  137. package/ui/form/InputField/InputField.d.ts +2 -2
  138. package/ui/form/InputField/InputField.js +11 -11
  139. package/ui/form/NavField/NavField.d.ts +2 -2
  140. package/ui/form/NavField/NavField.js +3 -3
  141. package/ui/form/NumberField/NumberField.d.ts +2 -2
  142. package/ui/form/NumberField/NumberField.js +5 -4
  143. package/ui/form/NumberField/hooks/useInputTypeNumber.js +2 -2
  144. package/ui/form/PasswordField/PasswordField.d.ts +1 -1
  145. package/ui/form/PasswordField/PasswordField.js +3 -1
  146. package/ui/form/RateField/RateField.js +2 -2
  147. package/ui/form/SliderField/SliderField.d.ts +1 -1
  148. package/ui/form/SliderField/SliderField.js +2 -2
  149. package/ui/form/TextField/TextField.js +1 -1
  150. package/ui/form/TimeField/TimeField.js +8 -8
  151. package/ui/form/TimeField/utils.js +9 -2
  152. package/ui/form/TimeRangeField/TimeRangeField.js +11 -11
  153. package/ui/form/WizardForm/WizardForm.d.ts +1 -1
  154. package/ui/form/WizardForm/WizardForm.js +4 -4
  155. package/ui/form/WizardForm/utils.d.ts +1 -1
  156. package/ui/form/WizardForm/utils.js +3 -3
  157. package/ui/form/index.d.ts +2 -2
  158. package/ui/form/index.js +4 -4
  159. package/ui/form/validate.js +5 -5
  160. package/ui/format/EnumFormatter/EnumFormatter.js +3 -1
  161. package/ui/format/Format/Format.js +1 -1
  162. package/ui/layout/Header/Header.d.ts +3 -3
  163. package/ui/layout/Loader/Loader.d.ts +1 -1
  164. package/ui/layout/Notifications/Notifications.d.ts +1 -1
  165. package/ui/layout/Notifications/Notifications.js +3 -3
  166. package/ui/layout/ProgressBar/ProgressBar.js +1 -1
  167. package/ui/layout/Sidebar/Sidebar.d.ts +1 -1
  168. package/ui/layout/Tooltip/Tooltip.js +1 -1
  169. package/ui/layout/index.d.ts +1 -1
  170. package/ui/layout/index.js +2 -2
  171. package/ui/list/CheckboxColumn/CheckboxColumn.js +1 -1
  172. package/ui/list/Empty/Empty.js +6 -2
  173. package/ui/list/Grid/Grid.d.ts +1 -1
  174. package/ui/list/Grid/Grid.js +6 -4
  175. package/ui/list/InfiniteScroll/InfiniteScroll.js +5 -3
  176. package/ui/list/LayoutNames/LayoutNames.d.ts +2 -2
  177. package/ui/list/LayoutNames/LayoutNames.js +5 -3
  178. package/ui/list/Pagination/Pagination.js +4 -2
  179. package/ui/list/PaginationSize/PaginationSize.d.ts +1 -1
  180. package/ui/list/PaginationSize/PaginationSize.js +5 -3
  181. package/ui/list/SearchForm/SearchForm.js +1 -1
  182. package/ui/list/Steps/Steps.js +1 -1
  183. package/ui/list/TreeTable/TreeTable.d.ts +1 -1
  184. package/ui/list/TreeTable/TreeTable.js +9 -7
  185. package/ui/modal/ModalPortal/ModalPortal.js +2 -2
  186. package/ui/modal/TwoFactorModal/TwoFactorModal.js +3 -1
  187. package/ui/nav/ButtonGroup/ButtonGroup.d.ts +1 -1
  188. package/ui/nav/Controls/Controls.d.ts +1 -1
  189. package/ui/nav/Nav/Nav.js +2 -2
  190. package/ui/nav/Router/Router.js +15 -10
  191. package/ui/nav/Router/helpers.js +1 -1
  192. package/ui/nav/index.d.ts +3 -3
  193. package/ui/nav/index.js +6 -6
  194. package/ui/typography/Text/Text.d.ts +1 -1
  195. package/ui/typography/Title/Title.d.ts +1 -1
  196. package/utils/calculateComponentAbsolutePosition.js +9 -3
  197. package/utils/calendar.js +2 -1
  198. package/utils/data.js +27 -17
  199. package/utils/form.js +10 -8
package/actions/auth.js CHANGED
@@ -34,6 +34,7 @@ var init = function (skipInitialized) {
34
34
  exports.init = init;
35
35
  var reInit = function () { return (0, exports.init)(); };
36
36
  exports.reInit = reInit;
37
+ // eslint-disable-next-line default-param-last
37
38
  var login = function (token, redirectPageId, params) {
38
39
  if (redirectPageId === void 0) { redirectPageId = 'root'; }
39
40
  return function (dispatch, getState, _a) {
package/actions/list.js CHANGED
@@ -15,17 +15,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  exports.__esModule = true;
17
17
  exports.selectItem = exports.toggleAll = exports.toggleItem = exports.deleteItem = exports.update = exports.add = exports.listDestroy = exports.listRefresh = exports.listLazyFetch = exports.listFetch = exports.listChangeAction = exports.listSetLayout = exports.listSetItems = exports.listInit = exports.localFetchHandler = exports.httpFetchHandler = exports.LIST_SELECT_ITEM = exports.LIST_CHANGE_ACTION = exports.LIST_SET_LAYOUT = exports.LIST_TOGGLE_ALL = exports.LIST_TOGGLE_ITEM = exports.LIST_DESTROY = exports.LIST_ITEM_DELETE = exports.LIST_ITEM_UPDATE = exports.LIST_ITEM_ADD = exports.LIST_AFTER_FETCH = exports.LIST_BEFORE_FETCH = exports.LIST_SET_ITEMS = exports.LIST_INIT = void 0;
18
+ var axios_1 = __importDefault(require("axios"));
18
19
  var get_1 = __importDefault(require("lodash-es/get"));
19
20
  var isArray_1 = __importDefault(require("lodash-es/isArray"));
20
21
  var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
21
- var orderBy_1 = __importDefault(require("lodash-es/orderBy"));
22
- var trimStart_1 = __importDefault(require("lodash-es/trimStart"));
23
- var isFunction_1 = __importDefault(require("lodash-es/isFunction"));
24
22
  var isEqual_1 = __importDefault(require("lodash-es/isEqual"));
23
+ var isFunction_1 = __importDefault(require("lodash-es/isFunction"));
25
24
  var isNil_1 = __importDefault(require("lodash-es/isNil"));
26
- var axios_1 = __importDefault(require("axios"));
27
- var form_1 = require("../reducers/form");
28
- var form_2 = require("../actions/form");
25
+ var orderBy_1 = __importDefault(require("lodash-es/orderBy"));
26
+ var trimStart_1 = __importDefault(require("lodash-es/trimStart"));
27
+ var form_1 = require("../actions/form");
28
+ var form_2 = require("../reducers/form");
29
29
  var data_1 = require("../utils/data");
30
30
  exports.LIST_INIT = '@list/init';
31
31
  exports.LIST_SET_ITEMS = '@list/set_items';
@@ -148,7 +148,7 @@ var listFetch = function (listId, query) {
148
148
  return [];
149
149
  }
150
150
  var toDispatch = [];
151
- var formValues = (0, form_1.formSelector)(state, list.formId, function (_a) {
151
+ var formValues = (0, form_2.formSelector)(state, list.formId, function (_a) {
152
152
  var values = _a.values;
153
153
  return values;
154
154
  }) || {};
@@ -156,7 +156,7 @@ var listFetch = function (listId, query) {
156
156
  // Change query
157
157
  Object.keys(query || {}).forEach(function (key) {
158
158
  formValues[key] = query[key];
159
- toDispatch.push((0, form_2.formChange)(list.formId, key, query[key]));
159
+ toDispatch.push((0, form_1.formChange)(list.formId, key, query[key]));
160
160
  });
161
161
  // Отменяем предыдущий запрос для этого listId (если есть)
162
162
  components.http._promises = components.http._promises || {};
@@ -172,7 +172,9 @@ var listFetch = function (listId, query) {
172
172
  // Создаем новый источник отмены
173
173
  var source = axios_1["default"].CancelToken.source();
174
174
  components.http._promises[listId] = source;
175
- var options = { cancelToken: source.token };
175
+ var options = {
176
+ cancelToken: source.token
177
+ };
176
178
  // Set `Loading...`
177
179
  if (list.isRemote) {
178
180
  toDispatch.push({
@@ -205,7 +207,7 @@ var listFetch = function (listId, query) {
205
207
  var totalPages = Math.ceil(((list === null || list === void 0 ? void 0 : list.total) || 0) / (pageSize || 1));
206
208
  var hasNextPage = (_a = data === null || data === void 0 ? void 0 : data.hasNextPage) !== null && _a !== void 0 ? _a : (page !== totalPages || null);
207
209
  return [
208
- (0, form_2.formSetErrors)(list.formId, data.errors || null),
210
+ (0, form_1.formSetErrors)(list.formId, data.errors || null),
209
211
  {
210
212
  items: items,
211
213
  total: total,
@@ -12,5 +12,5 @@ export declare const closeNotification: (id?: string | null) => {
12
12
  export declare const showNotification: (message: string | {
13
13
  message: string;
14
14
  description?: string;
15
- }, level?: ColorName, params?: IShowNotificationParameters) => (dispatch: any) => void;
15
+ }, notificationType?: AlertColorName, params?: IShowNotificationParameters) => (dispatch: any) => void;
16
16
  export declare const setFlashes: (flashes: any) => ((dispatch: any) => void)[][];
@@ -31,8 +31,10 @@ var closeNotification = function (id) {
31
31
  });
32
32
  };
33
33
  exports.closeNotification = closeNotification;
34
- var showNotification = function (message, level, params) {
35
- if (level === void 0) { level = null; }
34
+ var showNotification = function (message,
35
+ // eslint-disable-next-line default-param-last
36
+ notificationType, params) {
37
+ if (notificationType === void 0) { notificationType = null; }
36
38
  return function (dispatch) {
37
39
  var _a = __assign(__assign({}, showNotificationDefaults), params), position = _a.position, timeOut = _a.timeOut;
38
40
  var id = (0, uniqueId_1["default"])();
@@ -40,7 +42,7 @@ var showNotification = function (message, level, params) {
40
42
  type: exports.NOTIFICATIONS_SHOW,
41
43
  id: id,
42
44
  message: message,
43
- level: level || 'success',
45
+ notificationType: notificationType || 'success',
44
46
  position: position
45
47
  });
46
48
  if (timeOut > 0) {
@@ -28,8 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  exports.__esModule = true;
29
29
  /* eslint-disable import/no-extraneous-dependencies */
30
30
  /* eslint-disable no-unused-expressions */
31
- var cookie = __importStar(require("js-cookie"));
32
31
  var dayjs_1 = __importDefault(require("dayjs"));
32
+ var cookie = __importStar(require("js-cookie"));
33
33
  /**
34
34
  * Client Storage Component
35
35
  * Слой хранения данных в браузере (cookie, local/session storage) или ReactNative
@@ -50,11 +50,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  exports.__esModule = true;
53
- var trimStart_1 = __importDefault(require("lodash-es/trimStart"));
54
- var trimEnd_1 = __importDefault(require("lodash-es/trimEnd"));
53
+ var axios_1 = __importDefault(require("axios"));
55
54
  var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
55
+ var trimEnd_1 = __importDefault(require("lodash-es/trimEnd"));
56
+ var trimStart_1 = __importDefault(require("lodash-es/trimStart"));
56
57
  var set_cookie_parser_1 = __importDefault(require("set-cookie-parser"));
57
- var axios_1 = __importDefault(require("axios"));
58
58
  var notifications_1 = require("../actions/notifications");
59
59
  /**
60
60
  * Http Component
@@ -54,9 +54,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
54
54
  return (mod && mod.__esModule) ? mod : { "default": mod };
55
55
  };
56
56
  exports.__esModule = true;
57
- var axios_1 = __importDefault(require("axios"));
58
- var HttpComponent_1 = __importDefault(require("@steroidsjs/core/components/HttpComponent"));
59
57
  var auth_1 = require("@steroidsjs/core/actions/auth");
58
+ var HttpComponent_1 = __importDefault(require("@steroidsjs/core/components/HttpComponent"));
59
+ var axios_1 = __importDefault(require("axios"));
60
60
  /**
61
61
  * JwtHttpComponent
62
62
  * Вариация HttpComponent с функционалом обновления токена авторизации
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  exports.__esModule = true;
29
29
  /* eslint-disable import/no-extraneous-dependencies */
30
- var React = __importStar(require("react"));
31
- var intl_messageformat_1 = __importDefault(require("intl-messageformat"));
32
30
  var dayjs_1 = __importDefault(require("dayjs"));
31
+ var intl_messageformat_1 = __importDefault(require("intl-messageformat"));
33
32
  var isObject_1 = __importDefault(require("lodash-es/isObject"));
33
+ var React = __importStar(require("react"));
34
34
  require("dayjs/locale/it");
35
35
  require("dayjs/locale/ru");
36
36
  /**
@@ -42,7 +42,8 @@ var LocaleComponent = /** @class */ (function () {
42
42
  this.language = config.language || 'en';
43
43
  this.sourceLanguage = config.sourceLanguage || 'ru';
44
44
  this.backendTimeZone = null;
45
- this.backendTimeDiff = null; // in microseconds
45
+ // in microseconds
46
+ this.backendTimeDiff = null;
46
47
  this.translations = {};
47
48
  // Publish to global
48
49
  if (process.env.IS_SSR) {
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  exports.__esModule = true;
6
- var upperFirst_1 = __importDefault(require("lodash-es/upperFirst"));
7
6
  var isEmpty_1 = __importDefault(require("lodash-es/isEmpty"));
7
+ var upperFirst_1 = __importDefault(require("lodash-es/upperFirst"));
8
8
  var auth_1 = require("../reducers/auth");
9
9
  /**
10
10
  * Metrics Component
@@ -85,6 +85,8 @@ export interface IResourceComponent extends IResourceComponentConfig {
85
85
  /**
86
86
  * Resource Component
87
87
  * Компонент для подгрузки внешних API: Google Maps, Yandex Maps, Twitter, ...
88
+ *
89
+ * @deprecated
88
90
  */
89
91
  export default class ResourceComponent implements IResourceComponent {
90
92
  protected _callbacks: any;
@@ -27,11 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  exports.__esModule = true;
29
29
  /* eslint-disable @typescript-eslint/ban-ts-comment */
30
- var queryString = __importStar(require("qs"));
31
30
  var isArray_1 = __importDefault(require("lodash-es/isArray"));
31
+ var queryString = __importStar(require("qs"));
32
32
  /**
33
33
  * Resource Component
34
34
  * Компонент для подгрузки внешних API: Google Maps, Yandex Maps, Twitter, ...
35
+ *
36
+ * @deprecated
35
37
  */
36
38
  var ResourceComponent = /** @class */ (function () {
37
39
  function ResourceComponent(components, config) {
@@ -50,7 +52,9 @@ var ResourceComponent = /** @class */ (function () {
50
52
  if (window.grecaptcha) {
51
53
  return Promise.resolve(window.grecaptcha);
52
54
  }
53
- return this.loadScript(this.RESOURCE_GOOGLE_CAPTCHA, { render: this.googleCaptchaSiteKey }, function () { return window.grecaptcha; });
55
+ return this.loadScript(this.RESOURCE_GOOGLE_CAPTCHA, {
56
+ render: this.googleCaptchaSiteKey
57
+ }, function () { return window.grecaptcha; });
54
58
  };
55
59
  ResourceComponent.prototype.loadGoogleMapApi = function () {
56
60
  var locale = this._components.locale;
@@ -73,7 +77,7 @@ var ResourceComponent = /** @class */ (function () {
73
77
  if (window.ymaps) {
74
78
  return new Promise(function (resolve) {
75
79
  // @ts-ignore
76
- // eslint-disable-next-line implicit-arrow-linebreak
80
+ // eslint-disable-next-line implicit-arrow-linebreak,no-promise-executor-return
77
81
  return window.ymaps.ready(function () { return resolve(window.ymaps); });
78
82
  });
79
83
  }
@@ -81,6 +85,7 @@ var ResourceComponent = /** @class */ (function () {
81
85
  lang: this.language || locale.language
82
86
  },
83
87
  // @ts-ignore
88
+ // eslint-disable-next-line no-promise-executor-return
84
89
  function () { return new Promise(function (resolve) { return window.ymaps.ready(function () { return resolve(window.ymaps); }); }); });
85
90
  };
86
91
  ResourceComponent.prototype.loadTwitterWidget = function () {
@@ -91,6 +96,7 @@ var ResourceComponent = /** @class */ (function () {
91
96
  }
92
97
  return this.loadScript(this.RESOURCE_TWITTER_WIDGET, {},
93
98
  // @ts-ignore
99
+ // eslint-disable-next-line no-promise-executor-return
94
100
  function () { return new Promise(function (resolve) { return window.twttr.ready(function () { return resolve(window.twttr); }); }); });
95
101
  };
96
102
  ResourceComponent.prototype.loadGeetest = function () {
@@ -18,7 +18,9 @@ var SocialComponent = /** @class */ (function () {
18
18
  var _this = this;
19
19
  Object.keys(this.providers).forEach(function (name) {
20
20
  if ((0, isFunction_1["default"])(_this.providers[name])) {
21
- _this.providers[name] = { className: _this.providers[name] };
21
+ _this.providers[name] = {
22
+ className: _this.providers[name]
23
+ };
22
24
  }
23
25
  var ProviderClass = _this.providers[name].className;
24
26
  delete _this.providers[name].className;
@@ -1,3 +1,7 @@
1
+ import { IComponents } from '@steroidsjs/core/providers/ComponentsProvider';
2
+ import { RouterState } from 'connected-react-router';
3
+ import { History, LocationState } from 'history';
4
+ import { Store, Dispatch, Unsubscribe, Reducer, AnyAction } from 'redux';
1
5
  declare global {
2
6
  interface Window {
3
7
  APP_REDUX_PRELOAD_STATES?: any;
@@ -5,26 +9,34 @@ declare global {
5
9
  }
6
10
  }
7
11
  interface IStoreComponentConfig {
8
- initialState: any;
9
- history: any;
12
+ initialState: Record<string, any>;
13
+ history: History;
10
14
  }
15
+ type AsyncReducersMap = {
16
+ router?: Reducer<RouterState<LocationState>, AnyAction>;
17
+ [key: string]: Reducer<any, AnyAction> | undefined;
18
+ };
19
+ type RootState<R extends AsyncReducersMap> = {
20
+ [K in keyof R]: R[K] extends Reducer<infer S, AnyAction> ? S : never;
21
+ };
22
+ type CreateRootReducer = <R extends AsyncReducersMap>(reducers: R) => Reducer<RootState<R>, AnyAction>;
11
23
  export interface IStoreComponent {
12
24
  /**
13
25
  * Редьюсеры
14
26
  */
15
- reducers: any;
27
+ reducers: CreateRootReducer;
16
28
  /**
17
29
  * Хранилище
18
30
  */
19
- store: any;
31
+ store: Store;
20
32
  /**
21
33
  * Инициализация
22
34
  */
23
- init(): void;
35
+ init(config: IStoreComponentConfig): void;
24
36
  /**
25
37
  * Инициализация хранилища
26
38
  */
27
- initStore(): void;
39
+ initStore(config: IStoreComponentConfig): void;
28
40
  /**
29
41
  * Конфигурация
30
42
  */
@@ -33,16 +45,16 @@ export interface IStoreComponent {
33
45
  * Метод для dispatch
34
46
  * @param action Экшен для изменения состояния.
35
47
  */
36
- dispatch(action: any): void;
48
+ dispatch: Dispatch<any>;
37
49
  /**
38
50
  * Получение состояния
39
51
  */
40
- getState(): void;
52
+ getState(): Record<string, any>;
41
53
  /**
42
54
  * Подписка
43
55
  * @param handler Обработчик изменения состояния.
44
56
  */
45
- subscribe(handler: any): void;
57
+ subscribe(handler: () => void): Unsubscribe;
46
58
  /**
47
59
  * Добавление редьюсеров
48
60
  * @param asyncReducers Коллекция редьюсеров.
@@ -61,23 +73,23 @@ export interface IStoreComponent {
61
73
  * Обертка над Redux Store со встроенными middleware (thunk, multi, promise..) и react-router.
62
74
  */
63
75
  export default class StoreComponent implements IStoreComponent {
64
- _asyncReducers: any;
65
- _components: any;
66
- reducers: any;
67
- _routerReducer: any;
68
- history: any;
76
+ _asyncReducers: AsyncReducersMap;
77
+ _components: IComponents;
78
+ reducers: CreateRootReducer;
79
+ _routerReducer: Reducer<RouterState<LocationState>>;
80
+ history: History | null;
69
81
  navigationNative: any;
70
- store: any;
82
+ store: Store | null;
71
83
  lastAction: string;
72
- constructor(components: any, config: any, lazyInit?: boolean);
73
- init(config?: IStoreComponentConfig): void;
74
- initStore(config?: IStoreComponentConfig): void;
84
+ constructor(components: IComponents, config: any, lazyInit?: boolean);
85
+ init(config: IStoreComponentConfig): void;
86
+ initStore(config: IStoreComponentConfig): void;
75
87
  configurate(): void;
76
88
  dispatch(action: any): any;
77
89
  getState(): any;
78
- subscribe(handler: any): any;
79
- addReducers(asyncReducers: any): void;
90
+ subscribe(handler: any): Unsubscribe;
91
+ addReducers(asyncReducers: AsyncReducersMap): void;
80
92
  errorHandler(error: any, action: any): void;
81
- _prepare(action: any, dispatch: any, getState: any): any;
93
+ _prepare(action: any, dispatch: Dispatch<any>, getState: Record<string, any>): any;
82
94
  }
83
95
  export {};
@@ -14,13 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  exports.__esModule = true;
17
- /* eslint-disable no-restricted-globals */
18
- var redux_1 = require("redux");
19
17
  var connected_react_router_1 = require("connected-react-router");
20
18
  var history_1 = require("history");
21
19
  var get_1 = __importDefault(require("lodash-es/get"));
22
- var merge_1 = __importDefault(require("lodash-es/merge"));
23
20
  var isPlainObject_1 = __importDefault(require("lodash-es/isPlainObject"));
21
+ var merge_1 = __importDefault(require("lodash-es/merge"));
22
+ var redux_1 = require("redux");
24
23
  /**
25
24
  * Store Component
26
25
  * Обертка над Redux Store со встроенными middleware (thunk, multi, promise..) и react-router.
@@ -28,10 +27,11 @@ var isPlainObject_1 = __importDefault(require("lodash-es/isPlainObject"));
28
27
  var StoreComponent = /** @class */ (function () {
29
28
  function StoreComponent(components, config, lazyInit) {
30
29
  if (lazyInit === void 0) { lazyInit = false; }
30
+ var _a;
31
31
  this._components = components;
32
32
  this.reducers = config.reducers;
33
33
  this.history = null;
34
- this.store = config.store || null;
34
+ this.store = (_a = config.store) !== null && _a !== void 0 ? _a : null;
35
35
  this.lastAction = null;
36
36
  this._asyncReducers = {};
37
37
  this.getState = this.getState.bind(this);
@@ -42,13 +42,11 @@ var StoreComponent = /** @class */ (function () {
42
42
  }
43
43
  }
44
44
  StoreComponent.prototype.init = function (config) {
45
- if (config === void 0) { config = {}; }
46
45
  this.initStore(config);
47
46
  this.configurate();
48
47
  };
49
48
  StoreComponent.prototype.initStore = function (config) {
50
49
  var _this = this;
51
- if (config === void 0) { config = {}; }
52
50
  var initialState = __assign(__assign({}, (process.env.IS_WEB
53
51
  ? merge_1["default"].apply(void 0, (window.APP_REDUX_PRELOAD_STATES || [{}])) : {})), config.initialState);
54
52
  if (window === null || window === void 0 ? void 0 : window.APP_REDUX_PRELOAD_STATES) {
@@ -68,10 +66,7 @@ var StoreComponent = /** @class */ (function () {
68
66
  this._routerReducer = (0, connected_react_router_1.connectRouter)(this.history);
69
67
  }
70
68
  if (!this.store) {
71
- this.store = (0, redux_1.createStore)(
72
- //TODO TYPES
73
- //@ts-ignore
74
- this.reducers(this._routerReducer ? {
69
+ this.store = (0, redux_1.createStore)(this.reducers(this._routerReducer ? {
75
70
  router: this._routerReducer
76
71
  } : {}), initialState, (0, redux_1.compose)((0, redux_1.applyMiddleware)(function (_a) {
77
72
  var getState = _a.getState;
@@ -37,10 +37,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  exports.__esModule = true;
40
- var React = __importStar(require("react"));
41
40
  var isFunction_1 = __importDefault(require("lodash-es/isFunction"));
42
41
  var isObject_1 = __importDefault(require("lodash-es/isObject"));
43
42
  var isString_1 = __importDefault(require("lodash-es/isString"));
43
+ var React = __importStar(require("react"));
44
44
  /**
45
45
  * Ui Component
46
46
  * Компонент для подгрузки и конфигурации UI компонентов приложения
@@ -83,7 +83,9 @@ var GitlabProvider = /** @class */ (function () {
83
83
  // ?provider=gitlab_kozhindev#access_token=7b87e3de0...5518198d885d&token_type=Bearer
84
84
  var token = (/access_token=(\w+)/.exec(link) || [])[1];
85
85
  if (token) {
86
- resolve({ token: token });
86
+ resolve({
87
+ token: token
88
+ });
87
89
  }
88
90
  else {
89
91
  reject();