@jetbrains/ring-ui 5.0.36 → 5.0.37

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 (236) hide show
  1. package/components/input/input.css +2 -0
  2. package/components/query-assist/query-assist.js +1 -1
  3. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -4
  4. package/dist/_helpers/anchor.js +0 -1
  5. package/dist/_helpers/card.js +0 -3
  6. package/dist/_helpers/dialog__body-scroll-preventer.js +0 -11
  7. package/dist/_helpers/footer.js +2 -13
  8. package/dist/_helpers/query-assist__suggestions.js +0 -10
  9. package/dist/_helpers/select__filter.js +0 -11
  10. package/dist/_helpers/services-link.js +0 -2
  11. package/dist/_helpers/sidebar.js +0 -12
  12. package/dist/_helpers/theme.js +0 -3
  13. package/dist/_helpers/title.js +0 -9
  14. package/dist/alert/alert.js +2 -32
  15. package/dist/alert/container.js +0 -5
  16. package/dist/alert-service/alert-service.js +0 -26
  17. package/dist/analytics/analytics.js +0 -22
  18. package/dist/analytics/analytics__custom-plugin.js +0 -38
  19. package/dist/analytics/analytics__fus-plugin.js +0 -20
  20. package/dist/analytics/analytics__ga-plugin.js +0 -13
  21. package/dist/analytics/analytics__plugin-utils.js +0 -8
  22. package/dist/analytics-ng/analytics-ng.js +3 -9
  23. package/dist/auth/auth.js +2 -3
  24. package/dist/auth/auth__core.js +30 -243
  25. package/dist/auth/background-flow.js +2 -25
  26. package/dist/auth/down-notification.js +0 -7
  27. package/dist/auth/iframe-flow.js +2 -26
  28. package/dist/auth/landing.js +2 -6
  29. package/dist/auth/request-builder.js +0 -11
  30. package/dist/auth/response-parser.js +4 -26
  31. package/dist/auth/storage.js +4 -60
  32. package/dist/auth/token-validator.js +6 -42
  33. package/dist/auth/window-flow.js +2 -34
  34. package/dist/auth-dialog/auth-dialog.js +2 -12
  35. package/dist/auth-dialog-service/auth-dialog-service.js +2 -4
  36. package/dist/auth-ng/auth-ng.js +6 -22
  37. package/dist/auth-ng/auth-ng.mock.js +0 -4
  38. package/dist/autofocus-ng/autofocus-ng.js +0 -5
  39. package/dist/avatar/avatar.js +4 -17
  40. package/dist/avatar/fallback-avatar.js +2 -9
  41. package/dist/avatar-editor-ng/avatar-editor-ng.js +1 -17
  42. package/dist/badge/badge.js +0 -3
  43. package/dist/button/button.js +0 -8
  44. package/dist/button-group/button-group.js +0 -3
  45. package/dist/button-group/caption.js +0 -2
  46. package/dist/button-group-ng/button-group-ng.js +0 -4
  47. package/dist/button-ng/button-ng.js +3 -21
  48. package/dist/button-set/button-set.js +0 -3
  49. package/dist/button-set-ng/button-set-ng.js +0 -2
  50. package/dist/button-toolbar/button-toolbar.js +0 -3
  51. package/dist/button-toolbar-ng/button-toolbar-ng.js +0 -2
  52. package/dist/caret/caret.js +2 -53
  53. package/dist/checkbox/checkbox.js +0 -12
  54. package/dist/code/code.js +3 -25
  55. package/dist/compiler-ng/compiler-ng.js +0 -5
  56. package/dist/confirm/confirm.js +0 -6
  57. package/dist/confirm-service/confirm-service.js +10 -8
  58. package/dist/content-layout/content-layout.js +0 -7
  59. package/dist/contenteditable/contenteditable.js +6 -13
  60. package/dist/data-list/data-list.js +4 -28
  61. package/dist/data-list/item.js +0 -15
  62. package/dist/data-list/selection.js +0 -27
  63. package/dist/date-picker/consts.js +0 -7
  64. package/dist/date-picker/date-input.js +0 -20
  65. package/dist/date-picker/date-picker.js +2 -36
  66. package/dist/date-picker/date-popup.js +18 -71
  67. package/dist/date-picker/day.js +0 -14
  68. package/dist/date-picker/month-names.js +0 -9
  69. package/dist/date-picker/month-slider.js +0 -10
  70. package/dist/date-picker/month.js +2 -4
  71. package/dist/date-picker/months.js +6 -13
  72. package/dist/date-picker/years.js +0 -14
  73. package/dist/dialog/dialog.js +0 -19
  74. package/dist/dialog-ng/dialog-ng.js +17 -105
  75. package/dist/docked-panel-ng/docked-panel-ng.js +6 -29
  76. package/dist/dropdown/dropdown.js +2 -33
  77. package/dist/dropdown-menu/dropdown-menu.js +4 -8
  78. package/dist/editable-heading/editable-heading.js +0 -3
  79. package/dist/error-bubble/error-bubble.js +2 -4
  80. package/dist/error-message/error-message.js +0 -3
  81. package/dist/footer-ng/footer-ng.js +0 -13
  82. package/dist/form-ng/form-ng.js +1 -21
  83. package/dist/global/angular-component-factory.js +0 -10
  84. package/dist/global/compose.js +0 -1
  85. package/dist/global/composeRefs.js +0 -1
  86. package/dist/global/controls-height.js +0 -2
  87. package/dist/global/create-stateful-context.js +0 -5
  88. package/dist/global/data-tests.js +0 -4
  89. package/dist/global/dom.js +2 -11
  90. package/dist/global/focus-sensor-hoc.js +4 -33
  91. package/dist/global/fuzzy-highlight.js +2 -16
  92. package/dist/global/get-event-key.js +8 -17
  93. package/dist/global/get-uid.js +0 -2
  94. package/dist/global/linear-function.js +0 -2
  95. package/dist/global/listeners.js +0 -13
  96. package/dist/global/memoize.js +0 -2
  97. package/dist/global/normalize-indent.js +2 -5
  98. package/dist/global/react-dom-renderer.js +0 -8
  99. package/dist/global/react-render-adapter.js +0 -7
  100. package/dist/global/rerender-hoc.js +0 -7
  101. package/dist/global/ring-angular-component.js +0 -5
  102. package/dist/global/schedule-raf.js +0 -5
  103. package/dist/global/trivial-template-tag.js +2 -3
  104. package/dist/global/url.js +0 -27
  105. package/dist/grid/col.js +0 -4
  106. package/dist/grid/grid.js +0 -3
  107. package/dist/grid/row.js +0 -5
  108. package/dist/group/group.js +0 -3
  109. package/dist/header/header.js +0 -5
  110. package/dist/header/logo.js +0 -4
  111. package/dist/header/profile.js +0 -7
  112. package/dist/header/services.js +0 -11
  113. package/dist/header/smart-profile.js +4 -18
  114. package/dist/header/smart-services.js +0 -17
  115. package/dist/header/tray-icon.js +2 -3
  116. package/dist/header/tray.js +0 -3
  117. package/dist/heading/heading.js +0 -5
  118. package/dist/http/http.js +20 -65
  119. package/dist/http/http.mock.js +2 -14
  120. package/dist/hub-source/hub-source.js +0 -32
  121. package/dist/hub-source/hub-source__user.js +0 -1
  122. package/dist/hub-source/hub-source__users-groups.js +0 -12
  123. package/dist/icon/icon.js +0 -13
  124. package/dist/icon/icon__constants.js +0 -4
  125. package/dist/icon/icon__svg.js +0 -10
  126. package/dist/icon-ng/icon-ng.js +2 -7
  127. package/dist/input/input.js +0 -30
  128. package/dist/input-ng/input-ng.js +0 -17
  129. package/dist/island/adaptive-island-hoc.js +0 -7
  130. package/dist/island/content.js +0 -25
  131. package/dist/island/header.js +0 -7
  132. package/dist/island/island.js +0 -4
  133. package/dist/island-legacy/content-legacy.js +0 -2
  134. package/dist/island-legacy/header-legacy.js +0 -2
  135. package/dist/island-legacy/island-legacy.js +0 -2
  136. package/dist/island-ng/island-content-ng.js +0 -3
  137. package/dist/link/clickableLink.js +2 -10
  138. package/dist/link/link.js +2 -9
  139. package/dist/link-ng/link-ng.js +0 -2
  140. package/dist/list/consts.js +0 -4
  141. package/dist/list/list.js +6 -128
  142. package/dist/list/list__custom.js +0 -4
  143. package/dist/list/list__hint.js +0 -3
  144. package/dist/list/list__item.js +0 -8
  145. package/dist/list/list__link.js +2 -3
  146. package/dist/list/list__separator.js +0 -1
  147. package/dist/list/list__title.js +0 -1
  148. package/dist/list/list__users-groups-source.js +4 -17
  149. package/dist/loader/loader.js +0 -10
  150. package/dist/loader/loader__core.js +6 -70
  151. package/dist/loader-inline/loader-inline.js +0 -3
  152. package/dist/loader-ng/loader-ng.js +0 -7
  153. package/dist/loader-screen/loader-screen.js +0 -3
  154. package/dist/loader-screen-ng/loader-screen-ng.js +2 -14
  155. package/dist/login-dialog/login-dialog.js +0 -15
  156. package/dist/login-dialog/service.js +2 -4
  157. package/dist/markdown/code.js +0 -2
  158. package/dist/markdown/heading.js +0 -1
  159. package/dist/markdown/link.js +0 -1
  160. package/dist/markdown/markdown.js +0 -2
  161. package/dist/message/message.js +0 -24
  162. package/dist/message-bundle-ng/message-bundle-ng.js +2 -45
  163. package/dist/old-browsers-message/old-browsers-message.js +2 -21
  164. package/dist/old-browsers-message/white-list.js +2 -6
  165. package/dist/pager/pager.js +2 -39
  166. package/dist/panel/panel.js +0 -3
  167. package/dist/permissions/permissions.js +1 -43
  168. package/dist/permissions/permissions__cache.js +12 -63
  169. package/dist/permissions-ng/permissions-ng.js +11 -19
  170. package/dist/place-under-ng/place-under-ng.js +0 -19
  171. package/dist/popup/popup.consts.js +0 -11
  172. package/dist/popup/popup.js +6 -68
  173. package/dist/popup/position.js +8 -30
  174. package/dist/popup-menu/popup-menu.js +4 -13
  175. package/dist/progress-bar/progress-bar.js +0 -14
  176. package/dist/promised-click-ng/promised-click-ng.js +3 -22
  177. package/dist/query-assist/query-assist.js +17 -201
  178. package/dist/radio/radio.js +0 -6
  179. package/dist/radio/radio__item.js +0 -9
  180. package/dist/radio-ng/radio-ng.js +0 -4
  181. package/dist/save-field-ng/save-field-ng.js +1 -37
  182. package/dist/select/select.js +18 -208
  183. package/dist/select/select__popup.js +4 -76
  184. package/dist/select-ng/select-ng.js +18 -74
  185. package/dist/select-ng/select-ng__lazy.js +2 -17
  186. package/dist/select-ng/select-ng__options.js +3 -29
  187. package/dist/shortcuts/core.js +4 -56
  188. package/dist/shortcuts/shortcuts-hoc.js +0 -4
  189. package/dist/shortcuts/shortcuts.js +0 -10
  190. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -13
  191. package/dist/shortcuts-ng/shortcuts-ng.js +16 -46
  192. package/dist/sidebar-ng/sidebar-ng.js +2 -12
  193. package/dist/storage/storage.js +2 -5
  194. package/dist/storage/storage__fallback.js +2 -48
  195. package/dist/storage/storage__local.js +0 -23
  196. package/dist/style.css +1 -1
  197. package/dist/tab-trap/tab-trap.js +0 -37
  198. package/dist/table/cell.js +0 -2
  199. package/dist/table/disable-hover-hoc.js +0 -9
  200. package/dist/table/header-cell.js +0 -8
  201. package/dist/table/header.js +0 -16
  202. package/dist/table/multitable.js +0 -23
  203. package/dist/table/row-with-focus-sensor.js +0 -12
  204. package/dist/table/row.js +0 -18
  205. package/dist/table/selection-adapter.js +0 -2
  206. package/dist/table/selection-shortcuts-hoc.js +8 -42
  207. package/dist/table/selection.js +0 -50
  208. package/dist/table/smart-table.js +0 -9
  209. package/dist/table/table.js +6 -37
  210. package/dist/table-legacy-ng/table-legacy-ng.js +12 -42
  211. package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +0 -31
  212. package/dist/table-legacy-ng/table-legacy-ng__selection.js +0 -32
  213. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +2 -5
  214. package/dist/tabs/collapsible-more.js +0 -5
  215. package/dist/tabs/collapsible-tab.js +0 -4
  216. package/dist/tabs/collapsible-tabs.js +8 -28
  217. package/dist/tabs/dumb-tabs.js +0 -8
  218. package/dist/tabs/smart-tabs.js +0 -6
  219. package/dist/tabs/tab-link.js +0 -1
  220. package/dist/tabs/tab.js +0 -2
  221. package/dist/tabs-ng/tabs-ng.js +13 -29
  222. package/dist/tag/tag.js +0 -24
  223. package/dist/tags-input/tags-input.js +0 -76
  224. package/dist/tags-list/tags-list.js +0 -6
  225. package/dist/template-ng/template-ng.js +0 -12
  226. package/dist/text/text.js +0 -3
  227. package/dist/theme-ng/theme-ng.js +0 -8
  228. package/dist/title-ng/title-ng.js +6 -17
  229. package/dist/toggle/toggle.js +0 -4
  230. package/dist/tooltip/tooltip.js +4 -35
  231. package/dist/tooltip-ng/tooltip-ng.js +2 -8
  232. package/dist/user-agreement/service.js +0 -62
  233. package/dist/user-agreement/user-agreement.js +0 -8
  234. package/dist/user-card/smart-user-card-tooltip.js +2 -8
  235. package/dist/user-card/tooltip.js +0 -3
  236. package/package.json +15 -15
