@codingame/monaco-vscode-api 1.69.23 → 1.76.0-next.1

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/dialogs.js CHANGED
@@ -1,24 +1,24 @@
1
- import './polyfill.js';
1
+ import { n } from './polyfill.js';
2
2
  import './missing-services.js';
3
- import { _ as __decorate, a as __param, E as Emitter } from './workspace.js';
3
+ import { _ as __decorate, a as __param, E as Emitter } from './contextkey.js';
4
4
  import { h as IProductService, l as IWorkbenchEnvironmentService } from './services2.js';
5
- import { n, g as getServiceOverride$1, c as attachDialogStyler, B as ButtonBar, d as ButtonWithDescription } from './layout.js';
5
+ import { localize } from 'monaco-editor/esm/vs/nls.js';
6
+ import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
6
7
  import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
7
- import { Codicon, CSSIcon } from 'monaco-editor/esm/vs/base/common/codicons.js';
8
- import { Color } from 'monaco-editor/esm/vs/base/common/color.js';
8
+ import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
9
+ import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
10
+ import { g as getServiceOverride$1, B as ButtonBar, a as ButtonWithDescription } from './layout.js';
9
11
  import { isMacintosh, isLinux, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
10
12
  import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
11
13
  import { EventHelper, $, hide, addDisposableListener, EventType, clearNode, isAncestor, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
12
- import { localize } from 'monaco-editor/esm/vs/nls.js';
13
14
  import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
14
15
  import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
15
16
  import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
16
17
  import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
17
18
  import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
18
- import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
19
+ import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
19
20
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
20
21
  import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
21
- import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
22
22
  import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
23
23
  import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
24
24
  import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
@@ -26,10 +26,119 @@ import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dia
26
26
  import { DeferredPromise } from 'monaco-editor/esm/vs/base/common/async.js';
27
27
  import { o as onServicesInitialized } from './tools.js';
28
28
  import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
29
- const defaultOpts = {
30
- inputActiveOptionBorder: ( (Color.fromHex('#007ACC00'))),
31
- inputActiveOptionForeground: ( (Color.fromHex('#FFFFFF'))),
32
- inputActiveOptionBackground: ( (Color.fromHex('#0E639C50')))
29
+ function mnemonicButtonLabel(label, forceDisableMnemonics) {
30
+ if (isMacintosh || forceDisableMnemonics) {
31
+ return label.replace(/\(&&\w\)|&&/g, '');
32
+ }
33
+ if (isWindows) {
34
+ return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
35
+ }
36
+ return label.replace(/&&/g, '_');
37
+ }
38
+ var DialogKind;
39
+ ( ((function(DialogKind) {
40
+ DialogKind[DialogKind["Confirmation"] = 1] = "Confirmation";
41
+ DialogKind[DialogKind["Prompt"] = 2] = "Prompt";
42
+ DialogKind[DialogKind["Input"] = 3] = "Input";
43
+ })(DialogKind || (DialogKind = {}))));
44
+ class AbstractDialogHandler {
45
+ getConfirmationButtons(dialog) {
46
+ return this.getButtons(dialog, DialogKind.Confirmation);
47
+ }
48
+ getPromptButtons(dialog) {
49
+ return this.getButtons(dialog, DialogKind.Prompt);
50
+ }
51
+ getInputButtons(dialog) {
52
+ return this.getButtons(dialog, DialogKind.Input);
53
+ }
54
+ getButtons(dialog, kind) {
55
+ const buttons = [];
56
+ switch (kind) {
57
+ case DialogKind.Confirmation: {
58
+ const confirmationDialog = dialog;
59
+ if (confirmationDialog.primaryButton) {
60
+ buttons.push(confirmationDialog.primaryButton);
61
+ }
62
+ else {
63
+ buttons.push(( (localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"))));
64
+ }
65
+ if (confirmationDialog.cancelButton) {
66
+ buttons.push(confirmationDialog.cancelButton);
67
+ }
68
+ else {
69
+ buttons.push(( (localize('cancelButton', "Cancel"))));
70
+ }
71
+ break;
72
+ }
73
+ case DialogKind.Prompt: {
74
+ const promptDialog = dialog;
75
+ if (Array.isArray(promptDialog.buttons) && promptDialog.buttons.length > 0) {
76
+ buttons.push(...promptDialog.buttons.map(button => button.label));
77
+ }
78
+ if (promptDialog.cancelButton) {
79
+ if (promptDialog.cancelButton === true) {
80
+ buttons.push(( (localize('cancelButton', "Cancel"))));
81
+ }
82
+ else if (typeof promptDialog.cancelButton === 'string') {
83
+ buttons.push(promptDialog.cancelButton);
84
+ }
85
+ else {
86
+ if (promptDialog.cancelButton.label) {
87
+ buttons.push(promptDialog.cancelButton.label);
88
+ }
89
+ else {
90
+ buttons.push(( (localize('cancelButton', "Cancel"))));
91
+ }
92
+ }
93
+ }
94
+ if (buttons.length === 0) {
95
+ buttons.push(( (localize({ key: 'okButton', comment: ['&& denotes a mnemonic'] }, "&&OK"))));
96
+ }
97
+ break;
98
+ }
99
+ case DialogKind.Input: {
100
+ const inputDialog = dialog;
101
+ if (inputDialog.primaryButton) {
102
+ buttons.push(inputDialog.primaryButton);
103
+ }
104
+ else {
105
+ buttons.push(( (localize({ key: 'okButton', comment: ['&& denotes a mnemonic'] }, "&&OK"))));
106
+ }
107
+ if (inputDialog.cancelButton) {
108
+ buttons.push(inputDialog.cancelButton);
109
+ }
110
+ else {
111
+ buttons.push(( (localize('cancelButton', "Cancel"))));
112
+ }
113
+ break;
114
+ }
115
+ }
116
+ return buttons;
117
+ }
118
+ getDialogType(type) {
119
+ if (typeof type === 'string') {
120
+ return type;
121
+ }
122
+ if (typeof type === 'number') {
123
+ return (type === Severity.Info) ? 'info' : (type === Severity.Error) ? 'error' : (type === Severity.Warning) ? 'warning' : 'none';
124
+ }
125
+ return undefined;
126
+ }
127
+ async getPromptResult(prompt, buttonIndex, checkboxChecked) {
128
+ const promptButtons = [...(prompt.buttons ?? [])];
129
+ if (prompt.cancelButton && typeof prompt.cancelButton !== 'string' && typeof prompt.cancelButton !== 'boolean') {
130
+ promptButtons.push(prompt.cancelButton);
131
+ }
132
+ const result = await promptButtons[buttonIndex]?.run({ checkboxChecked });
133
+ return { result, checkboxChecked };
134
+ }
135
+ }
136
+ var css$1 = ".monaco-custom-toggle{border:1px solid transparent;border-radius:3px;box-sizing:border-box;cursor:pointer;float:left;height:20px;margin-left:2px;overflow:hidden;padding:1px;user-select:none;-webkit-user-select:none;width:20px}.monaco-custom-toggle:hover{background-color:var(--vscode-inputOption-hoverBackground)}.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle:hover{border:1px dashed var(--vscode-focusBorder)}.hc-black .monaco-custom-toggle,.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle,.hc-light .monaco-custom-toggle:hover{background:none}.monaco-custom-toggle.monaco-checkbox{background-size:16px!important;border:1px solid transparent;border-radius:3px;height:18px;margin-left:0;margin-right:9px;opacity:1;padding:0;width:18px}.monaco-custom-toggle.monaco-checkbox:not(.checked):before{visibility:hidden}";
137
+ n(css$1,{});
138
+ const unthemedToggleStyles = {
139
+ inputActiveOptionBorder: '#007ACC00',
140
+ inputActiveOptionForeground: '#FFFFFF',
141
+ inputActiveOptionBackground: '#0E639C50'
33
142
  };
34
143
  class Toggle extends Widget {
35
144
  constructor(opts) {
@@ -38,12 +147,12 @@ class Toggle extends Widget {
38
147
  this.onChange = this._onChange.event;
39
148
  this._onKeyDown = this._register(( (new Emitter())));
40
149
  this.onKeyDown = this._onKeyDown.event;
41
- this._opts = { ...defaultOpts, ...opts };
150
+ this._opts = opts;
42
151
  this._checked = this._opts.isChecked;
43
152
  const classes = ['monaco-custom-toggle'];
44
153
  if (this._opts.icon) {
45
154
  this._icon = this._opts.icon;
46
- classes.push(...CSSIcon.asClassNameArray(this._icon));
155
+ classes.push(...ThemeIcon.asClassNameArray(this._icon));
47
156
  }
48
157
  if (this._opts.actionClassName) {
49
158
  classes.push(...this._opts.actionClassName.split(' '));
@@ -68,7 +177,7 @@ class Toggle extends Widget {
68
177
  ev.preventDefault();
69
178
  }
70
179
  });
71
- this.ignoreGesture(this.domNode);
180
+ this._register(this.ignoreGesture(this.domNode));
72
181
  this.onkeydown(this.domNode, (keyboardEvent) => {
73
182
  if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
74
183
  this.checked = !this._checked;
@@ -97,33 +206,21 @@ class Toggle extends Widget {
97
206
  }
98
207
  setIcon(icon) {
99
208
  if (this._icon) {
100
- this.domNode.classList.remove(...CSSIcon.asClassNameArray(this._icon));
209
+ this.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));
101
210
  }
102
211
  this._icon = icon;
103
212
  if (this._icon) {
104
- this.domNode.classList.add(...CSSIcon.asClassNameArray(this._icon));
213
+ this.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));
105
214
  }
106
215
  }
107
216
  width() {
108
217
  return 2 + 2 + 2 + 16 ;
109
218
  }
110
- style(styles) {
111
- if (styles.inputActiveOptionBorder) {
112
- this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
113
- }
114
- if (styles.inputActiveOptionForeground) {
115
- this._opts.inputActiveOptionForeground = styles.inputActiveOptionForeground;
116
- }
117
- if (styles.inputActiveOptionBackground) {
118
- this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
119
- }
120
- this.applyStyles();
121
- }
122
219
  applyStyles() {
123
220
  if (this.domNode) {
124
- this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? ( (this._opts.inputActiveOptionBorder.toString())) : '';
125
- this.domNode.style.color = this._checked && this._opts.inputActiveOptionForeground ? ( (this._opts.inputActiveOptionForeground.toString())) : 'inherit';
126
- this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? ( (this._opts.inputActiveOptionBackground.toString())) : '';
221
+ this.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';
222
+ this.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';
223
+ this.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';
127
224
  }
128
225
  }
129
226
  enable() {
@@ -138,18 +235,17 @@ class Toggle extends Widget {
138
235
  }
139
236
  }
140
237
  class Checkbox extends Widget {
141
- constructor(title, isChecked) {
238
+ constructor(title, isChecked, styles) {
142
239
  super();
143
240
  this.title = title;
144
241
  this.isChecked = isChecked;
145
242
  this.checkbox = ( (new Toggle(
146
- { title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox' }
243
+ { title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox', ...unthemedToggleStyles }
147
244
  )));
148
245
  this.domNode = this.checkbox.domNode;
149
- this.styles = {};
150
- this.checkbox.onChange(() => {
151
- this.applyStyles();
152
- });
246
+ this.styles = styles;
247
+ this.applyStyles();
248
+ this._register(this.checkbox.onChange(() => this.applyStyles()));
153
249
  }
154
250
  get checked() {
155
251
  return this.checkbox.checked;
@@ -164,26 +260,213 @@ class Checkbox extends Widget {
164
260
  hasFocus() {
165
261
  return this.domNode === document.activeElement;
166
262
  }
167
- style(styles) {
168
- this.styles = styles;
169
- this.applyStyles();
170
- }
171
263
  applyStyles() {
172
- this.domNode.style.color = this.styles.checkboxForeground ? ( (this.styles.checkboxForeground.toString())) : '';
173
- this.domNode.style.backgroundColor = this.styles.checkboxBackground ? ( (this.styles.checkboxBackground.toString())) : '';
174
- this.domNode.style.borderColor = this.styles.checkboxBorder ? ( (this.styles.checkboxBorder.toString())) : '';
264
+ this.domNode.style.color = this.styles.checkboxForeground || '';
265
+ this.domNode.style.backgroundColor = this.styles.checkboxBackground || '';
266
+ this.domNode.style.borderColor = this.styles.checkboxBorder || '';
175
267
  }
176
268
  }
177
- function mnemonicButtonLabel(label, forceDisableMnemonics) {
178
- if (isMacintosh || forceDisableMnemonics) {
179
- return label.replace(/\(&&\w\)|&&/g, '');
269
+ const minute = 60;
270
+ const hour = minute * 60;
271
+ const day = hour * 24;
272
+ const week = day * 7;
273
+ const month = day * 30;
274
+ const year = day * 365;
275
+ function fromNow(date, appendAgoLabel, useFullTimeWords, disallowNow) {
276
+ if (typeof date !== 'number') {
277
+ date = date.getTime();
180
278
  }
181
- if (isWindows) {
182
- return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
279
+ const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
280
+ if (seconds < -30) {
281
+ return (
282
+ (localize(
283
+ 'date.fromNow.in',
284
+ 'in {0}',
285
+ fromNow(( (new Date())).getTime() + seconds * 1000, false)
286
+ ))
287
+ );
288
+ }
289
+ if (!disallowNow && seconds < 30) {
290
+ return (
291
+ (localize('date.fromNow.now', 'now'))
292
+ );
293
+ }
294
+ let value;
295
+ if (seconds < minute) {
296
+ value = seconds;
297
+ if (appendAgoLabel) {
298
+ if (value === 1) {
299
+ return useFullTimeWords
300
+ ? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
301
+ : ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
302
+ }
303
+ else {
304
+ return useFullTimeWords
305
+ ? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
306
+ : ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
307
+ }
308
+ }
309
+ else {
310
+ if (value === 1) {
311
+ return useFullTimeWords
312
+ ? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
313
+ : ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
314
+ }
315
+ else {
316
+ return useFullTimeWords
317
+ ? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
318
+ : ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
319
+ }
320
+ }
321
+ }
322
+ if (seconds < hour) {
323
+ value = Math.floor(seconds / minute);
324
+ if (appendAgoLabel) {
325
+ if (value === 1) {
326
+ return useFullTimeWords
327
+ ? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
328
+ : ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
329
+ }
330
+ else {
331
+ return useFullTimeWords
332
+ ? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
333
+ : ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
334
+ }
335
+ }
336
+ else {
337
+ if (value === 1) {
338
+ return useFullTimeWords
339
+ ? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
340
+ : ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
341
+ }
342
+ else {
343
+ return useFullTimeWords
344
+ ? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
345
+ : ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
346
+ }
347
+ }
348
+ }
349
+ if (seconds < day) {
350
+ value = Math.floor(seconds / hour);
351
+ if (appendAgoLabel) {
352
+ if (value === 1) {
353
+ return useFullTimeWords
354
+ ? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
355
+ : ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
356
+ }
357
+ else {
358
+ return useFullTimeWords
359
+ ? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
360
+ : ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
361
+ }
362
+ }
363
+ else {
364
+ if (value === 1) {
365
+ return useFullTimeWords
366
+ ? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
367
+ : ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
368
+ }
369
+ else {
370
+ return useFullTimeWords
371
+ ? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
372
+ : ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
373
+ }
374
+ }
375
+ }
376
+ if (seconds < week) {
377
+ value = Math.floor(seconds / day);
378
+ if (appendAgoLabel) {
379
+ return value === 1
380
+ ? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
381
+ : ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
382
+ }
383
+ else {
384
+ return value === 1
385
+ ? ( (localize('date.fromNow.days.singular', '{0} day', value)))
386
+ : ( (localize('date.fromNow.days.plural', '{0} days', value)));
387
+ }
388
+ }
389
+ if (seconds < month) {
390
+ value = Math.floor(seconds / week);
391
+ if (appendAgoLabel) {
392
+ if (value === 1) {
393
+ return useFullTimeWords
394
+ ? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
395
+ : ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
396
+ }
397
+ else {
398
+ return useFullTimeWords
399
+ ? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
400
+ : ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
401
+ }
402
+ }
403
+ else {
404
+ if (value === 1) {
405
+ return useFullTimeWords
406
+ ? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
407
+ : ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
408
+ }
409
+ else {
410
+ return useFullTimeWords
411
+ ? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
412
+ : ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
413
+ }
414
+ }
415
+ }
416
+ if (seconds < year) {
417
+ value = Math.floor(seconds / month);
418
+ if (appendAgoLabel) {
419
+ if (value === 1) {
420
+ return useFullTimeWords
421
+ ? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
422
+ : ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
423
+ }
424
+ else {
425
+ return useFullTimeWords
426
+ ? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
427
+ : ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
428
+ }
429
+ }
430
+ else {
431
+ if (value === 1) {
432
+ return useFullTimeWords
433
+ ? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
434
+ : ( (localize('date.fromNow.months.singular', '{0} mo', value)));
435
+ }
436
+ else {
437
+ return useFullTimeWords
438
+ ? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
439
+ : ( (localize('date.fromNow.months.plural', '{0} mos', value)));
440
+ }
441
+ }
442
+ }
443
+ value = Math.floor(seconds / year);
444
+ if (appendAgoLabel) {
445
+ if (value === 1) {
446
+ return useFullTimeWords
447
+ ? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
448
+ : ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
449
+ }
450
+ else {
451
+ return useFullTimeWords
452
+ ? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
453
+ : ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
454
+ }
455
+ }
456
+ else {
457
+ if (value === 1) {
458
+ return useFullTimeWords
459
+ ? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
460
+ : ( (localize('date.fromNow.years.singular', '{0} yr', value)));
461
+ }
462
+ else {
463
+ return useFullTimeWords
464
+ ? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
465
+ : ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
466
+ }
183
467
  }
184
- return label.replace(/&&/g, '_');
185
468
  }
186
- var css = "/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\n/** Dialog: Modal Block */\n.monaco-dialog-modal-block {\n\tposition: fixed;\n\theight: 100%;\n\twidth: 100%;\n\tleft:0;\n\ttop:0;\n\tz-index: 2600;\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n}\n\n.monaco-dialog-modal-block.dimmed {\n\tbackground: rgba(0, 0, 0, 0.3);\n}\n\n/** Dialog: Container */\n.monaco-dialog-box {\n\tdisplay: flex;\n\tflex-direction: column-reverse;\n\twidth: min-content;\n\tmin-width: 500px;\n\tmax-width: 90vw;\n\tmin-height: 75px;\n\tpadding: 10px;\n\ttransform: translate3d(0px, 0px, 0px);\n}\n\n/** Dialog: Title Actions Row */\n.monaco-dialog-box .dialog-toolbar-row {\n\theight: 22px;\n\tpadding-bottom: 4px;\n}\n\n.monaco-dialog-box .dialog-toolbar-row .actions-container {\n\tjustify-content: flex-end;\n}\n\n/** Dialog: Message Row */\n.monaco-dialog-box .dialog-message-row {\n\tdisplay: flex;\n\tflex-grow: 1;\n\talign-items: center;\n\tpadding: 0 10px;\n}\n\n.monaco-dialog-box .dialog-message-row > .dialog-icon.codicon {\n\tflex: 0 0 48px;\n\theight: 48px;\n\talign-self: baseline;\n\tfont-size: 48px;\n}\n\n/** Dialog: Message Container */\n.monaco-dialog-box .dialog-message-row .dialog-message-container {\n\tdisplay: flex;\n\tflex-direction: column;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tpadding-left: 24px;\n\tuser-select: text;\n\t-webkit-user-select: text;\n\t-ms-user-select: text;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\twhite-space: normal;\n}\n\n/** Dialog: Message */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message {\n\tline-height: 22px;\n\tfont-size: 18px;\n\tflex: 1; /* let the message always grow */\n\twhite-space: normal;\n\tword-wrap: break-word; /* never overflow long words, but break to next line */\n\tmin-height: 48px; /* matches icon height */\n\tmargin-bottom: 8px;\n\tdisplay: flex;\n\talign-items: center;\n}\n\n/** Dialog: Details */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail {\n\tline-height: 22px;\n\tflex: 1; /* let the message always grow */\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus {\n\toutline-width: 1px;\n\toutline-style: solid;\n}\n\n/** Dialog: Checkbox */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message {\n\tcursor: pointer;\n\tuser-select: none;\n\t-webkit-user-select: none;\n\t-ms-user-select: none;\n}\n\n/** Dialog: Input */\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input {\n\tpadding: 15px 0px 0px;\n\tdisplay: flex;\n}\n\n.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox {\n\tflex: 1;\n}\n\n/** Dialog: File Path */\n.monaco-dialog-box code {\n\tfont-family: var(--monaco-monospace-font);\n}\n\n/** Dialog: Buttons Row */\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\talign-items: center;\n\tpadding-right: 1px;\n\toverflow: hidden; /* buttons row should never overflow */\n}\n\n.monaco-dialog-box > .dialog-buttons-row {\n\tdisplay: flex;\n\twhite-space: nowrap;\n\tpadding: 20px 10px 10px;\n}\n\n/** Dialog: Buttons */\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons {\n\tdisplay: flex;\n\twidth: 100%;\n\tjustify-content: flex-end;\n\toverflow: hidden;\n\tmargin-left: 67px; /* for long buttons, force align with text */\n}\n\n.monaco-dialog-box > .dialog-buttons-row > .dialog-buttons > .monaco-button {\n\twidth: fit-content;\n\twidth: -moz-fit-content;\n\tpadding: 5px 10px;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tmargin: 4px 5px; /* allows button focus outline to be visible */\n\toutline-offset: 2px !important;\n}\n";
469
+ var css = ".monaco-dialog-modal-block{align-items:center;display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:2600}.monaco-dialog-modal-block.dimmed{background:rgba(0,0,0,.3)}.monaco-dialog-box{display:flex;flex-direction:column-reverse;max-width:90vw;min-height:75px;min-width:500px;padding:10px;transform:translateZ(0);width:min-content}.monaco-dialog-box .dialog-toolbar-row{height:22px;padding-bottom:4px}.monaco-dialog-box .dialog-toolbar-row .actions-container{justify-content:flex-end}.monaco-dialog-box .dialog-message-row{align-items:center;display:flex;flex-grow:1;padding:0 10px}.monaco-dialog-box .dialog-message-row>.dialog-icon.codicon{align-self:baseline;flex:0 0 48px;font-size:48px;height:48px}.monaco-dialog-box .dialog-message-row .dialog-message-container{word-wrap:break-word;display:flex;flex-direction:column;overflow:hidden;padding-left:24px;text-overflow:ellipsis;user-select:text;-webkit-user-select:text;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message{word-wrap:break-word;align-items:center;display:flex;flex:1;font-size:18px;line-height:22px;margin-bottom:8px;min-height:48px;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail{flex:1;line-height:22px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus{outline-style:solid;outline-width:1px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message{cursor:pointer;user-select:none;-webkit-user-select:none}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox{flex:1}.monaco-dialog-box code{font-family:var(--monaco-monospace-font)}.monaco-dialog-box>.dialog-buttons-row{align-items:center;display:flex;overflow:hidden;padding-right:1px;padding:20px 10px 10px;white-space:nowrap}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons{display:flex;justify-content:flex-end;margin-left:67px;overflow:hidden;width:100%}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons>.monaco-button{margin:4px 5px;outline-offset:2px!important;overflow:hidden;padding:5px 10px;text-overflow:ellipsis;width:fit-content}";
187
470
  n(css,{});
188
471
  class Dialog extends Disposable {
189
472
  constructor(container, message, buttons, options) {
@@ -197,6 +480,7 @@ class Dialog extends Disposable {
197
480
  this.element.setAttribute('role', 'dialog');
198
481
  this.element.tabIndex = -1;
199
482
  hide(this.element);
483
+ this.buttonStyles = options.buttonStyles;
200
484
  if (Array.isArray(buttons) && buttons.length > 0) {
201
485
  this.buttons = buttons;
202
486
  }
@@ -237,6 +521,7 @@ class Dialog extends Disposable {
237
521
  const inputBox = this._register(( (new InputBox(inputRowElement, undefined, {
238
522
  placeholder: input.placeholder,
239
523
  type: input.type ?? 'text',
524
+ inputBoxStyles: options.inputBoxStyles
240
525
  }))));
241
526
  if (input.value) {
242
527
  inputBox.value = input.value;
@@ -249,7 +534,11 @@ class Dialog extends Disposable {
249
534
  }
250
535
  if (this.options.checkboxLabel) {
251
536
  const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
252
- const checkbox = this.checkbox = this._register(( (new Checkbox(this.options.checkboxLabel, !!this.options.checkboxChecked))));
537
+ const checkbox = this.checkbox = this._register(( (new Checkbox(
538
+ this.options.checkboxLabel,
539
+ !!this.options.checkboxChecked,
540
+ options.checkboxStyles
541
+ ))));
253
542
  checkboxRowElement.appendChild(checkbox.domNode);
254
543
  const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
255
544
  checkboxMessageElement.innerText = this.options.checkboxLabel;
@@ -257,6 +546,7 @@ class Dialog extends Disposable {
257
546
  }
258
547
  const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
259
548
  this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
549
+ this.applyStyles();
260
550
  }
261
551
  getIconAriaLabel() {
262
552
  const typeLabel = ( (localize('dialogInfoMessage', 'Info')));
@@ -274,7 +564,7 @@ class Dialog extends Disposable {
274
564
  const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
275
565
  buttonMap.forEach((entry, index) => {
276
566
  const primary = buttonMap[index].index === 0;
277
- const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary })) : this._register(buttonBar.addButton({ title: true, secondary: !primary }));
567
+ const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary, ...this.buttonStyles })) : this._register(buttonBar.addButton({ title: true, secondary: !primary, ...this.buttonStyles }));
278
568
  button.label = mnemonicButtonLabel(buttonMap[index].label, true);
279
569
  if (button instanceof ButtonWithDescription) {
280
570
  button.description = this.options.buttonDetails[buttonMap[index].index];
@@ -390,26 +680,26 @@ class Dialog extends Disposable {
390
680
  }
391
681
  }, false));
392
682
  const spinModifierClassName = 'codicon-modifier-spin';
393
- this.iconElement.classList.remove(...Codicon.dialogError.classNamesArray, ...Codicon.dialogWarning.classNamesArray, ...Codicon.dialogInfo.classNamesArray, ...Codicon.loading.classNamesArray, spinModifierClassName);
683
+ this.iconElement.classList.remove(...ThemeIcon.asClassNameArray(Codicon.dialogError), ...ThemeIcon.asClassNameArray(Codicon.dialogWarning), ...ThemeIcon.asClassNameArray(Codicon.dialogInfo), ...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
394
684
  if (this.options.icon) {
395
- this.iconElement.classList.add(...this.options.icon.classNamesArray);
685
+ this.iconElement.classList.add(...ThemeIcon.asClassNameArray(this.options.icon));
396
686
  }
397
687
  else {
398
688
  switch (this.options.type) {
399
689
  case 'error':
400
- this.iconElement.classList.add(...Codicon.dialogError.classNamesArray);
690
+ this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogError));
401
691
  break;
402
692
  case 'warning':
403
- this.iconElement.classList.add(...Codicon.dialogWarning.classNamesArray);
693
+ this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogWarning));
404
694
  break;
405
695
  case 'pending':
406
- this.iconElement.classList.add(...Codicon.loading.classNamesArray, spinModifierClassName);
696
+ this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
407
697
  break;
408
698
  case 'none':
409
699
  case 'info':
410
700
  case 'question':
411
701
  default:
412
- this.iconElement.classList.add(...Codicon.dialogInfo.classNamesArray);
702
+ this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogInfo));
413
703
  break;
414
704
  }
415
705
  }
@@ -418,351 +708,151 @@ class Dialog extends Disposable {
418
708
  const action = this._register(( (new Action(
419
709
  'dialog.close',
420
710
  (localize('dialogClose', "Close Dialog")),
421
- Codicon.dialogClose.classNames,
711
+ ThemeIcon.asClassName(Codicon.dialogClose),
422
712
  true,
423
713
  async () => {
424
- resolve({
425
- button: this.options.cancelId || 0,
426
- checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
427
- });
428
- }
429
- ))));
430
- actionBar.push(action, { icon: true, label: false, });
431
- }
432
- this.applyStyles();
433
- this.element.setAttribute('aria-modal', 'true');
434
- this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
435
- this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
436
- show(this.element);
437
- if (this.inputs.length > 0) {
438
- this.inputs[0].focus();
439
- this.inputs[0].select();
440
- }
441
- else {
442
- buttonMap.forEach((value, index) => {
443
- if (value.index === 0) {
444
- buttonBar.buttons[index].focus();
445
- }
446
- });
447
- }
448
- }))
449
- );
450
- }
451
- applyStyles() {
452
- if (this.styles) {
453
- const style = this.styles;
454
- const fgColor = style.dialogForeground;
455
- const bgColor = style.dialogBackground;
456
- const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
457
- const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
458
- const linkFgColor = style.textLinkForeground;
459
- this.shadowElement.style.boxShadow = shadowColor;
460
- this.element.style.color = fgColor?.toString() ?? '';
461
- this.element.style.backgroundColor = bgColor?.toString() ?? '';
462
- this.element.style.border = border;
463
- this.buttonBar?.buttons.forEach(button => button.style(style));
464
- this.checkbox?.style(style);
465
- if (fgColor && bgColor) {
466
- const messageDetailColor = ( (fgColor.transparent(.9)));
467
- this.messageDetailElement.style.color = ( (messageDetailColor.makeOpaque(bgColor).toString()));
468
- }
469
- if (linkFgColor) {
470
- for (const el of this.messageContainer.getElementsByTagName('a')) {
471
- el.style.color = ( (linkFgColor.toString()));
472
- }
473
- }
474
- let color;
475
- switch (this.options.type) {
476
- case 'error':
477
- color = style.errorIconForeground;
478
- break;
479
- case 'warning':
480
- color = style.warningIconForeground;
481
- break;
482
- default:
483
- color = style.infoIconForeground;
484
- break;
485
- }
486
- if (color) {
487
- this.iconElement.style.color = ( (color.toString()));
488
- }
489
- for (const input of this.inputs) {
490
- input.style(style);
491
- }
492
- }
493
- }
494
- style(style) {
495
- this.styles = style;
496
- this.applyStyles();
497
- }
498
- dispose() {
499
- super.dispose();
500
- if (this.modalElement) {
501
- this.modalElement.remove();
502
- this.modalElement = undefined;
503
- }
504
- if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
505
- this.focusToReturn.focus();
506
- this.focusToReturn = undefined;
507
- }
508
- }
509
- rearrangeButtons(buttons, cancelId) {
510
- const buttonMap = [];
511
- if (buttons.length === 0) {
512
- return buttonMap;
513
- }
514
- buttons.forEach((button, index) => {
515
- buttonMap.push({ label: button, index });
516
- });
517
- if (isMacintosh || isLinux) {
518
- if (cancelId !== undefined && cancelId < buttons.length) {
519
- const cancelButton = buttonMap.splice(cancelId, 1)[0];
520
- buttonMap.reverse();
521
- buttonMap.splice(buttonMap.length - 1, 0, cancelButton);
522
- }
523
- }
524
- return buttonMap;
525
- }
526
- }
527
- const minute = 60;
528
- const hour = minute * 60;
529
- const day = hour * 24;
530
- const week = day * 7;
531
- const month = day * 30;
532
- const year = day * 365;
533
- function fromNow(date, appendAgoLabel, useFullTimeWords) {
534
- if (typeof date !== 'number') {
535
- date = date.getTime();
536
- }
537
- const seconds = Math.round((( (new Date())).getTime() - date) / 1000);
538
- if (seconds < -30) {
539
- return (
540
- (localize(
541
- 'date.fromNow.in',
542
- 'in {0}',
543
- fromNow(( (new Date())).getTime() + seconds * 1000, false)
544
- ))
545
- );
546
- }
547
- if (seconds < 30) {
548
- return (
549
- (localize('date.fromNow.now', 'now'))
714
+ resolve({
715
+ button: this.options.cancelId || 0,
716
+ checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
717
+ });
718
+ }
719
+ ))));
720
+ actionBar.push(action, { icon: true, label: false });
721
+ }
722
+ this.applyStyles();
723
+ this.element.setAttribute('aria-modal', 'true');
724
+ this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
725
+ this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
726
+ show(this.element);
727
+ if (this.inputs.length > 0) {
728
+ this.inputs[0].focus();
729
+ this.inputs[0].select();
730
+ }
731
+ else {
732
+ buttonMap.forEach((value, index) => {
733
+ if (value.index === 0) {
734
+ buttonBar.buttons[index].focus();
735
+ }
736
+ });
737
+ }
738
+ }))
550
739
  );
