qsharp-lang 1.0.23-dev → 1.0.24-dev

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.
@@ -0,0 +1,616 @@
1
+ /* Copyright (c) Microsoft Corporation.
2
+ Licensed under the MIT License. */
3
+
4
+ /* Styles for Q# UX components.
5
+
6
+ Notes:
7
+ - Variables and class names should be prefixed with "qs-" to minimize conflicts in other contexts.
8
+ - Colors should be defined in terms of CSS variables, so that they can be overridden by the editor theme.
9
+ - Values should be defined in terms of the VS Code theme colors, with fall-backs for other environments.
10
+
11
+ Define variables as using a VS Code variable by default, e.g. "--vscode-foreground", and then a fallback
12
+ value for use in other environments. Use the variable in setting class properties, e.g:
13
+
14
+ :root {
15
+ --qs-foreground: var(--vscode-foreground, black);
16
+ }
17
+
18
+ .qs-button {
19
+ color: var(--qs-foreground);
20
+ }
21
+
22
+ It is recommended that the page these components are included in using a CSS reset such as
23
+ modern-normalize (see https://mattbrictson.com/blog/css-normalize-and-reset for more information).
24
+ */
25
+
26
+ /* Global variables for styling */
27
+
28
+ /* TODO: Use the qs- prefixes and apply consistently */
29
+ :root {
30
+ --heading-background: #262679;
31
+ --main-background: var(--vscode-editor-background, #ececf0);
32
+ --main-color: var(
33
+ --vscode-editor-foreground,
34
+ var(--jp-widgets-color, #202020)
35
+ );
36
+ --qs-tr-nth-color: var(
37
+ --vscode-list-hoverBackground,
38
+ var(--jp-layout-color1, #f2f2f2)
39
+ );
40
+ --nav-background: #bed1f4;
41
+ --nav-hover-background: #b3bede;
42
+ --nav-current-background: #b5c5f2;
43
+ --border-color: #768f9c;
44
+ --menu-box-fill: var(--main-background);
45
+ --error-background-color: #ffe3e3;
46
+ --bar-selected-outline: #587ddd;
47
+ }
48
+
49
+ /* Generic element resets */
50
+
51
+ /* TODO: Don't apply to entire page */
52
+ *,
53
+ *::before,
54
+ *::after {
55
+ box-sizing: inherit;
56
+ margin: 0;
57
+ padding: 0;
58
+ }
59
+
60
+ html {
61
+ box-sizing: border-box;
62
+ font-size: 16px;
63
+ }
64
+
65
+ /* TODO: Make the below playground specific classes */
66
+
67
+ /* Playground body */
68
+
69
+ .qs-play-body {
70
+ position: relative;
71
+ min-height: 100vh;
72
+ font-family: system-ui, "Segoe UI", "SegoeUI", Roboto, Helvetica, Arial,
73
+ sans-serif;
74
+ color: var(--main-color);
75
+ background-color: var(--main-background);
76
+ display: grid;
77
+ grid-template-areas:
78
+ "header header header"
79
+ "nav editor results";
80
+ grid-template-rows: auto 1fr;
81
+ grid-template-columns: minmax(180px, auto) 8fr 8fr;
82
+ column-gap: 16px;
83
+ }
84
+
85
+ /* Playground layout */
86
+
87
+ .page-header {
88
+ grid-area: header;
89
+ background: var(--heading-background);
90
+ color: var(--main-background);
91
+ font-size: 2rem;
92
+ font-weight: 600;
93
+ text-align: center;
94
+ padding-top: 4px;
95
+ padding-bottom: 8px;
96
+ }
97
+
98
+ #popup {
99
+ position: absolute;
100
+ display: none;
101
+ background-color: white;
102
+ border: 1px solid black;
103
+ border-radius: 2px;
104
+ padding: 8px 16px;
105
+ font-size: 16px;
106
+ }
107
+
108
+ /* Navigation section */
109
+
110
+ .nav-column {
111
+ grid-area: nav;
112
+ background-color: var(--nav-background);
113
+ }
114
+
115
+ .nav-1 {
116
+ font-size: 1.2rem;
117
+ font-weight: 200;
118
+ color: var(--main-color);
119
+ border-top: 1px solid var(--border-color);
120
+ padding-top: 4px;
121
+ padding-bottom: 4px;
122
+ padding-left: 8px;
123
+ }
124
+
125
+ .nav-2 {
126
+ font-size: 1rem;
127
+ font-weight: 200;
128
+ padding: 4px;
129
+ padding-left: 16px;
130
+ }
131
+
132
+ .nav-selectable:hover {
133
+ background-color: var(--nav-hover-background);
134
+ cursor: pointer;
135
+ }
136
+
137
+ .nav-current {
138
+ font-weight: 700;
139
+ background-color: var(--nav-current-background);
140
+ }
141
+
142
+ /* Editor section */
143
+
144
+ .editor-column {
145
+ grid-area: editor;
146
+ margin: 16px;
147
+ margin-top: 32px;
148
+ }
149
+
150
+ .file-name {
151
+ border: 1px solid var(--border-color);
152
+ border-bottom: 0px;
153
+ width: 100px;
154
+ text-align: center;
155
+ height: 32px;
156
+ line-height: 32px;
157
+ background-color: white;
158
+ }
159
+
160
+ .icon-row > * {
161
+ margin-left: 4px;
162
+ font-size: 1.4rem;
163
+ cursor: pointer;
164
+ }
165
+
166
+ .code-editor {
167
+ height: 40vh;
168
+ min-height: 400px;
169
+ border: 1px solid var(--border-color);
170
+ }
171
+
172
+ .button-row {
173
+ display: flex;
174
+ justify-content: flex-end;
175
+ align-items: center;
176
+ margin-top: 8px;
177
+ }
178
+
179
+ .button-row > * {
180
+ margin-left: 10px;
181
+ font-size: 1rem;
182
+ }
183
+
184
+ .main-button {
185
+ background-color: var(--nav-background);
186
+ font-size: 1rem;
187
+ color: var(--main-color);
188
+ width: 72px;
189
+ height: 24px;
190
+ border-radius: 8px;
191
+ border: 1px solid var(--border-color);
192
+ cursor: pointer;
193
+ }
194
+
195
+ .main-button:disabled {
196
+ background-color: gray;
197
+ cursor: default;
198
+ }
199
+
200
+ .error-list {
201
+ margin-top: 24px;
202
+ margin-bottom: 24px;
203
+ min-height: 48px;
204
+ }
205
+
206
+ .error-row {
207
+ border: 1px solid var(--border-color);
208
+ background-color: var(--error-background-color);
209
+ padding: 4px;
210
+ border-bottom: 0.5px solid gray;
211
+ font-size: 0.9rem;
212
+ margin-bottom: -1px;
213
+ }
214
+
215
+ .error-row > span {
216
+ font-weight: 200;
217
+ }
218
+
219
+ .error-help {
220
+ font-weight: 200;
221
+ font-style: italic;
222
+ }
223
+
224
+ /* Katas */
225
+
226
+ .kata-override {
227
+ background-color: var(--main-background);
228
+ }
229
+
230
+ /* TODO: Update all components with specific prefixes */
231
+
232
+ /* Results panels */
233
+
234
+ .results-column {
235
+ grid-area: results;
236
+ margin-left: 0px;
237
+ margin-top: 32px;
238
+ margin-right: 120px;
239
+ }
240
+
241
+ .active-tab {
242
+ font-size: 1.1rem;
243
+ font-weight: 600;
244
+ text-decoration: underline;
245
+ }
246
+
247
+ .results-labels {
248
+ display: flex;
249
+ height: 32px;
250
+ }
251
+
252
+ .results-labels > div {
253
+ margin-right: 40px;
254
+ text-align: left;
255
+ vertical-align: middle;
256
+ cursor: pointer;
257
+ }
258
+
259
+ .hir-output {
260
+ height: 40vh;
261
+ min-height: 400px;
262
+ width: 100%;
263
+ resize: none;
264
+ white-space: pre;
265
+ }
266
+
267
+ /* Results output */
268
+
269
+ .output-header {
270
+ font-size: 1.1rem;
271
+ font-weight: 400;
272
+ margin-top: 16px;
273
+ margin-bottom: 16px;
274
+ display: flex;
275
+ justify-content: space-between;
276
+ }
277
+
278
+ .prev-next {
279
+ font-weight: 200;
280
+ cursor: pointer;
281
+ }
282
+
283
+ .result-label {
284
+ margin-bottom: 24px;
285
+ font-style: italic;
286
+ font-weight: 300;
287
+ }
288
+
289
+ .message-output {
290
+ font-weight: 300;
291
+ font-size: 1.1rem;
292
+ margin-bottom: 16px;
293
+ }
294
+
295
+ /* State table */
296
+
297
+ .state-table {
298
+ border-collapse: collapse;
299
+ font-size: 0.9rem;
300
+ width: 100%;
301
+ min-width: 400px;
302
+ margin-bottom: 16px;
303
+ }
304
+
305
+ .state-table thead tr {
306
+ background: var(--nav-background);
307
+ }
308
+
309
+ .state-table tbody tr {
310
+ border-top: 1px solid gray;
311
+ }
312
+
313
+ .state-table td,
314
+ .state-table th {
315
+ text-align: center;
316
+ padding: 6px;
317
+ white-space: nowrap;
318
+ }
319
+
320
+ .state-table progress {
321
+ margin-right: 2px;
322
+ }
323
+
324
+ /* Histogram */
325
+
326
+ .histogram {
327
+ max-height: calc(100vh - 40px);
328
+ border: 1px solid var(--border-color);
329
+ background-color: var(--vscode-sideBar-background, white);
330
+ }
331
+
332
+ .bar {
333
+ fill: var(--vscode-button-background, var(--nav-background));
334
+ }
335
+
336
+ .bar:hover {
337
+ fill: var(--vscode-button-hoverBackground, var(--nav-hover-background));
338
+ }
339
+
340
+ .bar-selected {
341
+ stroke: var(--bar-selected-outline);
342
+ fill: var(--nav-current-background);
343
+ }
344
+
345
+ .bar-label {
346
+ font-size: 3pt;
347
+ fill: var(--vscode-button-foreground, var(--main-color));
348
+ text-anchor: end;
349
+ pointer-events: none;
350
+ }
351
+
352
+ .histo-label {
353
+ font-size: 3.5pt;
354
+ fill: var(--vscode-foreground, #3b3b3b);
355
+ }
356
+
357
+ .hover-text {
358
+ font-size: 3.5pt;
359
+ fill: gray;
360
+ text-anchor: middle;
361
+ }
362
+
363
+ .menu-icon * {
364
+ stroke: black;
365
+ fill: var(--vscode-sideBar-background, white);
366
+ stroke: var(--vscode-icon-foreground, #3b3b3b);
367
+ }
368
+
369
+ .menu-box {
370
+ fill: var(--menu-box-fill);
371
+ stroke: black;
372
+ stroke-width: 0.1;
373
+ }
374
+
375
+ .menu-item {
376
+ width: 32px;
377
+ height: 10px;
378
+ fill: var(--vscode-list-inactiveSelectionBackground, var(--nav-background));
379
+ stroke: gray;
380
+ stroke-width: 0.2;
381
+ }
382
+
383
+ /* --vscode-list-inactiveSelectionBackground */
384
+
385
+ .menu-item:hover {
386
+ stroke-width: 0.6;
387
+ fill: var(--vscode-list-hoverBackground, var(--nav-hover-background));
388
+ }
389
+
390
+ .menu-selected {
391
+ /* stroke: #0800ff; */
392
+ fill: var(
393
+ --vscode-list-activeSelectionBackground,
394
+ var(--nav-current-background)
395
+ );
396
+ }
397
+
398
+ .menu-text {
399
+ font-size: 4.5px;
400
+ pointer-events: none;
401
+ fill: var(--main-color);
402
+ }
403
+
404
+ .menu-separator {
405
+ stroke: gray;
406
+ stroke-width: 0.25;
407
+ }
408
+
409
+ .help-info {
410
+ fill: var(--menu-box-fill);
411
+ stroke: gray;
412
+ stroke-width: 0.5;
413
+ }
414
+
415
+ .help-info-text {
416
+ font-size: 4.5px;
417
+ pointer-events: none;
418
+ fill: var(--main-color);
419
+ }
420
+
421
+ /* RE details */
422
+
423
+ .estimate-details {
424
+ padding: 1em;
425
+ }
426
+
427
+ .estimate-details > summary {
428
+ font-size: 1.1em;
429
+ }
430
+
431
+ .estimate-table {
432
+ margin-top: 1em;
433
+ font-size: 0.9em;
434
+ }
435
+
436
+ .estimate-table tr:nth-child(even) {
437
+ background-color: var(--qs-tr-nth-color);
438
+ }
439
+
440
+ .estimate-cell {
441
+ vertical-align: top;
442
+ padding-right: 8px;
443
+ }
444
+
445
+ .title-cell {
446
+ font-weight: bold;
447
+ white-space: nowrap;
448
+ }
449
+
450
+ .value-cell {
451
+ text-align: center;
452
+ width: 100px;
453
+ white-space: nowrap;
454
+ }
455
+
456
+ .estimate-explanation {
457
+ margin-top: 1em;
458
+ margin-bottom: 1em;
459
+ max-width: 500px;
460
+ }
461
+
462
+ .estimate-assumption {
463
+ margin: 1em;
464
+ }
465
+
466
+ /* Space chart */
467
+
468
+ /* Needed until https://github.com/microsoft/vscode-jupyter/issues/7161 is resolved */
469
+ .cell-output-ipywidget-background {
470
+ background-color: transparent !important;
471
+ }
472
+
473
+ #pieChart {
474
+ fill: var(--main-color);
475
+ }
476
+
477
+ .spaceReport {
478
+ display: flex;
479
+ flex-direction: column;
480
+ }
481
+
482
+ .spaceReportHeader {
483
+ font-size: 13px;
484
+ background-color: var(--qs-tr-nth-color);
485
+ border-top: 0.5px gray solid;
486
+ border-bottom: 0.5px gray solid;
487
+ padding: 10px;
488
+ }
489
+
490
+ .spaceReportRow {
491
+ display: flex;
492
+ font-size: 12px;
493
+ padding: 10px 24px;
494
+ }
495
+
496
+ .spaceDetailText {
497
+ width: 200px;
498
+ }
499
+
500
+ .qs-help {
501
+ font-size: 14px;
502
+ line-height: 1.5;
503
+ word-wrap: break-word;
504
+ }
505
+
506
+ .qs-help h1 {
507
+ margin-top: 16px;
508
+ margin-bottom: 8px;
509
+ line-height: 1.25;
510
+ font-weight: 600;
511
+ padding-bottom: 0.3em;
512
+ font-size: 2em;
513
+ border-bottom: 1px solid var(--vscode-editorWidget-border);
514
+ }
515
+
516
+ .qs-help h2 {
517
+ margin-top: 16px;
518
+ margin-bottom: 8px;
519
+ font-weight: 600;
520
+ line-height: 1.25;
521
+ padding-bottom: 0.3em;
522
+ font-size: 1.4em;
523
+ border-bottom: 1px solid var(--vscode-editorWidget-border);
524
+ }
525
+
526
+ /* Results Table */
527
+
528
+ .qs-resultsTable-sortedTable {
529
+ border-collapse: collapse;
530
+ margin: 12px 0px;
531
+ }
532
+
533
+ .qs-resultsTable-sortedTable th,
534
+ .qs-resultsTable-sortedTable td {
535
+ padding: 4px 8px;
536
+ text-align: left;
537
+ }
538
+
539
+ .qs-resultsTable-dragEnter {
540
+ background-color: #8888;
541
+ border-left: 1.5px solid blue;
542
+ border-right: 1.5px solid blue;
543
+ }
544
+
545
+ .qs-resultsTable-sortedTable tr:nth-child(even) {
546
+ background: var(--qs-tr-nth-color);
547
+ }
548
+
549
+ .qs-resultsTable-sortedTable tbody tr:hover {
550
+ background: var(--vscode-list-hoverBackground);
551
+ }
552
+
553
+ .qs-resultsTable-sortedTableSelectedRow td {
554
+ background: var(--vscode-button-background);
555
+ color: var(--vscode-button-foreground);
556
+ font-weight: 600;
557
+ }
558
+
559
+ .qs-resultsTable-columnMenu {
560
+ display: none;
561
+ width: 160px;
562
+ }
563
+
564
+ .qs-resultsTable-showColumnMenu {
565
+ display: block;
566
+ position: absolute;
567
+ background-color: var(--vscode-menu-background);
568
+ border: 1px solid #8888;
569
+ padding: 4px;
570
+ z-index: 100;
571
+ text-align: left;
572
+ }
573
+
574
+ .qs-resultsTable-menuItem {
575
+ cursor: pointer;
576
+ background-color: var(--vscode-list-hoverBackground);
577
+ padding: 4px;
578
+ margin: 2px;
579
+ font-size: 14px;
580
+ font-weight: 400;
581
+ }
582
+
583
+ .qs-resultsTable-menuItem:hover {
584
+ background-color: var(--vscode-menu-border);
585
+ }
586
+
587
+ .qs-resultsTable-columnSelected {
588
+ cursor: pointer;
589
+ padding: 4px;
590
+ font-weight: 400;
591
+ font-size: 14px;
592
+ background-color: var(--vscode-button-background);
593
+ color: var(--vscode-button-foreground);
594
+ margin: 2px;
595
+ border-radius: 3px;
596
+ }
597
+
598
+ .qs-resultsTable-headerCell {
599
+ padding-right: 20px;
600
+ }
601
+
602
+ .qs-resultsTable-sortHeaderCell {
603
+ padding-right: 4px;
604
+ }
605
+
606
+ @keyframes codicon-spin {
607
+ 100% {
608
+ transform: rotate(360deg);
609
+ transform-origin: center;
610
+ }
611
+ }
612
+
613
+ .codicon-modifier-spin {
614
+ fill: var(--vscode-icon-foreground, gray);
615
+ animation: codicon-spin 1.5s steps(45) infinite;
616
+ }
package/ux/reTable.tsx ADDED
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ import { useState } from "preact/hooks";
5
+
6
+ export type ReData = {
7
+ status: string;
8
+ jobParams: any;
9
+ physicalCounts: any;
10
+ physicalCountsFormatted: any;
11
+ logicalQubit: any;
12
+ tfactory: any;
13
+ errorBudget: any;
14
+ logicalCounts: any;
15
+ reportData: {
16
+ groups: {
17
+ title: string;
18
+ alwaysVisible: boolean;
19
+ entries: {
20
+ path: string;
21
+ label: string;
22
+ description: string;
23
+ explanation: string;
24
+ }[];
25
+ }[];
26
+ assumptions: string[];
27
+ };
28
+ };
29
+
30
+ export function ReTable(props: {
31
+ mdRenderer: (input: string) => string;
32
+ estimatesData: ReData;
33
+ }) {
34
+ const [showDetail, setShowDetail] = useState(false);
35
+ const toggleDetail = () => {
36
+ setShowDetail(!showDetail);
37
+ };
38
+
39
+ return (
40
+ <div>
41
+ <div>
42
+ <input
43
+ type="checkbox"
44
+ id="showDetail"
45
+ checked={showDetail}
46
+ onClick={toggleDetail}
47
+ />
48
+ <label htmlFor="showDetail"> Show detailed rows</label>
49
+ </div>
50
+ {props.estimatesData.reportData.groups.map((group) => {
51
+ return (
52
+ <details className="estimate-details">
53
+ <summary>
54
+ <strong>{group.title}</strong>
55
+ </summary>
56
+ <table className="estimate-table">
57
+ {group.entries.map((entry) => {
58
+ // entry.path is a '/' separated path to the value in the JSON to show
59
+ const path = entry.path.split("/");
60
+ let value = path.reduce(
61
+ (obj, key) => obj[key],
62
+ props.estimatesData as any,
63
+ );
64
+ // Check if value is not a primitive type
65
+ if (typeof value === "object") {
66
+ value = JSON.stringify(value);
67
+ }
68
+ const renderedExplanation = {
69
+ __html: props.mdRenderer(entry.explanation),
70
+ };
71
+ return (
72
+ <tr>
73
+ <td className="estimate-cell title-cell">{entry.label}</td>
74
+ <td className="estimate-cell value-cell">{value}</td>
75
+ <td className="estimate-cell">
76
+ {showDetail ? (
77
+ <>
78
+ <strong>{entry.description}</strong>
79
+ <hr />
80
+ <div
81
+ className="estimate-explanation"
82
+ dangerouslySetInnerHTML={renderedExplanation}
83
+ />
84
+ </>
85
+ ) : (
86
+ <>
87
+ <span>{entry.description}</span>
88
+ </>
89
+ )}
90
+ </td>
91
+ </tr>
92
+ );
93
+ })}
94
+ </table>
95
+ </details>
96
+ );
97
+ })}
98
+ <details className="estimate-details">
99
+ <summary>
100
+ <strong>Assumptions</strong>
101
+ </summary>
102
+ <ul className="estimate-table">
103
+ {props.estimatesData.reportData.assumptions.map((assumption) => (
104
+ <li
105
+ className="estimate-assumption"
106
+ dangerouslySetInnerHTML={{ __html: props.mdRenderer(assumption) }}
107
+ />
108
+ ))}
109
+ </ul>
110
+ </details>
111
+ </div>
112
+ );
113
+ }