@@ -40,31 +40,23 @@ import 'scrollbar-width';
40
40
  /**
41
41
  * @name Dialog
42
42
  */
43
-
44
43
  function noop() {}
45
-
46
44
  class Dialog extends PureComponent {
47
45
  constructor() {
48
46
  super(...arguments);
49
-
50
47
  _defineProperty(this, "state", {
51
48
  shortcutsScope: getUID('ring-dialog-')
52
49
  });
53
-
54
50
  _defineProperty(this, "scrollPreventer", preventerFactory(getUID('preventer-')));
55
-
56
51
  _defineProperty(this, "uid", getUID('dialog-'));
57
-
58
52
  _defineProperty(this, "handleClick", event => {
59
53
  this.props.onOverlayClick(event);
60
54
  this.props.onCloseAttempt(event);
61
55
  });
62
-
63
56
  _defineProperty(this, "onCloseClick", event => {
64
57
  this.props.onCloseClick(event);
65
58
  this.props.onCloseAttempt(event);
66
59
  });
67
-
68
60
  _defineProperty(this, "getShortcutsMap", () => {
69
61
  const onEscape = event => {
70
62
  if (this.props.show) {
@@ -72,33 +64,26 @@ class Dialog extends PureComponent {
72
64
  this.props.onCloseAttempt(event);
73
65
  }
74
66
  };
75
-
76
67
  return {
77
68
  esc: onEscape
78
69
  };
79
70
  });
80
-
81
71
  _defineProperty(this, "dialog", void 0);
82
-
83
72
  _defineProperty(this, "dialogRef", tabTrap => {
84
73
  this.dialog = tabTrap && tabTrap.node;
85
74
  });
86
75
  }
87
-
88
76
  componentDidMount() {
89
77
  this.toggleScrollPreventer();
90
78
  }
91
-
92
79
  componentDidUpdate(prevProps) {
93
80
  if (prevProps.show !== this.props.show) {
94
81
  this.toggleScrollPreventer();
95
82
  }
96
83
  }
97
-
98
84
  componentWillUnmount() {
99
85
  this.scrollPreventer.reset();
100
86
  }
101
-
102
87
  toggleScrollPreventer() {
103
88
  if (this.props.show) {
104
89
  this.scrollPreventer.prevent();
@@ -106,7 +91,6 @@ class Dialog extends PureComponent {
106
91
  this.scrollPreventer.reset();
107
92
  }
108
93
  }
109
-
110
94
  render() {
111
95
  const {
112
96
  show,
@@ -168,9 +152,7 @@ class Dialog extends PureComponent {
168
152
  "aria-label": closeButtonTitle || 'close dialog'
169
153
  }))), target)), portalTarget instanceof HTMLElement ? portalTarget : document.body);