551
740
  }
552
- let value;
553
- if (seconds < minute) {
554
- value = seconds;
555
- if (appendAgoLabel) {
556
- if (value === 1) {
557
- return useFullTimeWords
558
- ? ( (localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value)))
559
- : ( (localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value)));
560
- }
561
- else {
562
- return useFullTimeWords
563
- ? ( (localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value)))
564
- : ( (localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value)));
565
- }
566
- }
567
- else {
568
- if (value === 1) {
569
- return useFullTimeWords
570
- ? ( (localize('date.fromNow.seconds.singular.fullWord', '{0} second', value)))
571
- : ( (localize('date.fromNow.seconds.singular', '{0} sec', value)));
572
- }
573
- else {
574
- return useFullTimeWords
575
- ? ( (localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value)))
576
- : ( (localize('date.fromNow.seconds.plural', '{0} secs', value)));
577
- }
578
- }
579
- }
580
- if (seconds < hour) {
581
- value = Math.floor(seconds / minute);
582
- if (appendAgoLabel) {
583
- if (value === 1) {
584
- return useFullTimeWords
585
- ? ( (localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value)))
586
- : ( (localize('date.fromNow.minutes.singular.ago', '{0} min ago', value)));
587
- }
588
- else {
589
- return useFullTimeWords
590
- ? ( (localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value)))
591
- : ( (localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value)));
592
- }
593
- }
594
- else {
595
- if (value === 1) {
596
- return useFullTimeWords
597
- ? ( (localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value)))
598
- : ( (localize('date.fromNow.minutes.singular', '{0} min', value)));
599
- }
600
- else {
601
- return useFullTimeWords
602
- ? ( (localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value)))
603
- : ( (localize('date.fromNow.minutes.plural', '{0} mins', value)));
741
+ applyStyles() {
742
+ const style = this.options.dialogStyles;
743
+ const fgColor = style.dialogForeground;
744
+ const bgColor = style.dialogBackground;
745
+ const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
746
+ const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
747
+ const linkFgColor = style.textLinkForeground;
748
+ this.shadowElement.style.boxShadow = shadowColor;
749
+ this.element.style.color = fgColor ?? '';
750
+ this.element.style.backgroundColor = bgColor ?? '';
751
+ this.element.style.border = border;
752
+ if (linkFgColor) {
753
+ for (const el of this.messageContainer.getElementsByTagName('a')) {
754
+ el.style.color = linkFgColor;
604
755
  }
605
756
  }
606
- }
607
- if (seconds < day) {
608
- value = Math.floor(seconds / hour);
609
- if (appendAgoLabel) {
610
- if (value === 1) {
611
- return useFullTimeWords
612
- ? ( (localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value)))
613
- : ( (localize('date.fromNow.hours.singular.ago', '{0} hr ago', value)));
614
- }
615
- else {
616
- return useFullTimeWords
617
- ? ( (localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value)))
618
- : ( (localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value)));
619
- }
757
+ let color;
758
+ switch (this.options.type) {
759
+ case 'error':
760
+ color = style.errorIconForeground;
761
+ break;
762
+ case 'warning':
763
+ color = style.warningIconForeground;
764
+ break;
765
+ default:
766
+ color = style.infoIconForeground;
767
+ break;
620
768
  }
