@ldmjs/ui 1.0.84 → 1.0.86

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/dist/index.js CHANGED
@@ -428,11 +428,13 @@ class BreadcrumbsComponent extends external_vue_property_decorator_.Vue {
428
428
  if (item.disabled) {
429
429
  return;
430
430
  }
431
- if (!this.$router) {
432
- /* eslint-disable no-console */
433
- console.error('Router is undefined');
431
+ if (this.$attrs.onOpen instanceof Function) {
432
+ this.$attrs.onOpen(item);
434
433
  return;
435
434
  }
435
+ if (!this.$router) {
436
+ throw new Error('Router is undefined');
437
+ }
436
438
  if (item.route) {
437
439
  this.$router.push(item.route);
438
440
  }
@@ -7738,10 +7740,8 @@ class DialogManager {
7738
7740
  }
7739
7741
  static alert(modal) {
7740
7742
  const modalInfo = {
7741
- title: modal.title,
7742
- content: modal.content,
7743
+ ...modal,
7743
7744
  type: ModalType.Alert,
7744
- hostObject: modal.hostObject,
7745
7745
  managerId: DialogManager._id,
7746
7746
  };
7747
7747
  return DialogManager.execAsync(modalInfo);
@@ -7750,7 +7750,6 @@ class DialogManager {
7750
7750
  const modalInfo = {
7751
7751
  ...modal,
7752
7752
  type: ModalType.Prompt,
7753
- hostObject: modal.hostObject,
7754
7753
  managerId: DialogManager._id,
7755
7754
  };
7756
7755
  return DialogManager.execAsync(modalInfo);
@@ -7758,10 +7757,8 @@ class DialogManager {
7758
7757
  static confirm(modal) {
7759
7758
  const modalInfo = {
7760
7759
  ...modal,
7761
- content: modal.text,
7762
7760
  type: ModalType.Confirm,
7763
7761
  closable: true,
7764
- hostObject: modal.hostObject,
7765
7762
  managerId: DialogManager._id,
7766
7763
  };
7767
7764
  return DialogManager.execAsync(modalInfo);
@@ -8119,39 +8116,61 @@ const dialog_minimized_exports_ = /*#__PURE__*/(0,exportHelper/* default */.A)(d
8119
8116
  /* harmony default export */ const dialog_minimized = (dialog_minimized_exports_);
8120
8117
  ;// ./src/ld-dialog/dialogs.ts
8121
8118
  class Dialog {
8122
- constructor(title, content) {
8123
- this.title = title;
8124
- this.content = content ?? '';
8119
+ constructor(data) {
8120
+ this.title = data.title;
8121
+ this.content = data.content;
8122
+ this.pressEnterAsOk = data.pressEnterAsOk !== false;
8123
+ this.pressEscAsCancel = data.pressEscAsCancel !== false;
8124
+ this.hostObject = data.hostObject;
8125
8125
  }
8126
8126
  }
8127
8127
  class AlertDialog extends Dialog {
8128
8128
  constructor(data) {
8129
- super(data.title, data.text);
8130
- this.hostObject = data.hostObject;
8129
+ super({
8130
+ title: data.title,
8131
+ content: data.text,
8132
+ pressEnterAsOk: data.pressEnterAsOk,
8133
+ pressEscAsCancel: data.pressEscAsCancel,
8134
+ hostObject: data.hostObject,
8135
+ });
8131
8136
  }
8132
8137
  }
8133
8138
  class PromptDialog extends Dialog {
8134
8139
  constructor(data) {
8135
- super(data.title, data.content);
8140
+ super({
8141
+ title: data.title,
8142
+ content: data.content,
8143
+ pressEnterAsOk: data.pressEnterAsOk,
8144
+ pressEscAsCancel: data.pressEscAsCancel,
8145
+ hostObject: data.hostObject,
8146
+ });
8136
8147
  this.width = data.width || '60%';
8137
- this.hostObject = data.hostObject;
8138
8148
  }
8139
8149
  }
8140
8150
  class ConfirmDialog extends Dialog {
8141
8151
  constructor(data) {
8142
- super(data.title);
8143
- this.title = data.title;
8144
- this.text = data.text;
8152
+ super({
8153
+ title: data.title,
8154
+ content: data.text,
8155
+ pressEnterAsOk: data.pressEnterAsOk,
8156
+ pressEscAsCancel: data.pressEscAsCancel,
8157
+ hostObject: data.hostObject,
8158
+ });
8145
8159
  this.okTitle = data.okTitle;
8146
8160
  this.cancelTitle = data.cancelTitle;
8147
8161
  this.okResult = data.okResult;
8148
8162
  this.cancelResult = data.cancelResult;
8149
- this.hostObject = data.hostObject;
8150
8163
  }
8151
8164
  }
8152
8165
  class InfoDialog extends Dialog {
8153
8166
  constructor(data) {
8154
- super(data.title);
8167
+ super({
8168
+ title: data.title,
8169
+ content: '',
8170
+ pressEnterAsOk: data.pressEnterAsOk,
8171
+ pressEscAsCancel: data.pressEscAsCancel,
8172
+ hostObject: data.hostObject,
8173
+ });
8155
8174
  this.component = data.component;
8156
8175
  this.componentProps = data.componentProps;
8157
8176
  this.width = data.width;
@@ -8162,13 +8181,18 @@ class InfoDialog extends Dialog {
8162
8181
  this.hideFooter = data.hideFooter;
8163
8182
  this.minimizable = data.minimizable;
8164
8183
  this.description = data.description;
8165
- this.hostObject = data.hostObject;
8166
8184
  this.help = data.help;
8167
8185
  }
8168
8186
  }
8169
8187
  class SelectDialog extends Dialog {
8170
8188
  constructor(data) {
8171
- super(data.title);
8189
+ super({
8190
+ title: data.title,
8191
+ content: '',
8192
+ pressEnterAsOk: data.pressEnterAsOk,
8193
+ pressEscAsCancel: data.pressEscAsCancel,
8194
+ hostObject: data.hostObject,
8195
+ });
8172
8196
  this.component = data.component;
8173
8197
  this.componentProps = data.componentProps;
8174
8198
  this.loading = data.loading;
@@ -8178,20 +8202,24 @@ class SelectDialog extends Dialog {
8178
8202
  this.selectAsOk = data.selectAsOk;
8179
8203
  this.okTitle = data.okTitle;
8180
8204
  this.cancelTitle = data.cancelTitle;
8181
- this.hostObject = data.hostObject;
8182
8205
  this.help = data.help;
8183
8206
  }
8184
8207
  }
8185
8208
  class CreateEditDialog extends Dialog {
8186
8209
  constructor(data) {
8187
- super(data.title);
8210
+ super({
8211
+ title: data.title,
8212
+ content: '',
8213
+ pressEnterAsOk: data.pressEnterAsOk,
8214
+ pressEscAsCancel: data.pressEscAsCancel,
8215
+ hostObject: data.hostObject,
8216
+ });
8188
8217
  this._isChanged = null;
8189
8218
  this.component = data.component;
8190
8219
  this.componentProps = {
8191
8220
  ...data.componentProps,
8192
8221
  setIsChangedCallback: this.setIsChangedCallback.bind(this),
8193
8222
  };
8194
- this.hostObject = data.hostObject;
8195
8223
  this.loading = data.loading;
8196
8224
  this.fullHeight = data.fullHeight;
8197
8225
  this.width = data.width;
@@ -8298,6 +8326,8 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8298
8326
  component: modalInfo.component,
8299
8327
  componentProps: modalInfo.componentProps,
8300
8328
  hostObject: modalInfo.hostObject,
8329
+ pressEnterAsOk: modalInfo.pressEnterAsOk,
8330
+ pressEscAsCancel: modalInfo.pressEscAsCancel,
8301
8331
  loading: modalInfo.loading,
8302
8332
  noModal: modalInfo.noModal,
8303
8333
  type: modalInfo.type,
@@ -8375,16 +8405,24 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8375
8405
  return;
8376
8406
  }
8377
8407
  if (e.key === 'Enter') {
8408
+ if (!modal.pressEnterAsOk) {
8409
+ return;
8410
+ }
8378
8411
  if (e.shiftKey) {
8379
8412
  return;
8380
8413
  }
8381
8414
  this.handleOk(modal);
8382
8415
  }
8383
8416
  if (e.key === 'Escape') {
8417
+ if (!modal.pressEscAsCancel) {
8418
+ return;
8419
+ }
8384
8420
  this.handleCancel(modal);
8385
8421
  }
8386
8422
  };
8387
- this.dialogListeners.set(modal, listenerHandler.bind(this));
8423
+ if (modal.pressEnterAsOk || modal.pressEscAsCancel) {
8424
+ this.dialogListeners.set(modal, listenerHandler.bind(this));
8425
+ }
8388
8426
  modal.el = el;
8389
8427
  if (this.isConfirmDialog(modal)) {
8390
8428
  const btnOk = modal.el.querySelector('#modalOk');
@@ -8483,6 +8521,7 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8483
8521
  resultSave = await resultSave;
8484
8522
  if (resultSave) {
8485
8523
  this.modalResult = resultSave;
8524
+ removeModal = true;
8486
8525
  }
8487
8526
  else {
8488
8527
  return;
@@ -8502,6 +8541,7 @@ let DialogComponent = class DialogComponent extends (0,external_vue_class_compon
8502
8541
  return;
8503
8542
  }
8504
8543
  this.modalResult = resultSave;
8544
+ removeModal = true;
8505
8545
  }
8506
8546
  }
8507
8547
  break;
@@ -27,6 +27,8 @@ export interface IModalInfo {
27
27
  processingDescription?: string | (() => string);
28
28
  el?: HTMLElement;
29
29
  managerId?: string;
30
+ pressEnterAsOk?: boolean;
31
+ pressEscAsCancel?: boolean;
30
32
  hostObject?: IHostObject;
31
33
  /**
32
34
  * Окно немодальное - это начит окно отображается поверх контента страницы и не ограничивает пользователя
@@ -95,32 +97,39 @@ export type ModalWindow = IModalWindow<IViewModel<number | string>>;
95
97
  export class Dialog {
96
98
  constructor(
97
99
  public title: string,
98
- public content?: string
100
+ public content?: string,
101
+ public pressEnterAsOk?: boolean,
102
+ public pressEscAsCancel?: boolean,
103
+ public hostObject?: IHostObject
99
104
  ) {}
100
105
  }
101
106
 
102
107
  export class AlertDialog extends Dialog {
103
- title: string;
104
- text: string;
105
- hostObject?: IHostObject;
106
- constructor(data: { title: string; text: string; hostObject?: IHostObject });
108
+ constructor(data: {
109
+ title: string;
110
+ text: string;
111
+ pressEnterAsOk?: boolean;
112
+ pressEscAsCancel?: boolean;
113
+ hostObject?: IHostObject;
114
+ });
107
115
  }
108
116
 
109
117
  export class PromptDialog extends Dialog {
110
- title: string;
111
118
  width?: string;
112
- hostObject?: IHostObject;
113
- constructor(data: { title: string; width?: string; hostObject?: IHostObject });
119
+ constructor(data: {
120
+ title: string;
121
+ width?: string;
122
+ pressEnterAsOk?: boolean;
123
+ pressEscAsCancel?: boolean;
124
+ hostObject?: IHostObject;
125
+ });
114
126
  }
115
127
 
116
128
  export class ConfirmDialog extends Dialog {
117
- title: string;
118
- text: string;
119
129
  okTitle?: string;
120
130
  cancelTitle?: string;
121
131
  okResult?: number | string | boolean;
122
132
  cancelResult?: number | string | boolean;
123
- hostObject?: IHostObject;
124
133
  constructor(data: {
125
134
  title: string;
126
135
  text: string;
@@ -128,12 +137,13 @@ export class ConfirmDialog extends Dialog {
128
137
  cancelTitle?: string;
129
138
  okResult?: number | string | boolean;
130
139
  cancelResult?: number | string | boolean;
140
+ pressEnterAsOk?: boolean;
141
+ pressEscAsCancel?: boolean;
131
142
  hostObject?: IHostObject;
132
143
  });
133
144
  }
134
145
 
135
146
  export class InfoDialog extends Dialog {
136
- title: string;
137
147
  component: string;
138
148
  componentProps: Record<string, unknown>;
139
149
  width?: string;
@@ -144,7 +154,6 @@ export class InfoDialog extends Dialog {
144
154
  hideFooter?: boolean;
145
155
  minimizable?: boolean;
146
156
  description?: string;
147
- hostObject?: IHostObject;
148
157
  help?: boolean;
149
158
  constructor(data: {
150
159
  title: string;
@@ -158,13 +167,14 @@ export class InfoDialog extends Dialog {
158
167
  hideFooter?: boolean;
159
168
  minimizable?: boolean;
160
169
  description?: string;
170
+ pressEnterAsOk?: boolean;
171
+ pressEscAsCancel?: boolean;
161
172
  hostObject?: IHostObject;
162
173
  help?: boolean;
163
174
  });
164
175
  }
165
176
 
166
- export class SelectDialog<T> {
167
- title: string;
177
+ export class SelectDialog<T> extends Dialog {
168
178
  component: string;
169
179
  componentProps: {
170
180
  disabledItems: Array<T | number | string>;
@@ -189,7 +199,6 @@ export class SelectDialog<T> {
189
199
  selectAsOk?: boolean;
190
200
  okTitle?: string;
191
201
  cancelTitle?: string;
192
- hostObject?: IHostObject;
193
202
  help?: boolean;
194
203
  constructor(data: {
195
204
  title: string;
@@ -210,19 +219,19 @@ export class SelectDialog<T> {
210
219
  selectAsOk?: boolean;
211
220
  okTitle?: string;
212
221
  cancelTitle?: string;
222
+ pressEnterAsOk?: boolean;
223
+ pressEscAsCancel?: boolean;
213
224
  hostObject?: IHostObject;
214
225
  help?: boolean;
215
226
  });
216
227
  }
217
228
 
218
- export class CreateEditDialog<T> {
219
- title: string;
229
+ export class CreateEditDialog<T> extends Dialog {
220
230
  component: string;
221
231
  componentProps: {
222
232
  model: T;
223
233
  [key: string]: unknown;
224
234
  };
225
- hostObject?: IHostObject;
226
235
  loading?: boolean;
227
236
  fullHeight?: boolean;
228
237
  width?: string | number;
@@ -255,7 +264,6 @@ export class CreateEditDialog<T> {
255
264
  model: T;
256
265
  [key: string]: unknown;
257
266
  };
258
- hostObject?: IHostObject;
259
267
  loading?: boolean;
260
268
  fullHeight?: boolean;
261
269
  width?: string | number;
@@ -280,6 +288,9 @@ export class CreateEditDialog<T> {
280
288
  noModal?: boolean;
281
289
  okTitle?: string;
282
290
  cancelTitle?: string;
291
+ pressEnterAsOk?: boolean;
292
+ pressEscAsCancel?: boolean;
293
+ hostObject?: IHostObject;
283
294
  help?: boolean;
284
295
  });
285
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldmjs/ui",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "description": "ldm ui",
5
5
  "main": "dist/index.js",
6
6
  "engines": {