170
154
  }
171
-
172
155
  }
173
-
174
156
  _defineProperty(Dialog, "propTypes", {
175
157
  label: PropTypes.string,
176
158
  className: PropTypes.string,
@@ -192,7 +174,6 @@ _defineProperty(Dialog, "propTypes", {
192
174
  autoFocusFirst: PropTypes.bool,
193
175
  'data-test': PropTypes.string
194
176
  });
195
-
196
177
  _defineProperty(Dialog, "defaultProps", {
197
178
  label: 'Dialog',
198
179
  onOverlayClick: noop,
@@ -27,37 +27,30 @@ var modules_b378ce5a = {"unit":"8px","dialogContainer":"dialogContainer_rui_0b63
27
27
 
28
28
  rgDialogContentDirective.$inject = ["$compile", "$q"];
29
29
  rgDialogDirective.$inject = ["$timeout"];
30
+
30
31
  /**
31
32
  * @name Dialog Ng
32
33
  */
33
34
 
34
35
  const angularModule = angular.module('Ring.dialog', [ButtonNG, PromisedClick, rgCompilerModuleName]);
35
-
36
36
  class DialogController extends RingAngularComponent {
37
37
  constructor() {
38
38
  super(...arguments);
39
-
40
39
  _defineProperty(this, "hide", () => {
41
40
  if (!this.inSidebar) {
42
41
  this.scrollPreventer.reset();
43
42
  }
44
-
45
43
  this.active = false;
46
44
  this.content = '';
47
45
  this.focusTrap.deactivate();
48
46
  Reflect.deleteProperty(this, 'DIALOG_NAMESPACE');
49
-
50
47
  if (shortcutsInstance.indexOfScope(this.dialogService.DIALOG_NAMESPACE) > -1) {
51
48
  shortcutsInstance.setScope(this.currentShortcutsScope);
52
49
  }
53
-
54
50
  this._resetFormState();
55
-
56
51
  this.$inject.$scope.$broadcast('dialog.hide');
57
52
  });
58
-
59
53
  _defineProperty(this, "serverErrorFields", []);
60
-
61
54
  this.styles = modules_b378ce5a;
62
55
  this.dialogStyles = modules_5e9b8c03;
63
56
  this.islandStyles = modules_e6a056e1;
@@ -67,7 +60,6 @@ class DialogController extends RingAngularComponent {
67
60
  this.reject = reject;
68
61
  });
69
62
  }
70
-
71
63
  $onInit() {
72
64
  const {
73
65
  dialog,
@@ -95,52 +87,42 @@ class DialogController extends RingAngularComponent {
95
87
  });
96
88
  dialogService.register(this);
97
89
  }
98
-
99
90
  getShortcuts() {
100
91
  const defaultEscHandler = function escHandler() {
101
92
  this.active = false;
102
93
  this.focusTrap.deactivate();
103
94
  this.$inject.$scope.$apply();
104
95
  }.bind(this);
105
-
106
96
  const dialogShortcuts = {
107
97
  esc: defaultEscHandler,
108
98
  enter: this.applyDefaultHandler(false),
109
99
  'mod+enter': this.applyDefaultHandler(true)
110
100
  };
111
101
  angular.extend(dialogShortcuts, this.shortcuts);
112
-
113
102
  if (this.shortcuts && this.shortcuts.esc) {
114
103
  /**
115
104
  * Merge ESC handler
116
105
  * @type {Function} {dialogShortcuts.esc}
117
106
  */
118
107
  const customHandler = dialogShortcuts.esc;
119
-
120
108
  dialogShortcuts.esc = () => {
121
109
  const result = customHandler();
122
110
  defaultEscHandler();
123
111
  return result;
124
112
  };
125
113
  }
126
-
127
114
  return dialogShortcuts;
128
115
  }
129
-
130
116
  handleClick(event) {
131
117
  const isOverlayClicked = event.target === event.currentTarget;
132
-
133
118
  if (this.inSidebar || !this.closeOnClick || !isOverlayClicked) {
134
119
  return;
135
120
  }
136
-
137
121
  this.hide();
138
122
  }
139
-
140
123
  setTitle(title) {
141
124
  this.title = title;
142
125
  }
143
-
144
126
  compileTemplate() {
145
127
  if (this.config.data) {
146
128
  const element = angular.element(this.template);
@@ -149,38 +131,31 @@ class DialogController extends RingAngularComponent {
149
131
  link: this.$inject.$compile(element)
150
132
  };
151
133
  }
152
-
153
134
  return this.$inject.rgCompiler(this.config).catch(error => {
154
135
  this.reject(error);
155
136
  return this.$inject.$q.reject(error);
156
137
  });
157
138
  }
158
-
159
139
  show(config) {
160
140
  const {
161
141
  $q,
162
142
  $scope
163
143
  } = this.$inject;
164
-
165
144
  if (!this.inSidebar) {
166
145
  this.scrollPreventer.prevent();
167
-
168
146
  if (config && config.trapFocus === true) {
169
147
  this.focusTrap.activate();
170
148
  }
171
149
  }
172
-
173
150
  if (this.active) {
174
151
  this.reset();
175
- } // Clear dialog errors
176
-
152
+ }
177
153
 
154
+ // Clear dialog errors
178
155
  this.error = null;
179
-
180
156
  if (this.dialogForm) {
181
157
  this.dialogForm.$setPristine();
182
158
  }
183
-
184
159
  if (config) {
185
160
  this.title = config.title;
186
161
  this.buttons = config.buttons;
@@ -194,11 +169,11 @@ class DialogController extends RingAngularComponent {
194
169
  this.template = config.template;
195
170
  this.config = config;
196
171
  this.description = config.description && config.description.split('\n') || [];
197
- this.closeOnClick = config.closeOnClick; // Backward compatibility with existing templates which use data directly from scope
172
+ this.closeOnClick = config.closeOnClick;
198
173
 
174
+ // Backward compatibility with existing templates which use data directly from scope
199
175
  $scope.data = this.data;
200
176
  }
201
-
202
177
  this.currentShortcutsScope = shortcutsInstance.getScope();
203
178
  this.DIALOG_NAMESPACE = this.dialogService.DIALOG_NAMESPACE;
204
179
  shortcutsInstance.setScope(this.dialogService.DIALOG_NAMESPACE);
@@ -209,67 +184,52 @@ class DialogController extends RingAngularComponent {
209
184
  this.reject = reject;
210
185
  });
211
186
  }
212
-
213
187
  update() {
214
188
  let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
215
189
  Object.assign(this.data, config.data);
216
190
  Object.assign(this.buttons, config.buttons);
217
191
  }
218
-
219
192
  _resetFormState() {
220
193
  const dialogForm = this.dialogForm;
221
-
222
194
  if (!dialogForm) {
223
195
  return;
224
196
  }
225
-
226
197
  dialogForm.$setPristine();
227
198
  dialogForm.$setUntouched();
228
199
  dialogForm.$valid = true;
229
200
  dialogForm.$invalid = false;
230
201
  dialogForm.$error = {};
231
202
  }
232
-
233
203
  done(result) {
234
204
  this.resetPosition();
235
205
  this.resolve(result);
236
206
  this.hide();
237
207
  }
238
-
239
208
  reset(result) {
240
209
  this.done(result);
241
210
  }
242
-
243
211
  getErrorMessage(errorResponse) {
244
212
  var _errorResponse$data, _errorResponse$data2;
245
-
246
213
  if (errorResponse !== null && errorResponse !== void 0 && (_errorResponse$data = errorResponse.data) !== null && _errorResponse$data !== void 0 && _errorResponse$data.error_description) {
247
214
  return errorResponse.data.error_description;
248
215
  }
249
-
250
216
  if (errorResponse !== null && errorResponse !== void 0 && (_errorResponse$data2 = errorResponse.data) !== null && _errorResponse$data2 !== void 0 && _errorResponse$data2.error) {
251
217
  return errorResponse.data.error;
252
218
  }
253
-
254
219
  return errorResponse;
255
220
  }
256
-
257
221
  getFieldErrorMessage(errorResponse) {
258
222
  if (errorResponse && errorResponse.data && errorResponse.data.error) {
259
223
  return errorResponse.data.error;
260
224
  }
261
-
262
225
  return null;
263
226
  }
264
-
265
227
  action(button) {
266
228
  if (button.inProgress) {
267
229
  return undefined;
268
230
  }
269
-
270
231
  const errorReporter = errorResponse => {
271
232
  const errorField = errorResponse && errorResponse.data && errorResponse.data.error_field;
272
-
273
233
  if (errorField && this.dialogForm[errorField]) {
274
234
  this.dialogForm[errorField].$invalid = true;
275
235
  this.dialogForm[errorField].$error[errorField] = [{
@@ -280,7 +240,6 @@ class DialogController extends RingAngularComponent {
280
240
  this.error = this.$inject.$sce.trustAsHtml(this.getErrorMessage(errorResponse));
281
241
  }
282
242
  };
283
-
284
243
  if (button.action) {
285
244
  if (!button.keepServerErrors) {
286
245
  this.serverErrorFields.forEach(errorField => {
@@ -289,12 +248,10 @@ class DialogController extends RingAngularComponent {
289
248
  });
290
249
  this.serverErrorFields = [];
291
250
  }
292
-
293
251
  const actionResult = button.action(this.data, button, errorReporter, this.dialogForm, this.buttons);
294
252
  button.inProgress = true;
295
253
  return this.$inject.$q.resolve(actionResult).then(res => {
296
254
  const dontClose = res === false;
297
-
298
255
  if (!dontClose && button.close !== false) {
299
256
  this.done(res);
300
257
  }
@@ -304,19 +261,15 @@ class DialogController extends RingAngularComponent {
304
261
  } else if (button.close !== false) {
305
262
  this.reset(false);
306
263
  }
307
-
308
264
  return undefined;
309
265
  }
310
-
311
266
  applyDefaultHandler(isTextAreaShortcut) {
312
267
  return event => {
313
268
  if (event.target.matches('textarea') !== isTextAreaShortcut || event.target.matches('button')) {
314
269
  return;
315
270
  }
316
-
317
271
  event.stopPropagation();
318
272
  event.preventDefault();
319
-
320
273
  if (this.dialogForm.$valid && this.buttons) {
321
274
  for (const button of this.buttons) {
322
275
  if (button.default && !button.hidden && !button.disabled) {
@@ -328,25 +281,19 @@ class DialogController extends RingAngularComponent {
328
281
  }
329
282
  };
330
283
  }
331
-
332
284
  }
333
-
334
285
  DialogController.$inject = [];
335
-
336
286
  _defineProperty(DialogController, "$inject", ['$scope', '$q', 'dialog', '$element', 'dialogInSidebar', '$compile', '$injector', '$controller', 'rgCompiler', '$sce']);
337
-
338
287
  class DialogService extends RingAngularComponent {
339
288
  constructor() {
340
- super(...arguments); // Binding proxy methods to a service instance
289
+ super(...arguments);
341
290
 
291
+ // Binding proxy methods to a service instance
342
292
  _defineProperty(this, "DIALOG_NAMESPACE", 'ring-dialog');
343
-
344
293
  _defineProperty(this, "fallbackDialog", null);
345
-
346
294
  _defineProperty(this, "unregister", () => {
347
295
  Reflect.deleteProperty(this, 'ctrl');
348
296
  });
349
-
350
297
  ['show', 'hide', 'update', 'done', 'reset'].forEach(key => {
351
298
  this[key] = function methodWrapper() {
352
299
  if (this.ctrl) {
@@ -360,57 +307,44 @@ class DialogService extends RingAngularComponent {
360
307
  }.bind(this);
361
308
  });
362
309
  }
363
-
364
310
  register(ctrl) {
365
311
  this.ctrl = ctrl;
366
312
  }
367
-
368
313
  }
369
-
370
314
  DialogService.$inject = [];
371
-
372
315
  _defineProperty(DialogService, "$inject", ['$log']);
373
-
374
316
  class DialogInSidebarService extends DialogService {
375
317
  constructor() {
376
318
  super(...arguments);
377
-
378
319
  _defineProperty(this, "DIALOG_NAMESPACE", 'ring-dialog-in-sidebar');
379
-
380
320
  this.fallbackDialog = this.$inject.dialog;
381
321
  }
382
-
383
322
  }
384
-
385
323
  DialogInSidebarService.$inject = [];
386
-
387
324
  _defineProperty(DialogInSidebarService, "$inject", [...DialogService.$inject, 'dialog']);
388
-
389
325
  function rgDialogDirective($timeout) {
390
326
  function link(scope, iElement, iAttrs, dialogCtrl) {
391
327
  const node = iElement[0];
392
328
  const dialogContainer = node.querySelector('*[data-anchor=dialog-container]');
393
329
  const dialogHeader = node.querySelector('*[data-anchor=dialog-header]');
394
- const dialogCustomFooter = node.querySelector('*[data-anchor=dialog-custom-footer-container]'); // Left for backward compatibility with existing templates that use data directly from scope
330
+ const dialogCustomFooter = node.querySelector('*[data-anchor=dialog-custom-footer-container]');
395
331
 
332
+ // Left for backward compatibility with existing templates that use data directly from scope
396
333
  scope.dialogForm = dialogCtrl.dialogForm;
397
-
398
334
  function setPosition(top, left) {
399
335
  Object.assign(dialogContainer.style, {
400
336
  top: `${top}px`,
401
337
  left: `${left}px`
402
338
  });
403
- } // Focus first input
404
-
339
+ }
405
340
 
341
+ // Focus first input
406
342
  function focusFirst() {
407
343
  const controls = Array.from(node.querySelectorAll('input,select,button,textarea,*[contentEditable=true]')).filter(inputNode => getStyles(inputNode).display !== 'none');
408
-
409
344
  if (controls.length) {
410
345
  controls[0].focus();
411
346
  }
412
347
  }
413
-
414
348
  function onMousemove(e) {
415
349
  e.preventDefault();
416
350
  const pageHeight = window.innerHeight;
@@ -420,25 +354,20 @@ function rgDialogDirective($timeout) {
420
354
  const maxLeft = pageWidth - clearance;
421
355
  const newTop = getRect(dialogHeader).top + e.movementY;
422
356
  const newLeft = getRect(dialogHeader).left + e.movementX;
423
-
424
357
  if (newTop > maxTop || newTop < clearance) {
425
358
  return;
426
359
  }
427
-
428
360
  if (newLeft > maxLeft || newLeft < clearance) {
429
361
  return;
430
362
  }
431
-
432
363
  const offsetY = parseFloat(dialogContainer.style.top) || 0;
433
364
  const offsetX = parseFloat(dialogContainer.style.left) || 0;
434
365
  setPosition(offsetY + e.movementY, offsetX + e.movementX);
435
366
  }
436
-
437
367
  function onMouseup() {
438
368
  document.removeEventListener('mousemove', onMousemove);
439
369
  document.removeEventListener('mouseup', onMouseup);
440
370
  }
441
-
442
371
  function onMousedown() {
443
372
  if (!dialogCtrl.inSidebar) {
444
373
  // Duct tape for all Ring 1.0 dropdown components inside
@@ -447,29 +376,26 @@ function rgDialogDirective($timeout) {
447
376
  document.addEventListener('mouseup', onMouseup);
448
377
  }
449
378
  }
450
-
451
379
  function onFocusin(e) {
452
380
  if (!node.contains(e.target) && e.target.classList.contains('ring-popup')) {
453
381
  e.preventDefault();
454
382
  focusFirst();
455
383
  }
456
384
  }
457
-
458
385
  function setCustomFooter(customFooterElem) {
459
386
  const placeholder = angular.element(dialogCustomFooter);
460
387
  const footer = angular.element(`<div class="${this.styles.footer}"></div>`).append(customFooterElem);
461
388
  placeholder.empty();
462
389
  placeholder.append(footer);
463
390
  }
464
-
465
391
  dialogCtrl.resetPosition = () => dialogContainer.removeAttribute('style');
466
-
467
392
  dialogCtrl.setCustomFooter = setCustomFooter;
468
393
  dialogHeader.addEventListener('mousedown', onMousedown);
469
394
  document.addEventListener('focusin', onFocusin);
470
- scope.$on('rgDialogContentLoaded', () => $timeout(focusFirst)); // Backward compatibility for youtrack (if they are using "content" property)
471
- // which is actually ng-include with $includeContentLoaded event in the end
395
+ scope.$on('rgDialogContentLoaded', () => $timeout(focusFirst));
472
396
 
397
+ // Backward compatibility for youtrack (if they are using "content" property)
398
+ // which is actually ng-include with $includeContentLoaded event in the end
473
399
  scope.$on('$includeContentLoaded', () => $timeout(focusFirst));
474
400
  scope.$on('dialog.hide', () => {
475
401
  angular.element(dialogCustomFooter).empty();
@@ -482,7 +408,6 @@ function rgDialogDirective($timeout) {
482
408
  window.removeEventListener('resize', setPosition);
483
409
  });
484
410
  }
485
-
486
411
  return {
487
412
  scope: {},
488
413
  controller: DialogController,
@@ -496,12 +421,10 @@ function rgDialogDirective($timeout) {
496
421
  link
497
422
  };
498
423
  }
499
-
500
424
  function rgDialogTitleDirective() {
501
425
  function link(scope, iElement, iAttrs, dialogCtrl) {
502
426
  dialogCtrl.setTitle(scope.title);
503
427
  }
504
-
505
428
  return {
506
429
  scope: {
507
430
  title: '@rgDialogTitle'
@@ -510,7 +433,6 @@ function rgDialogTitleDirective() {
510
433
  link
511
434
  };
512
435
  }
513
-
514
436
  function rgDialogFooterDirective() {
515
437
  function link(scope, iElement, iAttrs, dialogCtrl, transclude) {
516
438
  scope.$on('rgDialogContentLoaded', () => {
@@ -519,50 +441,43 @@ function rgDialogFooterDirective() {
519
441
  });
520
442
  });
521
443
  }
522
-
523
444
  return {
524
445
  require: '^rgDialog',
525
446
  transclude: true,
526
447
  link
527
448
  };
528
449
  }
529
-
530
450
  function rgDialogContentDirective($compile, $q) {
531
451
  return {
532
452
  link: function link(scope, iElement) {
533
453
  const element = iElement[0];
534
454
  let contentScope;
535
-
536
455
  function createIncludeNode() {
537
456
  const node = document.createElement('ng-include');
538
457
  node.setAttribute('src', 'dialog.content');
539
458
  return node;
540
459
  }
541
-
542
460
  function isOldDataAPI() {
543
461
  return scope.dialog.config.data;
544
462
  }
545
-
546
463
  function compileContent() {
547
464
  contentScope = scope.$new();
548
-
549
465
  if (angular.isDefined(scope.dialog.content)) {
550
466
  const templateNode = angular.element(createIncludeNode());
551
467
  element.appendChild(templateNode[0]);
552
468
  return $compile(templateNode)(contentScope)[0];
553
469
  }
554
-
555
470
  return $q.when(scope.dialog.compileTemplate()).then(compiledData => {
556
- const templateScope = isOldDataAPI() ? contentScope : scope.dialog.config.scope || contentScope; // XXX(maksimrv): We should put element to directive
471
+ const templateScope = isOldDataAPI() ? contentScope : scope.dialog.config.scope || contentScope;
472
+
473
+ // XXX(maksimrv): We should put element to directive
557
474
  // before link because some directives (shortcuts)
558
475
  // depends from global directives (shortcuts-app)
559
-
560
476
  angular.element(element).append(compiledData.element);
561
477
  compiledData.link(templateScope);
562
478
  scope.$broadcast('rgDialogContentLoaded');
563
479
  }).catch(angular.noop);
564
480
  }
565
-
566
481
  function destroy() {
567
482
  function cleanupElement(_element) {
568
483
  while (_element.childNodes.length) {
@@ -574,13 +489,11 @@ function rgDialogContentDirective($compile, $q) {
574
489
  angular.element(_element.childNodes[0]).remove();
575
490
  }
576
491
  }
577
-
578
492
  if (contentScope) {
579
493
  contentScope.$destroy();
580
494
  cleanupElement(element);
581
495
  }
582
496
  }
583
-
584
497
  scope.$on('dialog.hide', destroy);
585
498
  scope.$on('dialog.show', () => {
586
499
  destroy();
@@ -589,7 +502,6 @@ function rgDialogContentDirective($compile, $q) {
589
502
  }
590
503
  };
591
504
  }
592
-
593
505
  angularModule.directive('rgDialog', rgDialogDirective);
594
506
  angularModule.directive('rgDialogTitle', rgDialogTitleDirective);
595
507
  angularModule.directive('rgDialogFooter', rgDialogFooterDirective);