621
- else {
622
- if (value === 1) {
623
- return useFullTimeWords
624
- ? ( (localize('date.fromNow.hours.singular.fullWord', '{0} hour', value)))
625
- : ( (localize('date.fromNow.hours.singular', '{0} hr', value)));
626
- }
627
- else {
628
- return useFullTimeWords
629
- ? ( (localize('date.fromNow.hours.plural.fullWord', '{0} hours', value)))
630
- : ( (localize('date.fromNow.hours.plural', '{0} hrs', value)));
631
- }
769
+ if (color) {
770
+ this.iconElement.style.color = color;
632
771
  }
633
772
  }
634
- if (seconds < week) {
635
- value = Math.floor(seconds / day);
636
- if (appendAgoLabel) {
637
- return value === 1
638
- ? ( (localize('date.fromNow.days.singular.ago', '{0} day ago', value)))
639
- : ( (localize('date.fromNow.days.plural.ago', '{0} days ago', value)));
773
+ dispose() {
774
+ super.dispose();
775
+ if (this.modalElement) {
776
+ this.modalElement.remove();
777
+ this.modalElement = undefined;
640
778
  }
641
- else {
642
- return value === 1
643
- ? ( (localize('date.fromNow.days.singular', '{0} day', value)))
644
- : ( (localize('date.fromNow.days.plural', '{0} days', value)));
779
+ if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
780
+ this.focusToReturn.focus();
781
+ this.focusToReturn = undefined;
645
782
  }
646
783
  }
647
- if (seconds < month) {
648
- value = Math.floor(seconds / week);
649
- if (appendAgoLabel) {
650
- if (value === 1) {
651
- return useFullTimeWords
652
- ? ( (localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value)))
653
- : ( (localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value)));
654
- }
655
- else {
656
- return useFullTimeWords
657
- ? ( (localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value)))
658
- : ( (localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value)));
659
- }
660
- }
661
- else {
662
- if (value === 1) {
663
- return useFullTimeWords
664
- ? ( (localize('date.fromNow.weeks.singular.fullWord', '{0} week', value)))
665
- : ( (localize('date.fromNow.weeks.singular', '{0} wk', value)));
666
- }
667
- else {
668
- return useFullTimeWords
669
- ? ( (localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value)))
670
- : ( (localize('date.fromNow.weeks.plural', '{0} wks', value)));
671
- }
784
+ rearrangeButtons(buttons, cancelId) {
785
+ const buttonMap = buttons.map((label, index) => ({ label, index }));
786
+ if (buttons.length < 2) {
787
+ return buttonMap;
672
788
  }
673
- }
674
- if (seconds < year) {
675
- value = Math.floor(seconds / month);
676
- if (appendAgoLabel) {
677
- if (value === 1) {
678
- return useFullTimeWords
679
- ? ( (localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value)))
680
- : ( (localize('date.fromNow.months.singular.ago', '{0} mo ago', value)));
681
- }
682
- else {
683
- return useFullTimeWords
684
- ? ( (localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value)))
685
- : ( (localize('date.fromNow.months.plural.ago', '{0} mos ago', value)));
789
+ if (isMacintosh || isLinux) {
790
+ if (typeof cancelId === 'number' && buttonMap[cancelId]) {
791
+ const cancelButton = buttonMap.splice(cancelId, 1)[0];
792
+ buttonMap.splice(1, 0, cancelButton);
686
793
  }
794
+ buttonMap.reverse();
687
795
  }
688
- else {
689
- if (value === 1) {
690
- return useFullTimeWords
691
- ? ( (localize('date.fromNow.months.singular.fullWord', '{0} month', value)))
692
- : ( (localize('date.fromNow.months.singular', '{0} mo', value)));
693
- }
694
- else {
695
- return useFullTimeWords
696
- ? ( (localize('date.fromNow.months.plural.fullWord', '{0} months', value)))
697
- : ( (localize('date.fromNow.months.plural', '{0} mos', value)));
796
+ else if (isWindows) {
797
+ if (typeof cancelId === 'number' && buttonMap[cancelId]) {
798
+ const cancelButton = buttonMap.splice(cancelId, 1)[0];
799
+ buttonMap.push(cancelButton);
698
800
  }
699
801
  }
700
- }
701
- value = Math.floor(seconds / year);
702
- if (appendAgoLabel) {
703
- if (value === 1) {
704
- return useFullTimeWords
705
- ? ( (localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value)))
706
- : ( (localize('date.fromNow.years.singular.ago', '{0} yr ago', value)));
707
- }
708
- else {
709
- return useFullTimeWords
710
- ? ( (localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value)))
711
- : ( (localize('date.fromNow.years.plural.ago', '{0} yrs ago', value)));
712
- }
713
- }
714
- else {
715
- if (value === 1) {
716
- return useFullTimeWords
717
- ? ( (localize('date.fromNow.years.singular.fullWord', '{0} year', value)))
718
- : ( (localize('date.fromNow.years.singular', '{0} yr', value)));
719
- }
720
- else {
721
- return useFullTimeWords
722
- ? ( (localize('date.fromNow.years.plural.fullWord', '{0} years', value)))
723
- : ( (localize('date.fromNow.years.plural', '{0} yrs', value)));
724
- }
802
+ return buttonMap;
725
803
  }
726
804
  }
727
- let BrowserDialogHandler = class BrowserDialogHandler {
728
- constructor(logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
805
+ let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHandler {
806
+ constructor(logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
807
+ super();
729
808
  this.logService = logService;
730
809
  this.layoutService = layoutService;
731
- this.themeService = themeService;
732
810
  this.keybindingService = keybindingService;
733
811
  this.instantiationService = instantiationService;
734
812
  this.productService = productService;
735
813
  this.clipboardService = clipboardService;
736
814
  this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
737
815
  }
816
+ async prompt(prompt) {
817
+ this.logService.trace('DialogService#prompt', prompt.message);
818
+ const buttons = this.getPromptButtons(prompt);
819
+ const { button, checkboxChecked } = await this.doShow(prompt.type, prompt.message, buttons, prompt.detail, prompt.cancelButton ? buttons.length - 1 : -1 , prompt.checkbox, undefined, typeof prompt?.custom === 'object' ? prompt.custom : undefined);
820
+ return this.getPromptResult(prompt, button, checkboxChecked);
821
+ }
738
822
  async confirm(confirmation) {
739
823
  this.logService.trace('DialogService#confirm', confirmation.message);
740
- const buttons = [];
741
- if (confirmation.primaryButton) {
742
- buttons.push(confirmation.primaryButton);
743
- }
744
- else {
745
- buttons.push(( (localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes"))));
746
- }
747
- if (confirmation.secondaryButton) {
748
- buttons.push(confirmation.secondaryButton);
749
- }
750
- else if (typeof confirmation.secondaryButton === 'undefined') {
751
- buttons.push(( (localize('cancelButton', "Cancel"))));
752
- }
753
- const result = await this.doShow(confirmation.type, confirmation.message, buttons, confirmation.detail, 1, confirmation.checkbox);
754
- return { confirmed: result.button === 0, checkboxChecked: result.checkboxChecked };
824
+ const buttons = this.getConfirmationButtons(confirmation);
825
+ const { button, checkboxChecked } = await this.doShow(confirmation.type ?? 'question', confirmation.message, buttons, confirmation.detail, buttons.length - 1, confirmation.checkbox, undefined, typeof confirmation?.custom === 'object' ? confirmation.custom : undefined);
826
+ return { confirmed: button === 0, checkboxChecked };
755
827
  }
756
- getDialogType(severity) {
757
- return (severity === Severity.Info) ? 'question' : (severity === Severity.Error) ? 'error' : (severity === Severity.Warning) ? 'warning' : 'none';
828
+ async input(input) {
829
+ this.logService.trace('DialogService#input', input.message);
830
+ const buttons = this.getInputButtons(input);
831
+ const { button, checkboxChecked, values } = await this.doShow(input.type ?? 'question', input.message, buttons, input.detail, buttons.length - 1, input?.checkbox, input.inputs);
832
+ return { confirmed: button === 0, checkboxChecked, values };
758
833
  }
759
- async show(severity, message, buttons, options) {
760
- this.logService.trace('DialogService#show', message);
761
- const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, undefined, typeof options?.custom === 'object' ? options.custom : undefined);
762
- return {
763
- choice: result.button,
764
- checkboxChecked: result.checkboxChecked
834
+ async about() {
835
+ const detailString = (useAgo) => {
836
+ return (
837
+ (localize(
838
+ 'aboutDetail',
839
+ "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
840
+ this.productService.version || 'Unknown',
841
+ this.productService.commit || 'Unknown',
842
+ this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
843
+ navigator.userAgent
844
+ ))
845
+ );
765
846
  };
847
+ const detail = detailString(true);
848
+ const detailToCopy = detailString(false);
849
+ const { button } = await this.doShow(Severity.Info, this.productService.nameLong, [
850
+ ( (localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"))),
851
+ ( (localize('ok', "OK")))
852
+ ], detail, 1);
853
+ if (button === 0) {
854
+ this.clipboardService.writeText(detailToCopy);
855
+ }
766
856
  }
767
857
  async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
768
858
  const dialogDisposables = ( (new DisposableStore()));
@@ -778,7 +868,7 @@ let BrowserDialogHandler = class BrowserDialogHandler {
778
868
  const dialog = ( (new Dialog(this.layoutService.container, message, buttons, {
779
869
  detail,
780
870
  cancelId,
781
- type,
871
+ type: this.getDialogType(type),
782
872
  keyEventProcessor: (event) => {
783
873
  const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
784
874
  if (resolved?.commandId) {
@@ -793,43 +883,17 @@ let BrowserDialogHandler = class BrowserDialogHandler {
793
883
  buttonDetails: customOptions?.buttonDetails,
794
884
  checkboxLabel: checkbox?.label,
795
885
  checkboxChecked: checkbox?.checked,
796
- inputs
886
+ inputs,
887
+ buttonStyles: defaultButtonStyles,
888
+ checkboxStyles: defaultCheckboxStyles,
889
+ inputBoxStyles: defaultInputBoxStyles,
890
+ dialogStyles: defaultDialogStyles
797
891
  })));
798
892
  dialogDisposables.add(dialog);
799
- dialogDisposables.add(attachDialogStyler(dialog, this.themeService));
800
893
  const result = await dialog.show();
801
894
  dialogDisposables.dispose();
802
895
  return result;
803
896
  }
804
- async input(severity, message, buttons, inputs, options) {
805
- this.logService.trace('DialogService#input', message);
806
- const result = await this.doShow(this.getDialogType(severity), message, buttons, options?.detail, options?.cancelId, options?.checkbox, inputs);
807
- return {
808
- choice: result.button,
809
- checkboxChecked: result.checkboxChecked,
810
- values: result.values
811
- };
812
- }
813
- async about() {
814
- const detailString = (useAgo) => {
815
- return (
816
- (localize(
817
- 'aboutDetail',
818
- "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
819
- this.productService.version || 'Unknown',
820
- this.productService.commit || 'Unknown',
821
- this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
822
- navigator.userAgent
823
- ))
824
- );
825
- };
826
- const detail = detailString(true);
827
- const detailToCopy = detailString(false);
828
- const { choice } = await this.show(Severity.Info, this.productService.nameLong, [( (localize('copy', "Copy"))), ( (localize('ok', "OK")))], { detail, cancelId: 1 });
829
- if (choice === 0) {
830
- this.clipboardService.writeText(detailToCopy);
831
- }
832
- }
833
897
  };
834
898
  BrowserDialogHandler.ALLOWABLE_COMMANDS = [
835
899
  'copy',
@@ -842,20 +906,18 @@ BrowserDialogHandler.ALLOWABLE_COMMANDS = [
842
906
  BrowserDialogHandler = ( (__decorate([
843
907
  ( (__param(0, ILogService))),
844
908
  ( (__param(1, ILayoutService))),
845
- ( (__param(2, IThemeService))),
846
- ( (__param(3, IKeybindingService))),
847
- ( (__param(4, IInstantiationService))),
848
- ( (__param(5, IProductService))),
849
- ( (__param(6, IClipboardService)))
909
+ ( (__param(2, IKeybindingService))),
910
+ ( (__param(3, IInstantiationService))),
911
+ ( (__param(4, IProductService))),
912
+ ( (__param(5, IClipboardService)))
850
913
  ], BrowserDialogHandler)));
851
914
  let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
852
- constructor(dialogService, logService, layoutService, themeService, keybindingService, instantiationService, productService, clipboardService) {
915
+ constructor(dialogService, logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
853
916
  super();
854
917
  this.dialogService = dialogService;
855
918
  this.impl = ( (new BrowserDialogHandler(
856
919
  logService,
857
920
  layoutService,
858
- themeService,
859
921
  keybindingService,
860
922
  instantiationService,
861
923
  productService,
@@ -879,11 +941,11 @@ let DialogHandlerContribution = class DialogHandlerContribution extends Disposab
879
941
  }
880
942
  else if (this.currentDialog.args.inputArgs) {
881
943
  const args = this.currentDialog.args.inputArgs;
882
- result = await this.impl.input(args.severity, args.message, args.buttons, args.inputs, args.options);
944
+ result = await this.impl.input(args.input);
883
945
  }
884
- else if (this.currentDialog.args.showArgs) {
885
- const args = this.currentDialog.args.showArgs;
886
- result = await this.impl.show(args.severity, args.message, args.buttons, args.options);
946
+ else if (this.currentDialog.args.promptArgs) {
947
+ const args = this.currentDialog.args.promptArgs;
948
+ result = await this.impl.prompt(args.prompt);
887
949
  }
888
950
  else {
889
951
  await this.impl.about();
@@ -897,11 +959,10 @@ DialogHandlerContribution = ( (__decorate([
897
959
  ( (__param(0, IDialogService))),
898
960
  ( (__param(1, ILogService))),
899
961
  ( (__param(2, ILayoutService))),
900
- ( (__param(3, IThemeService))),
901
- ( (__param(4, IKeybindingService))),
902
- ( (__param(5, IInstantiationService))),
903
- ( (__param(6, IProductService))),
904
- ( (__param(7, IClipboardService)))
962
+ ( (__param(3, IKeybindingService))),
963
+ ( (__param(4, IInstantiationService))),
964
+ ( (__param(5, IProductService))),
965
+ ( (__param(6, IClipboardService)))
905
966
  ], DialogHandlerContribution)));
906
967
  class DialogsModel extends Disposable {
907
968
  constructor() {
@@ -953,20 +1014,29 @@ let DialogService = class DialogService extends Disposable {
953
1014
  const handle = this.model.show({ confirmArgs: { confirmation } });
954
1015
  return await handle.result;
955
1016
  }
956
- async show(severity, message, buttons, options) {
1017
+ async prompt(prompt) {
957
1018
  if (this.skipDialogs()) {
958
1019
  throw new Error('DialogService: refused to show dialog in tests.');
959
1020
  }
960
- const handle = this.model.show({ showArgs: { severity, message, buttons, options } });
1021
+ const handle = this.model.show({ promptArgs: { prompt } });
961
1022
  return await handle.result;
962
1023
  }
963
- async input(severity, message, buttons, inputs, options) {
1024
+ async input(input) {
964
1025
  if (this.skipDialogs()) {
965
1026
  throw new Error('DialogService: refused to show input dialog in tests.');
966
1027
  }
967
- const handle = this.model.show({ inputArgs: { severity, message, buttons, inputs, options } });
1028
+ const handle = this.model.show({ inputArgs: { input } });
968
1029
  return await handle.result;
969
1030
  }
1031
+ async info(message, detail) {
1032
+ await this.prompt({ type: Severity.Info, message, detail });
1033
+ }
1034
+ async warn(message, detail) {
1035
+ await this.prompt({ type: Severity.Warning, message, detail });
1036
+ }
1037
+ async error(message, detail) {
1038
+ await this.prompt({ type: Severity.Error, message, detail });
1039
+ }
970
1040
  async about() {
971
1041
  if (this.skipDialogs()) {
972
1042
  throw new Error('DialogService: refused to show about dialog in tests.');
@@ -980,7 +1050,9 @@ DialogService = ( (__decorate([
980
1050
  ( (__param(1, ILogService)))
981
1051
  ], DialogService)));
982
1052
  function initialize(instantiationService) {
983
- instantiationService.createInstance(DialogHandlerContribution);
1053
+ setTimeout(() => {
1054
+ instantiationService.createInstance(DialogHandlerContribution);
1055
+ });
984
1056
  }
985
1057
  function getServiceOverride(container) {
986
1058
  onServicesInitialized(initialize);